So, our next speaker is a veteran to the cloud village. This is Jenco Huang. Jenco is a principal researcher... Yeah, yeah, no, give it up. So Jenco is a principal researcher on Netscope's Threat Research Team, where he focuses on cloud threats and vectors. He spent time in engineering and product roles at various security startups, focusing on vulnerability scanning, pen testing, threat intel, and Windows security. In this talk, he's going to demonstrate how a handful of SSO attacks work, what's the difference between them, how the underlying SSO protocols and features are abused, and where defensive measures fail. So, please give another warm welcome to Jenco. Thanks, Mike. I will take your applause, even if it's out of pity. Thank you. Thanks for coming, if you just woke up, or if you're still up from last night. Hope you're having a great time. Alright, we are going to start here, and I'm going to give you a few things to level set. So, we've got a couple themes when we talk about SSO, just to frame it. We're going to talk about different chains, attack chains, trust chains. We're going to focus a lot on protocols at the design and implementation level, which is where I think it goes wrong. Concepts and principles, and I personally have a few goals here. So, just so you know where I'm coming from. I actually have about 80 minutes of content. We've got to shrink it into about 39 minutes. So, I'm going to amp it up to 2x speed, but this is a shared responsibility model. So, you're going to have to listen at 2x speed, right? And I like this graphic because it just had ecstasy in it. So, I have a stretch goal of making this, you know, go through ecstatic feelings for you. I can stay untangled here. If you don't get informed, we'll just try to entertain you. Got a few vendor jokes. Hopefully, you'll laugh at those. And if those don't work, I think you'll feel better about yourself because, you know, it's probably because you don't have the problems I'm going to go over. So, let's see how we do. Alright, so let's get into SSO. Let's do it in one minute, sort of review what it is and why should we even be talking about it. Well, you probably think, look, it's been around for 10, 20 years. Let's look at SAML, right? SAML 2.0. Do I have a clicker here? Or am I going to be running back and forth? Thank you. Well, that was a faux pas audio. Which button? Okay, I'm good. So, SAML. We have an identity provider. It can be separate, pure play, like Okta. It could be built into your apps and resources. Okay, nothing to be surprised there. But the flow can be initiated on two sides. You can start at the identity provider. Go to Okta. Log in. Get the dashboard, right? No surprise here. Bunch of enterprise apps. Click on one. Maybe it's Jira. Hop right in. So, although we're architecturally separating them, of course the user sees us in one browser, right? So, they see a few pop-ups. They're happy. Log in once. Maybe they go to a second app. Don't have to log in. Pop into Salesforce, right? There's redirects happening underneath of some kind off in HTTP. Okay, great. So far, so good. It can also start at the service provider where your apps and data are. Okay , great. So, someone goes to Jira. And then usually there's a choice. Do you want to do SSO or sort of direct log in? And they pick it, right? We have these buttons down here that we see. And it gets redirected and they see a log in. And then they come back in. So, the user sort of sees the same experience, but they went to a different point. Okay, no surprise there. We come to conventional wisdom. And I am talking fast because I've got 80 minutes to fit into 40. I've got too many drugs, too little sleep. So, stay with me, all right? Don't fall behind. You're going to miss something like a joke. All right. SSO is a good thing. It's a best practice. I don't think you'll find anyone saying it's a bad thing if you Google. Centrally managed, of course. That allows you to do better authentication policies if it's in one place. It's more consistent. No argument there. Of course, then you can do a better job at enforcing stronger authentication policies. Whatever it is. MFA, password shrink, rotating credentials. Great. And, of course, the attack surface is smaller because you don't have your users juggling, keeping track of a million passwords. Right? And that's great because they're the weak link. And it's probably one of the areas where security aligns with the user. This is better security if you believe the first few bullet points and your users are happy because it's more convenient. But... so I went out of security. Went to Disney for a quote. Just thinking the status quo is a good idea. Especially if it's 10 or 15 years old. Could be risky. And it's hard to find a good meme, but let's say Cinderella. Her status quo is mopping floors for her stepmom. Or maybe she's at the ball. And I just like that disdain age. Strong women quote. The point is we can't assume that what we're doing is safe because things change. So let's start talking about the tax, which is really the meat of it. I'm going to start with assumptions because that certainly makes an ass out of you and I or whoever's assuming. So one assumption is centrally managed is better. Or more secure. But there's a risk there because it's like the big red button that allows you to easily do things. You can really F it up, right? In this case, you have a central point of compromise and you have a huge blast radius, which is all the apps and data under the SSO umbrella. Makes sense, right? I'm just going to point out one thing. It's also contrary to security principles. Ask yourself what companies out there of any size have their production environment under the same SSO umbrella as development or everyday user. None. Other than the startups that play loose and fast. But any company that wants to stay in business doesn't do that. So already you have islands of SSO or authentication domains. That should be a warning flag to all of us that the conventional wisdom requires sort of review. So what really is the opening for abuse? So let's start with a classic one, Golden SAML, which is really a supply chain abuse of trust. But when it's combined with an SSO impact, it's once you have an upstream attack, you now have this huge blast radius. And to quickly review it, I don't want to go into SAML, but I'm going to point out a little bit of the complexity. You have all this interchange, right? Identity provider, user, service provider. And the Golden SAML attack, although this diagram shows it as a man-in-the-middle attack, the key to it is you have stolen signing keys, right? Shown here in the client. And although they're using AWS, it could be any resource manager. The key here is that they can sign a SAML assertion and just send it to where the app in question and it will take it. There's no other setup here. There's no state. This is really step three right here. So the protocol itself is stateless in the sense of the service provider with all the valuable data might just receive a SAML assertion and be like, oh, is this validly signed? Great, you're in. And that's sort of an example of how the protocol, although it's not a flaw, opens itself up to abuse. Although this is CyberArk's good work in 2017, this is part of SolarWinds, which is more recent, right? So you think about that. Although this is a harder attack to pull off because you have to compromise internally with ADFS, once you do that, and it's been done, you have huge, huge impact. Impact for access, persistence, lateral movement, because you essentially can create a SAML assertion and gain access to the whole SSO umbrella of that organization, all the apps and data. So let's move to a second assumption. We're moving laterally and we'll jump deep. So I'm sort of stretching your minds horizontally and vertically, right? Think of it as sort of mental bondage, right? I'm going to really stretch you guys. I'm the dominant one, by the way. I am trying to introduce terms that you wouldn't normally hear. Keep you entertained. Ecstasy. Bondage. Keep track. We'll have a little bingo game. Nice. I'm going to use that in the next presentation. Alright. Okay. You're cutting into my minutes. I like you, but... First I'm going to take this off. It's probably blinding you. I apologize. I did cover my head. That won't blind you. Alright. Let's get back to it. Assumption number two, ASS number two for short, is we at least understand SSO. So even if there's risk, we can deal with it, right? I mean, we do that in security all the time. The problem is SSO is way too high level a term. It's not even a protocol. You have to sort of jump beneath it. Is it SAML? Is it OIDC? Which is grafted on top of OAuth, an authorization protocol, to do authentication, right? Warning, warning. We're using authorization for authentication. It might work, but why would you do that, right? That would be the warning if we were reviewing software and talking to developers. So really, these protocols are all different. They're implemented differently. They have their own abuse areas. And OAuth introduces more remote access because it has well-formed REST APIs. Like SAML rides on top of HTTP. It's a little bit harder to inject yourself in there and intercept traffic. However, OAuth, if you've ever worked with that, it's got well-documented APIs of how you make a REST API call to participate. So there's a lot of differences and openings for abuse, which really gets us into protocol abuse. So let's take a look at SAML and a phishing variant. Jordan Potti, let me shout out the references. This is 2019. And it's still there in Okta. It's not particular Okta. They allow you to provide a custom identity provider that you have your own code to do the authentication part. But they will handle the traffic and they'll redirect traffic. So what do you see as a user? As an Okta user, someone could configure it. You receive an email, which looks like a normal email. Okta domain, no games there. Something about sign up, do this with your SSO credentials. And what happens is once you click on that, you will get redirected or immediately reference what is a subdomain of Okta.com. Now Jordan Potti, the researcher, just put his own name. If we were an attacker, we would try to make it realistic. That redirects to the attacker's site. Now, let's pause. I'm not saying this is the end of the world. The user could notice this, but the attacker could also be crafty and rewrite URLs. Underneath, we would see these different domains. So there is a chance to catch this. I'm not saying this is the end of the world. But we're abusing trust because someone or some secure web gateway or filter may not actually detect subdomains of Okta.com. They may just trust Okta.com. And really, architecturally, this is what's happening. The user, or the victim, gets this email that we just saw. They click on it, and it gets redirected to the attacker's site, which can play man-in-the-middle. Take MFA codes, submit them, do whatever it needs, and go back and forth. And it's a new feature, relatively. It's not really part of SAML. And we may not even be aware of it. But attacker could use this to obfuscate what they're doing. And when we look at SAML, we don't have to understand this. We just have to know that there's nine-ish pieces to the protocol. So it's still pretty complicated. Three parties. And normally in a phish, we would impersonate one of the identity provider or service provider. This particular one doesn't really take the place of the identity provider. It uses a well-known feature that they sell to hook into the existing identity provider, Okta. Okta provides this. How nice. So people trust Okta, and they may actually land on code controlled by the attacker. And it gets worse because there are built-in features. We know phishing as a service platforms, if you want to do phishing, self-phishing, or just for attack purposes. Well, built into Okta are features that allow you to craft emails, email templates, register domains, enter people. Of course, these would normally be SSO users, but an attacker could use it for targets and send them on its way. So new features sort of allow abuse of that. Now, that's just showing how SAML has sort of changed because vendors extend it. They want to provide more value, stay in the picture. Well, let's look at a different example. So now we move to AWS. Anyone from AWS? Okay, that's good. So AWS can do SSO. And if you're first doing cloud on AWS, you're used to hard-coded API keys, right? But let's look at AWS, or what they call Identity Center. And there has been some work on different kinds of attacks, just so you see that. From 21 and 20, Berger and Tufani to Reaper. So I want to go over that. So what, as a user, do you see when SSO is configured? Very similar to SAML dashboards, okay? You log in, right, as an SSO user. You might go through MFA. You hop into a dashboard. It's my simple one. You only have three apps. So some of these are obvious. Salesforce, right? You're in the browser. User clicks, logs in once, clicks away. Atlassian, so on. Now, here's where you have to do some thinking. AWS itself is an app. Now, if you've done this yourself, you know, you can just save it. But everyone else, think about this. What does that mean? Well, is it all of AWS or different services? Well, it turns out it's all of AWS. That's just one big app. Of course, there's IAM policies to control it. I'm not saying it's the end of the world, but that's what's called an app, AWS's app. All right. Here's a question and quiz. I'm not going to have you shout it out. But think mentally. There's also SSO. This is AWS, by the way. Said, hey, let's extend SSO to the CLI. So your mental exercise right now for about five seconds is, what the fuck does that mean? Seriously. Let's step back from this. You guys probably are way too technical. SSO has for like 20 years meant I go through a browser. I log in once and there's a bunch of websites or web apps, right? I've got this CLI. Maybe it's on the same computer. It doesn't run all the time. You run it once and it ends. So I'm going to log in to the browser with maybe AWS credentials. What's it mean? Think about it. Next time I start up the CLI, it's logged in. I mean, I guess you could technically do that. But how does that know I'm doing that? What if Joe comes by and starts my CLI? What if my CLI is in the cloud? How the hell does it know I've logged in through a browser? So anyway, your exercise when you go home is, think about you came up with this great idea. You're pitching management. We should put our CLI under SSO. Great, what does that mean? Just tell me if you come up with a story. All right, let's see what it means. Here's AWS. You click on that. I'm in the browser. I see information. Anyone see anything wrong with this? That's your second little quiz. This is interactive. Don't fall asleep on me. All right, we'll just jump to it. Mine are what? Look at the different versions up there. We're looking at macOS and Linux combined. We're environment variables. These are AWS credentials. There's Windows. There's PowerShell. I always love it when we mix operating systems and programming language like it's Windows, like BAT, DOSBAT. Sloppy thinking in one area, just warning signs. But more importantly, this will strike any AWS people as problematic. They're blurred out. But these contain not just ID, but the secrets. So for our AWS fans, nowhere in AWS Cloud, forget the SSO, can you look at a secret post-generation. You get to it, generate a key, download it, copy it. Because once you hide it, it's gone. And that's not strange. If I get access to your Windows system, I don't get your password. I might get a hash. Get your password. We compartmentalize secrets. So why, if you do SSO, do you get the secret? Someone at AWS thought it was a good idea, when they implemented SSO, to break their own siloed basic fundamental technique of isolating secrets. It means if I compromise the browser, I get an API key, which is far more valuable, because I can scale automatically everything I do. I'm much more effective with a key than a browser login. These are different. I am your console log. Okay. It gets worse. Where are we? We have time for a demo. I am going to. All right. I'm going to go through a demo of... It's a little bit of how AWS recommends you do the CLI SSO thing. It also shows how you would abuse that as an attacker. And imagine you have an organization... Well, Sam Brinkman Freed is in the news, so this is actually very timely. Might have a bucket with some Bitcoin and some billions of dollars that you stole from someone. Okay. $250 million bond, by the way. I have never heard of that. Wow. Okay. Enough politics. Let's move on. So, that's... Imagine SSO is pre-configured. You have a dashboard. But really, we're interested in what is... What's going to happen... This is really small, isn't it? I'm going to talk about a few things that a CLI would do or an attacker script that's trying to abuse SSO would do in the AWS world. First thing it does is... So, first you have to know that AWS calls this OIDC. So, they would have you believe they are doing SSO on top of OAuth using the official OIDC, which does work. Google does that. And first thing they do is get an application ID dynamically, which is part of OAuth, OIDC. It's hardly ever used. And it's very dangerous because the app ID is part of identity. And if you're thinking forensics and incident handling, sort of figuring out what app is doing what activity, what access. When you do it dynamically, it's on the fly. You don't have to supply any secrets. You can generate this. It means an attacker can start to play by just getting an app ID that's randomly generated effectively. So, then what happens? Okay. You suddenly get an ID, secret. And now you start to do a device code, which is a different part of OAuth, not OIDC. Warning, warning. So, we're not actually doing OIDC. We're doing a different part of OAuth. And device code is known to be open to abuse. It's a lot easier to phish people. We'll have a better example when we come to another vendor, Microsoft, about the pitfalls of device code. All we have to know is that someone stretched the truth. And underneath, we're not doing OIDC on OAuth. We're doing device code flow. All right. Let's continue. So, what a real CLI would do, it's also what an attacker would do. I'm going to sign out of this. We're going to continue. And let's move this along here because it suddenly went backwards. Now, the attacker is in charge. Whoever writes the CLI is in charge. What happens after the device code? I know you can't see this, but you can see it in the slides or afterwards. What happens afterwards is that we continue with device code flow. You get some codes. And what the CLI or script is going to do is launch the user to go log in to SSO. All right. Presumably, it will feed them a code that they generated. And the user, this is real AWS. There's nothing funny there. They'll go through MFA if that's part of it. And what they'll see is just a simple dialogue, hey, approve this. It's done, which is part of device code flow. There's not a lot of information to the user. What's just happened is they've approved a token for the CLI or the attacker script. And they now get OAuth tokens, which essentially is their credential to go do what they want to do. But it gets more confusing after that. The CLI, and I want to point this out, is speaking OAuth at this stage, gets access tokens. But really, AWS doesn't really understand that. And what it does is it trades them in for API keys. And then it can do stuff like access AWS within the environment. So, who cares? Here's the problem. One, there are a lot of steps. But if you notice, we started with saying we did one protocol, which was OIDC, which wasn't true. We were doing more base OAuth. But that's useless within AWS. And we got to API keys. So the problem is, what's happening underneath switches context. We start thinking we're doing browser and SAML when you're in the browser. But once that CLI is brought under the umbrella, we have to switch to a CLI. And then we start speaking OAuth. And then, that OAuth dance is this complicated. And we end up with API keys. Because that's really what you need for CLI to do anything with AWS. So we switch context from browser SAML to CLI OAuth to CLI keys. And that confusion complexity is ripe for abuse. There's way too many interchanges. You're translating tokens to different formats. It's a bad idea. Because basically, the attacker can be the script instead of the CLI. And can start phishing easier with these short codes. Convince users to log in and approve tokens. So let's move to task number three. I've got ten minutes. So we're going to have to really get going here. So even with all of this, we might think, look, we have different pieces. Just contain them. Focus on each one. Piecemeal security. It'll add up to total security. The problem is, the complexity of the protocols allows chaining that is extremely hard to figure out. And what do I mean by that? Well, the best example that I found was maybe a year ago. A Facebook account takeover attack. It was using Google SSO. Facebook configured as Google SSO. This is the work of Samuda. I think he makes six figures doing bug bounties on Facebook. He's really good at it. We start with this weird state. Facebook.com. You're a user there. You can set up SSO with your Google account. Nothing weird there. It speaks OAuth, OIDC. They have a sandbox so that you can prototype HTML stuff. Who knows? It's like Facebook groups or something. Maybe the home page. Because it's a sandbox, you as a user can upload anything there. So you could, of course, inject code. But it's for your own purpose. So nothing weird there. Salesforce does it. It's not uncommon to have a sandbox. Different domain. The kicker is, what's the problem here? Facebook connected in a trust relationship their main domain with this sandbox. We obviously know the sandbox. You can, as a user, create an account and upload code. We know there's a relationship here where tokens are passed back and forth between an SSO and the system. What ties it all together is that when you reset your password, the CAPTCHA is hosted on the sandbox domain. We don't know why they did it. Further, there's data leakage. When you're resetting the password and you try to go to Facebook, that URL doesn't work. It says, hey, no, you're in a reset stage. But it passes it as a referrer and the referrer as a parameter. So you can see that tying these together is non-obvious. Because if you're a tester, you might be testing these individually and say, oh, there's no risk. Once you chain it together, you can follow the path. Maybe there's an authentication token that can be passed to this sandbox domain, which someone has put in some injectable code for cross-site scripting. And that's exactly what submitted2did. He created some code, enticed a user to hit that code, which puts them in this reset stage on the main domain, as well as forces a reset of the password. The token gets passed back, data leakage to the sandbox. He had to do some work on crossing domains, but ultimately he controlled the page, gets the OAuth code, and can do a full password reset. Now look at this. We could spend an hour and it would still be this complicated. I've looked at this for a year. I've talked to Samuda. It's not well explained publicly because he probably wants to make more money. Don't blame him. Look at this. This is non-obvious. And it shows how a chained attack is really hard in this mixed protocol stage. All right. Let's talk about the final sort of example. I think we're on ask number four. We could just say, look, this is just authentication stuff. Let's use our best practices like MFA, etc. Well, MFA usually doesn't work with token systems because tokens are after you've gone through MFA and they're good. You'll never go through a challenge. And you still have the problem that everything's at risk once those tokens are stolen. And probably the best example of that is what's well known is Microsoft's SSO. A lot of the reason they used device code OAuth was to implement SSO. And so I'm going to cruise through this. I've actually shown this before. But when you do Microsoft SSO, let's say you're a user, what you can do... Okay, I'm going to jump to the architecture diagram. Here's the problem. You can do this complicated OAuth piece. I can phish you as a Microsoft user pretending to be Microsoft Office 365. You'll approve it, right? I've got a good phish. But because this was done for SSO purposes, they used OAuth for SSO in the browser. They also implemented the OAuth, I would say, in a customized fashion. I not only get access to your Office 365 assets, I can trade that token to get access to anything under the SSO umbrella, including Azure, as an example. So at the time, this is outdated, there were some 20-some apps. It's up there. Secureworks does great work. Dr. Azure AD, he's here, did great work on sort of publicly showing this. It's not just a phish. Langvik, at a prior DEF CON, had a tool that brute-forced passwords, and then had access to all of the data here and data X-filled it. Because you had an OAuth token, you could do it with API calls. Here's the problem. NetNet, to do SSO, Microsoft implemented a custom version of OAuth that exposed it to more phishing attacks, brute-force attacks, and APIs to get that X-fill. If you just look at it from an SSO perspective, it's like, of course, if a user gets their credential compromised, of course you get access to all those apps. But when you look at it from, no, you used OAuth, and you have other risk areas to being attacked, it's a bad, bad idea. I can convince a user that I'm doing things just for Office 365 and get access to everything. And so, in wrapping up, this won't stop. We're going to continue to have problems here, mainly because of the protocol complexity. SAML, OAuth, and then implementation differs. We have diagrams that are complicated like this, and they're just hard to implement cleanly. OAuth is worse than SAML. It has different kinds of flows, like device code flow. And all that leads to obfuscation, really hard to defend, really easy to find new attacks. And all this mixing of models is a warning point, or at least the opportunity to attack in sort of crafty new ways. So, I'm going to finish up. If you need to reach me, email the service. We don't know what the hell to call it anymore. And Mastodon. Please do reach out if you have further questions. Thanks for coming. Alright, if anyone has questions, Jake will be available out in the hall. Thanks so much.