Thank you all for coming to my talk. I wasn't really sure what to expect, but this is Referral to Where Your Rewards Are Mine, Exploring Insecurity and Incentive Rewards Program. This was a research project I did for my work that I found a lot of interest in and I hope you guys find a lot of interest in it, too. So just a little bit about who I am, because unless you're one of these people in the front row, you have no clue who I am. My name is Whit Taylor. If you see me online, I go by Unity Cyber on all platforms. I am an application pen tester at Rhino Security Labs. And outside of that, I do a whole lot of bug bounty hunting, security research on open source projects, things like that. Proud father and husband to a beautiful wife and a very, very large six and a half month old. And outside of that, I play the piano. I do power lifting. I go fishing. This is my beautiful family and this is me aura farming in the gym, dead lifting 500 pounds. I'm going to pause for a second to aura farm for a second. Yeah, lightweight. So why refer rewards? This was kind of a 2 a.m. hacking thought when I was just up late for no reason hacking and just thought this would be a really great idea. I wanted to find a piece of web functionality that no one had really looked at and I thought, what's the most boring part of a web application? Well, refer rewards seemed to fit that bill and I didn't really see anything out there on it. And so I went ahead and I fired a way and about three days later, the CFP for Bug Bounty Village opened up at which point I had no results and I kind of just said YOLO and sent off this idea to Harley with absolutely nothing ready to present. No results. This really could have gone terrible, but I figured I was going to find stuff and I did and I hope you guys find some interest in it. So a little background on refer rewards programs. If you've ever gone to a web application, you've probably seen something like this where you can share this link with a friend, they sign up, you get a reward, everyone gets a reward. It can be monetary value, it can be extra assets within the application. It kind of varies, but usually it's something monetary like cash or credit on the application. And companies all over use this. I haven't really seen a company that hasn't done this in some form or fashion. Companies from Google, HelloFresh, Robinhood, Etsy, you name it, they probably have a referral rewards program in some form or fashion. And so the way I'm going to do this talk is I'm going to go into the various technical implementations on how this works, typically, and typically how the relationship is established between the referrer and the referee and how that works in the back end. And then I'll go into some various findings of which I had along the way. Disclosure, I'm not allowed to disclose any of the actual technical details of the bugs, but I did the painstaking process of diagramming them all out in a very redacted fashion so that you can at least see how these attacks work. And so the first implementation you're going to see on a web application is a URL to cookie value. And so the way this works is that the user receives this referral link, they navigate to the link, and the code on the page extracts that link and adds it as a cookie. And then the user will end up signing up, they'll do some required action to receive the referral reward, that code is sent along as a cookie, user gets a reward, referrer gets a reward, everyone gets a reward. The second type is pretty much the same deal except instead of a cookie, there's several requests that are initiated by the client side code. And so same deal, the user receives this link, they navigate to it, the code is extracted, and usually there is a request that validates whether it's a valid code or not. If that passes a check, then it's applied in a secondary request to this pending user account. And then the user will complete sign up and again, you know, they'll have to do some required action, which is usually spending a certain amount, doing this, doing that, and then both parties will end up receiving a reward. And then thirdly, if you've ever been to an e-commerce site, you've probably seen the option of entering in a promo code. That's pretty much how this works. You can share your code with your friend, they'll begin checkout, it'll be applied as a promo code or as a discount, and then the user completes checkout and the rewards are applied to both parties. And then finally, if you've ever been to a mobile app, almost every single mobile application when sharing any data typically follows this particular code pattern. I'm not going to go into the details on how Android applications work. If you want to learn more about that, Live Overflow has a great course on Hackstreet.io. But typically intents are how data is passed around on Android applications. And so if you've ever shared anything to any other application, you'll click a button and this is typically what the code will look like. You'll get a pop-up like this where you can decide which app you want to share it to and then the data will be added to the application for you to send along in whatever form or fashion the app supports. And so why should companies care? Well, there's typically a direct or indirect financial impact to the company, whether or even to the user, because a lot of these rewards are monetary, either to the user or from the application. And so this can have impacts to their revenues, they can be a source of fraud for the application. So there's a lot of attack vectors that come with this functionality. And so companies should really address these and it's really under an underserviced area of company security programs where they're not really paying attention to this stuff. And so the way in which I approached this research was I asked myself a bunch of questions and I wanted to answer those questions. And so that's how I'm going to deliver all of these different bug classes to you. And so the first thing I wanted to find were client-side gadgets. And if you don't know what a gadget is, it's a bug that's not really impactful such as an open redirect, a client-side patch reversal, something that you can't really submit right then, but if you chain it with something else, you can make it very impactful. And so that's something I look for often in my hacking and so I wanted to see if this kind of functionality would bear any fruit in that area. And it turns out that it did. So the first thing that you can really find in this area, particularly with technical implementation one, is cookie injection. So when the application's taking your referral code and it's adding it to a cookie, if you can somehow break out of that cookie value context, you can do a lot of things with cookie injection. This can lead to cookie tossing if you can completely break out of the context of the cookie, you can inject set cookie headers and you can set arbitrary cookies on the site and you can do some really nasty things that can do anything from take over the account, you can do cookie bombing in the same form or fashion which you can just overflow the user's cookie jar with so much data that the request breaks and it won't allow them to navigate to the site, or if you can only break out of the cookie value and set arbitrary cookie attributes for that cookie, then you can do cookie fixation and you can accomplish certain things and that will come up later in the talk. And then secondly, client-side patroversals. If you don't know what that is, it's when a value in the URL is concatenated on to a fetch request, XHR request, something like that, and it's used to construct an API call and typically, like in the diagram here, you can put it in a patroversal sequence into a parameter like this and instead of it making a request to slash API users one, you can make it traverse all the way up the path and you can control where that request is sent and that can be very impactful, you can get XSS from it, you can bypass CSRF mitigations and get cross-site request forgery and it can be very impactful when combined with other gadgets. And so if you want a resource on CSPTs, I highly recommend this blog, they've got a lot of stuff there, really great to check out. All right. My second question was, can I abuse the logic? I'm a big business logic error hunter. I love finding ways in which you can abuse the logic, abuse the assumptions that developers made, and I was very certain that there was some complex logic in which developers were making assumptions. And I was correct. And one of my favorite vulnerabilities that I found was something called the infinite credit flaw or the infinite money flaw. I found this on a couple programs. Typically the requirement here is the application allows sign up with alias email, so if you have user plus one at gmo.com, user plus two at gmo.com and so on, that's what I mean by alias emails. And then typically it would require no, there would be no requirement for new users to start referring users, and the reward for a referral ends up being greater than the spending requirement for this referral. And on this particular target, while I can't name drop, current users could refer friends, new users would sign up and make a purchase of X dollars, and then that user would, and the referring user would receive store credit several times greater than the required spend. And so the way that this works, and this is a bit complex, so I'll pause at the end for you to get the diagram. You start with two accounts. Your goal is to get user one as much credit as possible. And so you start by referring user one. User one buys and triggers the reward. You go back and you refer user two and buy and trigger the reward. And so now both of these accounts have credit. And this is the last time you will have to spend any money out of pocket on this particular website. Everything else is from credit you generate from the application. And then you just continue this with user three and user one. User four and user one and so forth. And I was able to generate thousands of dollars of credit on this particular application. And the program rewarded me with $150 bounty. And that will be the theme pretty much of this entire talk. Bug bounty was not kind to me in this research, but I hope you can take it and do something more with it. The second idea that I had was a lot of these applications would require you to make an order before you could refer. And I wanted to see if I could somehow circumvent that logic or find a way to not complete that process in order to bypass that logic. And so in this case, the application requires an order before referral. Orders are not automatically processed and order cancellation is allowed. And in this case, this particular target, the user is required to make an order before a referral code is unlocked. And you could use that referral code to discount orders. And so here again, I signed up with two accounts. User one would shop and checked out with a scheduled delivery. And that would unlock the referral code. And then I would then go to user two, I'd shop, I'd check out with that referral code, that my order would be discounted, and then I'd go back to user one, cancel the scheduled order, bypassing the logic that I had in place. And that was pretty much all that there was to that bug. This bug rendered no bounty. A triager told me that there was no CIA impact and ignored my messages for about three months until I gave up. And it is currently in the mediation black hole. If you know ways to get out of that, please let me know. And then one of the other things that I checked, and I'm not going to go through all the business logic flaws, because there were many, I wanted to see if there was a way to refer myself or discount myself. I was certain that there was an application out there that wasn't validating that the referral code didn't belong to the user who was doing it, and I was correct. And so the application utilized the referral code as a promo code implementation, and I had to have some way to retrieve this referral code before getting my subscription. And so the way in which this works, the attacker would sign up for an account, and on this application, as soon as you sign up for your account, it would immediately throw you into the subscription flow. And this is easy to get out of. You just force browse back to the root directory, and then you would be able to navigate to your account settings. And then one of the API requests that gets initiated when you navigate to your account settings would contain your referral code. And then the attacker just restarts the subscription flow, sorry, and you complete the subscription, discounting yourself, and successfully using your own referral code as a promo code. I had to make this slide a lot smaller, so I didn't include this detail. On this particular application, you could continue to cancel your billing at the end of the billing cycle and then redo this attack, and so you could perpetually continue to get 50 percent off each billing cycle, cheating the company out of a lot of money if enough users found out how to do this. OK. Race conditions. I was certain I could find a race condition here, and certainly, and I was successful in doing so. This is a financial app that I found, and this is the flow in which users would sign up using a referral code. They'd visit the link. There'd be a put request that signs the account up. And then as soon as you send that request, this validation request would get sent, and it really wasn't a validation request. It really just checked to see if the account existed already or if it had already been referred by the code being used. And then the final request that applied the referral code was the one that ended up being vulnerable to this, and so using James Kettle's single packet attack, I intercepted this request and sent it to a repeater and used the send in parallel, and I was able to generate a whole bunch of rewards just off of a single referral. This was also one of those fun bug bounty moments. Dealing with the program, there was a lot of user verification to the point where you had to verify using your social security number, and so they outright refused to get me a second account to confirm this attack. And so while I have all these rewards still pending in my account, they won't approve my application, and they told me that there's no possible way that I was going to get those rewards anyways, and so they told me to F off, but they ended up fixing it about, I don't know, a week later. And then finally, could I steal referrals? This was the big question I wanted to answer, and there's a couple ways you can do this. One of them is super realistic. Companies will probably care about it. One of them is really just referral hijacking as a service. So cookie fixation. I talked a lot about cookie injection in the client side gadgets, and this particular attack vector is when you would break out of the cookie value and you could set it to a specific path, and so the attacker would send this crafted link that breaks out of the cookie value and sets the path of the cookie, the path attribute of the cookie to the request that signs the user up or whatever request is applying that referral code. So victim visits the link, that cookie is stored within that specified path, and the reason that we do this is because according to cookie RFC, the cookie at the more specified path is going to be prioritized over a cookie at a less specified path. And so what happens is this victim eventually receives a referral link from their friend, and the victim will complete the signup, but because that attacker cookie gets prioritized, our attacker account receives a reward instead of the person doing the referral. I'll pause for a second for pictures. And then finally, referral hijacking by mobile design. I mentioned how mobile apps typically work, and the way in which this attack works is most mobile applications kind of leave this up to the user to not accidentally click on a malicious mobile app that's on their device, and this is really a niche attack scenario in which there's really no reason for the application to leave it up to the user to select, and in this particular application, there were several buttons, one included send by e‑mail, and the application would set the type to message slash RFC 822, and then it would give that pop‑up where any app that could receive e‑mail data would be possible. The way this attack would work is you get your malicious attacker app on the program, you would peruse it as e‑mail, setting the package name to something like a.a.gmail, you'd set the icon of the application to match e‑mail, and then you just wait for the user to accidentally click on your app, thinking that it is the actual e‑mail app, the code within your app would then intercept it, change the data to your referral code, and then pass it on to the intended application in which it's going to, and then the user would be none the wiser. All right, takeaways. I made about 25‑plus submissions, and then I kind of got tired of dealing with it. I made less than $1,000 in bounties. Really frustrating experience. You know, bug bounty is a scam. Sometimes. I had a lot of fun with this. There's some really great parts of bug bounty, but unfortunately, you can have situations like this. Like I mentioned, there were triagers who didn't understand impact and would close as informative without letting me explain the attack scenario, without letting me explain the impact. Companies would cite expected behavior and still fix it. Other companies would eventually fix but not pay. And then others that did would pay super low bounties, which is kind of on me for hunting on programs with low bounty tables. But all in all, really enjoyed the research. It was really an underserviced area. I hope you all got a lot out of it. Hopefully, you know a little more about referral programs than when you came in. And I just want to thank all these people in the front row for being such great support. Thank you. And I went really, really fast. It was great. It was great. Yeah. Absolutely. I have a question. Questions? Okay. How did you submit directly? One of the programs in which I submitted had their own self-hosted program. But it ended up being unexploitable in that scenario. But there were a couple programs that had their own self-hosted programs. But almost everything was through HackerOne or Integrity. And one through BugCrowd. Yeah. So I have a pending vulnerability and a target that I'm not allowed to mention. Because they saw my talk and commented on the submission and wanted to make sure that I wasn't going to name drop them, which is why they were removed from all slides. So I will eventually find out if that's the case. No. So after about 25 submissions, I kind of just called it quits. Because, again, I don't like working for free. And so at the point where I realized that until there was some research out there to back up what I'm doing, I wanted to stop. I may go back. I know that there's some higher profile targets that I want to go after with it. But no, I did not check into that. You think... Probably so. Yeah. So, I mean, it looks like you did a bunch of research on this, obviously. You had a talk. A bunch of good work. But is there anything that you think you missed in targeting this? Absolutely. Absolutely. So... Yeah. What would be the next steps that maybe you didn't? So business logic errors are vast. And you really can't find enough of them. Because every application has its own logic. And so the way in which you impact, you know, the applications that I did, probably you could do something different for other applications. So it really varies. And so, you know, I asked myself a lot of questions. But then I kind of just stopped. So you could really just continue to go down the business logic error route. Because that's really where the most bugs are with this functionality. No, that's a single packet attack. I did not. Oh. So if I could inject arbitrary set cookie headers, my first thing would... I would first look for ATO paths. Because if you can set cookies, then there's some really nasty things. I don't know if you can necessarily get an ATO out of that. Like you'd have to have some other gadgets involved. A great thing to do there, because that's really cookie tossing, right? And so you could leak PII, like set it to a specific path, when the victim goes to update their credit card. You could set your session cookie using that. And so that would be what I would look for first. If I couldn't do that, then yeah, cookie bombing. Cookie bombing to client-side DOS is probably what I would go to next. In other contexts, yeah. I have a couple pending bounties on other targets, on something not related to this, that have been accepted with cookie bombing payloads, yeah. That's a good question. I didn't explore that. That's interesting. Okay. Yeah. I'd have to look into that. Oh, God. Clearly not thousands of dollars. That's a good question. I don't know. Potentially. Potentially. Like I don't have a definite answer there, but potentially. But the financial... Yeah. So to that point, I really hate that I can't talk about a very specific scenario, but a company that runs a bug bounty platform on their platform has a selection for fraudulent transactions. And so that makes me think, yes, but they have to care about it. And so if it's a target like that, then yeah. I think they'll pay. But again, I don't know. No. They were always implemented by the company. All right. Thank you very much. Thank you. Thank you.