WEBVTT

00:00.000 --> 00:05.760
So, our next speaker is a veteran to the cloud village.

00:05.760 --> 00:07.060
This is Jenco Huang.

00:07.060 --> 00:10.440
Jenco is a principal researcher... Yeah, yeah, no, give it up.

00:16.160 --> 00:23.360
So Jenco is a principal researcher on Netscope's Threat Research Team, where he focuses on cloud threats and vectors.

00:23.360 --> 00:31.860
He spent time in engineering and product roles at various security startups, focusing on vulnerability scanning, pen testing, threat intel, and Windows security.

00:31.940 --> 00:42.580
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.

00:42.580 --> 00:45.040
So, please give another warm welcome to Jenco.

00:46.980 --> 00:48.520
Thanks, Mike.

00:49.280 --> 00:52.100
I will take your applause, even if it's out of pity.

00:52.100 --> 00:53.080
Thank you.

00:53.080 --> 00:57.680
Thanks for coming, if you just woke up, or if you're still up from last night.

00:57.680 --> 00:58.960
Hope you're having a great time.

00:59.420 --> 01:04.660
Alright, we are going to start here, and I'm going to give you a few things to level set.

01:04.660 --> 01:08.940
So, we've got a couple themes when we talk about SSO, just to frame it.

01:09.000 --> 01:11.980
We're going to talk about different chains, attack chains, trust chains.

01:11.980 --> 01:18.180
We're going to focus a lot on protocols at the design and implementation level, which is where I think it goes wrong.

01:18.760 --> 01:21.980
Concepts and principles, and I personally have a few goals here.

01:21.980 --> 01:23.800
So, just so you know where I'm coming from.

01:24.320 --> 01:26.440
I actually have about 80 minutes of content.

01:26.440 --> 01:28.600
We've got to shrink it into about 39 minutes.

01:28.600 --> 01:33.220
So, I'm going to amp it up to 2x speed, but this is a shared responsibility model.

01:33.220 --> 01:35.320
So, you're going to have to listen at 2x speed, right?

01:35.980 --> 01:39.360
And I like this graphic because it just had ecstasy in it.

01:39.360 --> 01:45.260
So, I have a stretch goal of making this, you know, go through ecstatic feelings for you.

01:45.540 --> 01:47.900
I can stay untangled here.

01:48.880 --> 01:51.420
If you don't get informed, we'll just try to entertain you.

01:51.420 --> 01:53.120
Got a few vendor jokes.

01:53.120 --> 01:55.160
Hopefully, you'll laugh at those.

01:55.580 --> 02:02.460
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.

02:02.460 --> 02:03.700
So, let's see how we do.

02:04.660 --> 02:06.680
Alright, so let's get into SSO.

02:06.680 --> 02:12.380
Let's do it in one minute, sort of review what it is and why should we even be talking about it.

02:12.380 --> 02:16.440
Well, you probably think, look, it's been around for 10, 20 years.

02:16.440 --> 02:18.380
Let's look at SAML, right?

02:18.380 --> 02:19.680
SAML 2.0.

02:19.680 --> 02:22.620
Do I have a clicker here?

02:22.620 --> 02:24.460
Or am I going to be running back and forth?

02:26.760 --> 02:28.200
Thank you.

02:31.820 --> 02:34.600
Well, that was a faux pas audio.

02:37.180 --> 02:38.260
Which button?

02:40.920 --> 02:42.540
Okay, I'm good.

02:42.720 --> 02:44.000
So, SAML.

02:44.800 --> 02:46.780
We have an identity provider.

02:46.780 --> 02:49.060
It can be separate, pure play, like Okta.

02:49.060 --> 02:51.720
It could be built into your apps and resources.

02:51.720 --> 02:54.200
Okay, nothing to be surprised there.

02:54.200 --> 02:57.060
But the flow can be initiated on two sides.

02:57.060 --> 02:58.880
You can start at the identity provider.

02:58.880 --> 02:59.780
Go to Okta.

02:59.780 --> 03:00.600
Log in.

03:00.600 --> 03:01.540
Get the dashboard, right?

03:01.540 --> 03:02.460
No surprise here.

03:02.460 --> 03:05.160
Bunch of enterprise apps.

03:05.440 --> 03:06.680
Click on one.

03:07.220 --> 03:08.380
Maybe it's Jira.

03:08.460 --> 03:09.500
Hop right in.

03:09.500 --> 03:13.860
So, although we're architecturally separating them, of course the user sees us in one browser, right?

03:13.860 --> 03:15.300
So, they see a few pop-ups.

03:15.300 --> 03:15.960
They're happy.

03:15.960 --> 03:17.160
Log in once.

03:17.160 --> 03:18.780
Maybe they go to a second app.

03:18.780 --> 03:20.080
Don't have to log in.

03:20.080 --> 03:22.140
Pop into Salesforce, right?

03:22.140 --> 03:25.740
There's redirects happening underneath of some kind off in HTTP.

03:25.740 --> 03:26.840
Okay, great.

03:27.240 --> 03:28.540
So far, so good.

03:29.320 --> 03:32.680
It can also start at the service provider where your apps and data are.

03:32.680 --> 03:33.760
Okay , great.

03:33.760 --> 03:35.220
So, someone goes to Jira.

03:35.480 --> 03:37.100
And then usually there's a choice.

03:37.100 --> 03:39.200
Do you want to do SSO or sort of direct log in?

03:39.200 --> 03:40.320
And they pick it, right?

03:40.320 --> 03:42.640
We have these buttons down here that we see.

03:42.840 --> 03:45.840
And it gets redirected and they see a log in.

03:46.180 --> 03:47.360
And then they come back in.

03:47.360 --> 03:51.360
So, the user sort of sees the same experience, but they went to a different point.

03:51.660 --> 03:53.280
Okay, no surprise there.

03:53.280 --> 03:54.980
We come to conventional wisdom.

03:55.820 --> 03:58.720
And I am talking fast because I've got 80 minutes to fit into 40.

03:58.740 --> 04:00.720
I've got too many drugs, too little sleep.

04:00.720 --> 04:01.960
So, stay with me, all right?

04:02.360 --> 04:03.500
Don't fall behind.

04:03.500 --> 04:05.160
You're going to miss something like a joke.

04:05.480 --> 04:05.820
All right.

04:05.920 --> 04:06.800
SSO is a good thing.

04:06.800 --> 04:07.900
It's a best practice.

04:08.040 --> 04:11.420
I don't think you'll find anyone saying it's a bad thing if you Google.

04:11.640 --> 04:13.100
Centrally managed, of course.

04:13.100 --> 04:16.240
That allows you to do better authentication policies if it's in one place.

04:16.240 --> 04:17.340
It's more consistent.

04:17.340 --> 04:18.500
No argument there.

04:18.500 --> 04:22.920
Of course, then you can do a better job at enforcing stronger authentication policies.

04:22.920 --> 04:23.480
Whatever it is.

04:23.480 --> 04:26.660
MFA, password shrink, rotating credentials.

04:26.660 --> 04:27.340
Great.

04:27.920 --> 04:33.860
And, of course, the attack surface is smaller because you don't have your users juggling, keeping track of a million passwords.

04:34.500 --> 04:34.960
Right?

04:34.960 --> 04:37.140
And that's great because they're the weak link.

04:37.760 --> 04:42.180
And it's probably one of the areas where security aligns with the user.

04:42.180 --> 04:49.680
This is better security if you believe the first few bullet points and your users are happy because it's more convenient.

04:52.260 --> 04:54.320
But... so I went out of security.

04:54.320 --> 04:56.720
Went to Disney for a quote.

04:56.720 --> 04:59.580
Just thinking the status quo is a good idea.

04:59.580 --> 05:01.400
Especially if it's 10 or 15 years old.

05:01.400 --> 05:02.620
Could be risky.

05:03.080 --> 05:06.560
And it's hard to find a good meme, but let's say Cinderella.

05:06.620 --> 05:09.560
Her status quo is mopping floors for her stepmom.

05:09.560 --> 05:11.360
Or maybe she's at the ball.

05:11.360 --> 05:14.860
And I just like that disdain age.

05:15.240 --> 05:17.680
Strong women quote.

05:18.260 --> 05:25.840
The point is we can't assume that what we're doing is safe because things change.

05:27.040 --> 05:30.420
So let's start talking about the tax, which is really the meat of it.

05:30.420 --> 05:37.100
I'm going to start with assumptions because that certainly makes an ass out of you and I or whoever's assuming.

05:37.460 --> 05:40.100
So one assumption is centrally managed is better.

05:40.100 --> 05:41.820
Or more secure.

05:42.020 --> 05:47.640
But there's a risk there because it's like the big red button that allows you to easily do things.

05:48.060 --> 05:50.780
You can really F it up, right?

05:50.960 --> 05:59.200
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.

05:59.200 --> 06:00.420
Makes sense, right?

06:00.420 --> 06:02.000
I'm just going to point out one thing.

06:02.000 --> 06:05.340
It's also contrary to security principles.

06:05.340 --> 06:17.500
Ask yourself what companies out there of any size have their production environment under the same SSO umbrella as development or everyday user.

06:17.500 --> 06:18.520
None.

06:18.520 --> 06:20.780
Other than the startups that play loose and fast.

06:20.780 --> 06:23.720
But any company that wants to stay in business doesn't do that.

06:23.720 --> 06:28.460
So already you have islands of SSO or authentication domains.

06:28.460 --> 06:34.520
That should be a warning flag to all of us that the conventional wisdom requires sort of review.

06:35.000 --> 06:38.440
So what really is the opening for abuse?

06:38.440 --> 06:45.520
So let's start with a classic one, Golden SAML, which is really a supply chain abuse of trust.

06:45.520 --> 06:54.700
But when it's combined with an SSO impact, it's once you have an upstream attack, you now have this huge blast radius.

06:55.340 --> 07:00.960
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.

07:00.960 --> 07:02.700
You have all this interchange, right?

07:02.700 --> 07:05.680
Identity provider, user, service provider.

07:07.040 --> 07:17.000
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?

07:17.000 --> 07:18.840
Shown here in the client.

07:19.000 --> 07:22.560
And although they're using AWS, it could be any resource manager.

07:22.560 --> 07:31.660
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.

07:31.660 --> 07:33.680
There's no other setup here.

07:33.680 --> 07:34.680
There's no state.

07:34.680 --> 07:37.580
This is really step three right here.

07:37.660 --> 07:47.800
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?

07:47.800 --> 07:49.520
Great, you're in.

07:50.160 --> 07:58.280
And that's sort of an example of how the protocol, although it's not a flaw, opens itself up to abuse.

07:58.860 --> 08:05.500
Although this is CyberArk's good work in 2017, this is part of SolarWinds, which is more recent, right?

08:05.500 --> 08:07.320
So you think about that.

08:07.400 --> 08:18.320
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.

08:18.320 --> 08:30.200
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.

08:31.680 --> 08:34.260
So let's move to a second assumption.

08:34.300 --> 08:36.700
We're moving laterally and we'll jump deep.

08:36.800 --> 08:40.620
So I'm sort of stretching your minds horizontally and vertically, right?

08:40.620 --> 08:43.040
Think of it as sort of mental bondage, right?

08:43.040 --> 08:44.420
I'm going to really stretch you guys.

08:44.420 --> 08:46.500
I'm the dominant one, by the way.

08:47.860 --> 08:51.640
I am trying to introduce terms that you wouldn't normally hear.

08:51.880 --> 08:53.080
Keep you entertained.

08:53.160 --> 08:54.000
Ecstasy.

08:54.040 --> 08:54.960
Bondage.

08:55.200 --> 08:55.860
Keep track.

08:55.860 --> 08:57.360
We'll have a little bingo game.

09:02.200 --> 09:02.840
Nice.

09:02.840 --> 09:04.780
I'm going to use that in the next presentation.

09:05.620 --> 09:06.320
Alright.

09:08.300 --> 09:09.220
Okay.

09:09.760 --> 09:11.540
You're cutting into my minutes.

09:12.020 --> 09:13.480
I like you, but...

09:13.480 --> 09:14.420
First I'm going to take this off.

09:14.420 --> 09:15.640
It's probably blinding you.

09:15.640 --> 09:16.560
I apologize.

09:17.340 --> 09:18.680
I did cover my head.

09:18.680 --> 09:19.940
That won't blind you.

09:19.940 --> 09:20.240
Alright.

09:20.240 --> 09:21.420
Let's get back to it.

09:21.420 --> 09:27.800
Assumption number two, ASS number two for short, is we at least understand SSO.

09:27.800 --> 09:30.820
So even if there's risk, we can deal with it, right?

09:31.240 --> 09:33.580
I mean, we do that in security all the time.

09:34.360 --> 09:38.240
The problem is SSO is way too high level a term.

09:38.240 --> 09:39.480
It's not even a protocol.

09:39.480 --> 09:41.220
You have to sort of jump beneath it.

09:41.220 --> 09:42.120
Is it SAML?

09:42.560 --> 09:44.320
Is it OIDC?

09:44.320 --> 09:52.680
Which is grafted on top of OAuth, an authorization protocol, to do authentication, right?

09:52.680 --> 09:54.680
Warning, warning.

09:54.740 --> 09:58.240
We're using authorization for authentication.

09:58.260 --> 10:02.980
It might work, but why would you do that, right?

10:02.980 --> 10:08.560
That would be the warning if we were reviewing software and talking to developers.

10:09.020 --> 10:12.560
So really, these protocols are all different.

10:12.560 --> 10:14.180
They're implemented differently.

10:14.180 --> 10:16.360
They have their own abuse areas.

10:16.360 --> 10:23.320
And OAuth introduces more remote access because it has well-formed REST APIs.

10:23.320 --> 10:26.040
Like SAML rides on top of HTTP.

10:26.040 --> 10:30.740
It's a little bit harder to inject yourself in there and intercept traffic.

10:31.200 --> 10:39.680
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.

10:39.680 --> 10:49.160
So there's a lot of differences and openings for abuse, which really gets us into protocol abuse.

10:49.160 --> 10:54.440
So let's take a look at SAML and a phishing variant.

10:58.560 --> 11:02.020
Jordan Potti, let me shout out the references.

11:02.200 --> 11:04.140
This is 2019.

11:05.160 --> 11:07.060
And it's still there in Okta.

11:07.060 --> 11:08.640
It's not particular Okta.

11:08.640 --> 11:17.240
They allow you to provide a custom identity provider that you have your own code to do the authentication part.

11:17.240 --> 11:20.700
But they will handle the traffic and they'll redirect traffic.

11:20.700 --> 11:22.440
So what do you see as a user?

11:22.540 --> 11:25.220
As an Okta user, someone could configure it.

11:25.220 --> 11:28.480
You receive an email, which looks like a normal email.

11:29.160 --> 11:31.720
Okta domain, no games there.

11:32.060 --> 11:37.780
Something about sign up, do this with your SSO credentials.

11:38.500 --> 11:50.240
And what happens is once you click on that, you will get redirected or immediately reference what is a subdomain of Okta.com.

11:50.240 --> 11:53.180
Now Jordan Potti, the researcher, just put his own name.

11:53.180 --> 11:55.920
If we were an attacker, we would try to make it realistic.

11:56.280 --> 12:01.120
That redirects to the attacker's site.

12:01.580 --> 12:03.260
Now, let's pause.

12:03.260 --> 12:04.840
I'm not saying this is the end of the world.

12:04.840 --> 12:09.060
The user could notice this, but the attacker could also be crafty and rewrite URLs.

12:09.440 --> 12:11.940
Underneath, we would see these different domains.

12:11.940 --> 12:13.880
So there is a chance to catch this.

12:13.880 --> 12:15.800
I'm not saying this is the end of the world.

12:16.440 --> 12:27.180
But we're abusing trust because someone or some secure web gateway or filter may not actually detect subdomains of Okta.com.

12:27.180 --> 12:30.140
They may just trust Okta.com.

12:30.520 --> 12:33.140
And really, architecturally, this is what's happening.

12:33.140 --> 12:36.380
The user, or the victim, gets this email that we just saw.

12:36.380 --> 12:41.700
They click on it, and it gets redirected to the attacker's site, which can play man-in-the-middle.

12:41.700 --> 12:46.600
Take MFA codes, submit them, do whatever it needs, and go back and forth.

12:46.780 --> 12:49.340
And it's a new feature, relatively.

12:49.560 --> 12:51.560
It's not really part of SAML.

12:52.020 --> 12:53.980
And we may not even be aware of it.

12:54.280 --> 12:58.440
But attacker could use this to obfuscate what they're doing.

12:58.440 --> 13:00.600
And when we look at SAML, we don't have to understand this.

13:00.600 --> 13:04.600
We just have to know that there's nine-ish pieces to the protocol.

13:04.600 --> 13:05.680
So it's still pretty complicated.

13:05.680 --> 13:06.820
Three parties.

13:08.000 --> 13:13.400
And normally in a phish, we would impersonate one of the identity provider or service provider.

13:13.420 --> 13:19.000
This particular one doesn't really take the place of the identity provider.

13:19.000 --> 13:26.020
It uses a well-known feature that they sell to hook into the existing identity provider, Okta.

13:26.020 --> 13:27.500
Okta provides this.

13:27.500 --> 13:28.640
How nice.

13:28.640 --> 13:35.720
So people trust Okta, and they may actually land on code controlled by the attacker.

13:35.740 --> 13:40.060
And it gets worse because there are built-in features.

13:40.060 --> 13:46.980
We know phishing as a service platforms, if you want to do phishing, self-phishing, or just for attack purposes.

13:46.980 --> 13:58.260
Well, built into Okta are features that allow you to craft emails, email templates, register domains, enter people.

13:58.260 --> 14:06.300
Of course, these would normally be SSO users, but an attacker could use it for targets and send them on its way.

14:06.720 --> 14:09.640
So new features sort of allow abuse of that.

14:09.640 --> 14:15.780
Now, that's just showing how SAML has sort of changed because vendors extend it.

14:16.040 --> 14:18.700
They want to provide more value, stay in the picture.

14:18.700 --> 14:20.760
Well, let's look at a different example.

14:20.980 --> 14:25.820
So now we move to AWS.

14:25.820 --> 14:28.180
Anyone from AWS?

14:29.140 --> 14:31.020
Okay, that's good.

14:35.240 --> 14:38.920
So AWS can do SSO.

14:39.900 --> 14:45.180
And if you're first doing cloud on AWS, you're used to hard-coded API keys, right?

14:45.180 --> 14:50.300
But let's look at AWS, or what they call Identity Center.

14:51.220 --> 14:57.660
And there has been some work on different kinds of attacks, just so you see that.

14:57.660 --> 15:01.680
From 21 and 20, Berger and Tufani to Reaper.

15:01.820 --> 15:03.260
So I want to go over that.

15:03.260 --> 15:06.500
So what, as a user, do you see when SSO is configured?

15:06.500 --> 15:09.900
Very similar to SAML dashboards, okay?

15:09.900 --> 15:13.340
You log in, right, as an SSO user.

15:13.340 --> 15:15.040
You might go through MFA.

15:15.040 --> 15:17.100
You hop into a dashboard.

15:17.220 --> 15:18.080
It's my simple one.

15:18.080 --> 15:19.760
You only have three apps.

15:20.000 --> 15:22.020
So some of these are obvious.

15:22.020 --> 15:23.760
Salesforce, right?

15:23.760 --> 15:24.760
You're in the browser.

15:24.760 --> 15:27.620
User clicks, logs in once, clicks away.

15:28.580 --> 15:30.240
Atlassian, so on.

15:30.820 --> 15:34.180
Now, here's where you have to do some thinking.

15:34.540 --> 15:37.860
AWS itself is an app.

15:38.520 --> 15:43.720
Now, if you've done this yourself, you know, you can just save it.

15:43.720 --> 15:45.000
But everyone else, think about this.

15:45.000 --> 15:46.420
What does that mean?

15:48.000 --> 15:51.520
Well, is it all of AWS or different services?

15:51.520 --> 15:53.580
Well, it turns out it's all of AWS.

15:54.000 --> 15:55.600
That's just one big app.

15:57.000 --> 15:59.580
Of course, there's IAM policies to control it.

15:59.580 --> 16:05.340
I'm not saying it's the end of the world, but that's what's called an app, AWS's app.

16:06.240 --> 16:07.080
All right.

16:08.220 --> 16:09.620
Here's a question and quiz.

16:09.620 --> 16:11.540
I'm not going to have you shout it out.

16:11.540 --> 16:13.180
But think mentally.

16:15.660 --> 16:18.080
There's also SSO.

16:18.080 --> 16:19.960
This is AWS, by the way.

16:20.280 --> 16:24.140
Said, hey, let's extend SSO to the CLI.

16:24.900 --> 16:30.360
So your mental exercise right now for about five seconds is, what the fuck does that mean?

16:31.640 --> 16:32.680
Seriously.

16:33.880 --> 16:35.240
Let's step back from this.

16:35.240 --> 16:36.960
You guys probably are way too technical.

16:37.400 --> 16:41.220
SSO has for like 20 years meant I go through a browser.

16:41.220 --> 16:45.060
I log in once and there's a bunch of websites or web apps, right?

16:45.960 --> 16:48.160
I've got this CLI.

16:48.160 --> 16:49.980
Maybe it's on the same computer.

16:50.380 --> 16:52.120
It doesn't run all the time.

16:52.120 --> 16:54.080
You run it once and it ends.

16:54.100 --> 16:58.280
So I'm going to log in to the browser with maybe AWS credentials.

16:58.440 --> 16:59.560
What's it mean?

16:59.800 --> 17:01.180
Think about it.

17:01.300 --> 17:04.660
Next time I start up the CLI, it's logged in.

17:06.380 --> 17:09.260
I mean, I guess you could technically do that.

17:09.260 --> 17:12.140
But how does that know I'm doing that?

17:12.280 --> 17:14.620
What if Joe comes by and starts my CLI?

17:14.620 --> 17:16.860
What if my CLI is in the cloud?

17:16.880 --> 17:20.320
How the hell does it know I've logged in through a browser?

17:20.500 --> 17:27.480
So anyway, your exercise when you go home is, think about you came up with this great idea.

17:27.620 --> 17:29.060
You're pitching management.

17:29.060 --> 17:32.400
We should put our CLI under SSO.

17:32.400 --> 17:33.880
Great, what does that mean?

17:33.880 --> 17:35.960
Just tell me if you come up with a story.

17:36.760 --> 17:38.300
All right, let's see what it means.

17:38.300 --> 17:39.920
Here's AWS.

17:41.400 --> 17:42.640
You click on that.

17:42.640 --> 17:43.900
I'm in the browser.

17:44.700 --> 17:46.500
I see information.

17:47.040 --> 17:48.560
Anyone see anything wrong with this?

17:48.560 --> 17:49.860
That's your second little quiz.

17:49.860 --> 17:50.960
This is interactive.

17:50.960 --> 17:52.500
Don't fall asleep on me.

17:53.060 --> 17:54.800
All right, we'll just jump to it.

17:54.800 --> 17:55.960
Mine are what?

17:56.980 --> 17:58.860
Look at the different versions up there.

17:58.860 --> 18:01.360
We're looking at macOS and Linux combined.

18:02.260 --> 18:04.160
We're environment variables.

18:04.160 --> 18:06.480
These are AWS credentials.

18:06.480 --> 18:07.180
There's Windows.

18:07.180 --> 18:08.480
There's PowerShell.

18:08.800 --> 18:15.380
I always love it when we mix operating systems and programming language like it's Windows, like BAT, DOSBAT.

18:15.700 --> 18:19.480
Sloppy thinking in one area, just warning signs.

18:19.580 --> 18:26.340
But more importantly, this will strike any AWS people as problematic.

18:26.660 --> 18:28.660
They're blurred out.

18:28.800 --> 18:32.640
But these contain not just ID, but the secrets.

18:32.640 --> 18:45.940
So for our AWS fans, nowhere in AWS Cloud, forget the SSO, can you look at a secret post-generation.

18:46.300 --> 18:50.860
You get to it, generate a key, download it, copy it.

18:50.860 --> 18:53.300
Because once you hide it, it's gone.

18:53.300 --> 18:56.320
And that's not strange.

18:56.320 --> 19:00.640
If I get access to your Windows system, I don't get your password.

19:00.640 --> 19:02.000
I might get a hash.

19:02.000 --> 19:03.460
Get your password.

19:03.460 --> 19:07.080
We compartmentalize secrets.

19:07.320 --> 19:12.420
So why, if you do SSO, do you get the secret?

19:12.420 --> 19:27.320
Someone at AWS thought it was a good idea, when they implemented SSO, to break their own siloed basic fundamental technique of isolating secrets.

19:27.320 --> 19:38.840
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.

19:38.840 --> 19:42.740
I'm much more effective with a key than a browser login.

19:43.020 --> 19:44.420
These are different.

19:44.420 --> 19:46.080
I am your console log.

19:46.380 --> 19:47.480
Okay.

19:47.640 --> 19:49.140
It gets worse.

19:49.300 --> 19:49.980
Where are we?

19:49.980 --> 19:51.420
We have time for a demo.

19:54.280 --> 19:56.460
I am going to.

19:57.160 --> 19:58.160
All right.

19:58.160 --> 19:59.420
I'm going to go through a demo of...

20:00.600 --> 20:07.020
It's a little bit of how AWS recommends you do the CLI SSO thing.

20:07.020 --> 20:10.060
It also shows how you would abuse that as an attacker.

20:11.500 --> 20:13.420
And imagine you have an organization...

20:14.440 --> 20:18.260
Well, Sam Brinkman Freed is in the news, so this is actually very timely.

20:18.260 --> 20:23.840
Might have a bucket with some Bitcoin and some billions of dollars that you stole from someone.

20:23.840 --> 20:24.500
Okay.

20:26.440 --> 20:28.560
$250 million bond, by the way.

20:28.560 --> 20:30.140
I have never heard of that.

20:30.140 --> 20:30.860
Wow.

20:31.220 --> 20:31.960
Okay.

20:31.960 --> 20:33.000
Enough politics.

20:33.000 --> 20:34.180
Let's move on.

20:34.940 --> 20:37.500
So, that's...

20:37.500 --> 20:39.920
Imagine SSO is pre-configured.

20:40.060 --> 20:41.580
You have a dashboard.

20:41.580 --> 20:46.180
But really, we're interested in what is...

20:46.880 --> 20:48.220
What's going to happen...

20:48.220 --> 20:50.080
This is really small, isn't it?

20:50.160 --> 21:00.060
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.

21:00.160 --> 21:03.820
First thing it does is...

21:03.820 --> 21:07.420
So, first you have to know that AWS calls this OIDC.

21:07.420 --> 21:15.320
So, they would have you believe they are doing SSO on top of OAuth using the official OIDC, which does work.

21:15.320 --> 21:16.380
Google does that.

21:16.820 --> 21:24.980
And first thing they do is get an application ID dynamically, which is part of OAuth, OIDC.

21:24.980 --> 21:26.640
It's hardly ever used.

21:27.100 --> 21:31.600
And it's very dangerous because the app ID is part of identity.

21:31.600 --> 21:38.180
And if you're thinking forensics and incident handling, sort of figuring out what app is doing what activity, what access.

21:38.380 --> 21:41.480
When you do it dynamically, it's on the fly.

21:41.480 --> 21:43.340
You don't have to supply any secrets.

21:43.340 --> 21:44.860
You can generate this.

21:44.860 --> 21:52.520
It means an attacker can start to play by just getting an app ID that's randomly generated effectively.

21:52.880 --> 21:54.720
So, then what happens?

21:55.440 --> 21:56.520
Okay.

21:57.220 --> 22:00.240
You suddenly get an ID, secret.

22:00.240 --> 22:05.800
And now you start to do a device code, which is a different part of OAuth, not OIDC.

22:06.200 --> 22:07.860
Warning, warning.

22:08.440 --> 22:10.880
So, we're not actually doing OIDC.

22:10.880 --> 22:12.920
We're doing a different part of OAuth.

22:13.420 --> 22:17.060
And device code is known to be open to abuse.

22:17.060 --> 22:18.920
It's a lot easier to phish people.

22:18.920 --> 22:24.020
We'll have a better example when we come to another vendor, Microsoft, about the pitfalls of device code.

22:24.020 --> 22:28.680
All we have to know is that someone stretched the truth.

22:29.060 --> 22:31.920
And underneath, we're not doing OIDC on OAuth.

22:31.940 --> 22:33.600
We're doing device code flow.

22:34.220 --> 22:34.580
All right.

22:34.580 --> 22:35.580
Let's continue.

22:35.840 --> 22:40.640
So, what a real CLI would do, it's also what an attacker would do.

22:42.260 --> 22:43.560
I'm going to sign out of this.

22:43.560 --> 22:44.740
We're going to continue.

22:45.260 --> 22:49.240
And let's move this along here because it suddenly went backwards.

22:51.240 --> 22:54.960
Now, the attacker is in charge.

22:54.960 --> 22:56.920
Whoever writes the CLI is in charge.

22:57.220 --> 22:59.420
What happens after the device code?

23:00.280 --> 23:03.700
I know you can't see this, but you can see it in the slides or afterwards.

23:04.120 --> 23:10.760
What happens afterwards is that we continue with device code flow.

23:10.760 --> 23:12.100
You get some codes.

23:12.100 --> 23:19.780
And what the CLI or script is going to do is launch the user to go log in to SSO.

23:20.860 --> 23:21.420
All right.

23:21.860 --> 23:25.700
Presumably, it will feed them a code that they generated.

23:25.980 --> 23:28.060
And the user, this is real AWS.

23:28.060 --> 23:29.580
There's nothing funny there.

23:30.140 --> 23:32.840
They'll go through MFA if that's part of it.

23:33.020 --> 23:38.020
And what they'll see is just a simple dialogue, hey, approve this.

23:38.020 --> 23:40.100
It's done, which is part of device code flow.

23:40.100 --> 23:42.820
There's not a lot of information to the user.

23:42.820 --> 23:48.600
What's just happened is they've approved a token for the CLI or the attacker script.

23:48.600 --> 23:53.740
And they now get OAuth tokens, which essentially is their credential to go do what they want to do.

23:53.960 --> 23:58.500
But it gets more confusing after that.

23:58.640 --> 24:06.960
The CLI, and I want to point this out, is speaking OAuth at this stage, gets access tokens.

24:06.960 --> 24:10.740
But really, AWS doesn't really understand that.

24:11.280 --> 24:16.140
And what it does is it trades them in for API keys.

24:16.880 --> 24:22.920
And then it can do stuff like access AWS within the environment.

24:22.920 --> 24:26.160
So, who cares?

24:26.700 --> 24:28.300
Here's the problem.

24:28.860 --> 24:30.700
One, there are a lot of steps.

24:30.700 --> 24:38.820
But if you notice, we started with saying we did one protocol, which was OIDC, which wasn't true.

24:38.820 --> 24:41.200
We were doing more base OAuth.

24:41.460 --> 24:44.020
But that's useless within AWS.

24:44.540 --> 24:46.480
And we got to API keys.

24:46.480 --> 24:51.600
So the problem is, what's happening underneath switches context.

24:53.240 --> 24:57.120
We start thinking we're doing browser and SAML when you're in the browser.

24:57.120 --> 25:01.520
But once that CLI is brought under the umbrella, we have to switch to a CLI.

25:01.520 --> 25:03.480
And then we start speaking OAuth.

25:03.780 --> 25:08.280
And then, that OAuth dance is this complicated.

25:10.480 --> 25:13.040
And we end up with API keys.

25:13.040 --> 25:16.840
Because that's really what you need for CLI to do anything with AWS.

25:17.160 --> 25:22.720
So we switch context from browser SAML to CLI OAuth to CLI keys.

25:22.720 --> 25:26.720
And that confusion complexity is ripe for abuse.

25:26.720 --> 25:27.920
There's way too many interchanges.

25:27.920 --> 25:30.940
You're translating tokens to different formats.

25:30.940 --> 25:32.660
It's a bad idea.

25:32.660 --> 25:37.840
Because basically, the attacker can be the script instead of the CLI.

25:37.840 --> 25:40.780
And can start phishing easier with these short codes.

25:40.780 --> 25:45.000
Convince users to log in and approve tokens.

25:46.860 --> 25:49.600
So let's move to task number three.

25:49.600 --> 25:50.440
I've got ten minutes.

25:50.440 --> 25:53.380
So we're going to have to really get going here.

25:53.380 --> 25:58.100
So even with all of this, we might think, look, we have different pieces.

25:58.220 --> 25:59.500
Just contain them.

25:59.500 --> 26:00.740
Focus on each one.

26:00.740 --> 26:01.780
Piecemeal security.

26:01.780 --> 26:04.760
It'll add up to total security.

26:04.760 --> 26:11.320
The problem is, the complexity of the protocols allows chaining that is extremely hard to figure out.

26:11.540 --> 26:12.680
And what do I mean by that?

26:12.680 --> 26:17.660
Well, the best example that I found was maybe a year ago.

26:17.660 --> 26:20.080
A Facebook account takeover attack.

26:20.240 --> 26:22.120
It was using Google SSO.

26:22.120 --> 26:25.240
Facebook configured as Google SSO.

26:25.720 --> 26:28.720
This is the work of Samuda.

26:28.900 --> 26:33.980
I think he makes six figures doing bug bounties on Facebook.

26:33.980 --> 26:35.440
He's really good at it.

26:36.120 --> 26:38.960
We start with this weird state.

26:38.960 --> 26:40.600
Facebook.com.

26:40.600 --> 26:41.960
You're a user there.

26:41.960 --> 26:45.160
You can set up SSO with your Google account.

26:45.160 --> 26:46.320
Nothing weird there.

26:46.320 --> 26:49.100
It speaks OAuth, OIDC.

26:49.860 --> 26:55.040
They have a sandbox so that you can prototype HTML stuff.

26:55.040 --> 26:55.360
Who knows?

26:55.360 --> 26:56.940
It's like Facebook groups or something.

26:56.940 --> 26:58.280
Maybe the home page.

26:58.760 --> 27:02.600
Because it's a sandbox, you as a user can upload anything there.

27:02.600 --> 27:04.700
So you could, of course, inject code.

27:04.700 --> 27:05.980
But it's for your own purpose.

27:05.980 --> 27:07.280
So nothing weird there.

27:07.280 --> 27:08.500
Salesforce does it.

27:08.500 --> 27:11.000
It's not uncommon to have a sandbox.

27:11.000 --> 27:12.080
Different domain.

27:12.380 --> 27:18.060
The kicker is, what's the problem here?

27:18.060 --> 27:25.300
Facebook connected in a trust relationship their main domain with this sandbox.

27:25.980 --> 27:27.640
We obviously know the sandbox.

27:27.640 --> 27:31.000
You can, as a user, create an account and upload code.

27:31.340 --> 27:36.680
We know there's a relationship here where tokens are passed back and forth between an SSO and the system.

27:36.680 --> 27:47.400
What ties it all together is that when you reset your password, the CAPTCHA is hosted on the sandbox domain.

27:47.400 --> 27:49.260
We don't know why they did it.

27:51.120 --> 27:53.180
Further, there's data leakage.

27:53.980 --> 27:59.440
When you're resetting the password and you try to go to Facebook, that URL doesn't work.

27:59.440 --> 28:01.600
It says, hey, no, you're in a reset stage.

28:01.600 --> 28:07.160
But it passes it as a referrer and the referrer as a parameter.

28:08.640 --> 28:12.920
So you can see that tying these together is non-obvious.

28:12.920 --> 28:17.140
Because if you're a tester, you might be testing these individually and say, oh, there's no risk.

28:17.140 --> 28:20.520
Once you chain it together, you can follow the path.

28:20.520 --> 28:30.320
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.

28:30.320 --> 28:32.320
And that's exactly what submitted2did.

28:32.320 --> 28:46.120
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.

28:46.120 --> 28:49.960
The token gets passed back, data leakage to the sandbox.

28:50.100 --> 28:59.840
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.

28:59.860 --> 29:00.960
Now look at this.

29:00.960 --> 29:04.220
We could spend an hour and it would still be this complicated.

29:04.680 --> 29:06.680
I've looked at this for a year.

29:07.000 --> 29:07.980
I've talked to Samuda.

29:07.980 --> 29:12.200
It's not well explained publicly because he probably wants to make more money.

29:12.840 --> 29:14.140
Don't blame him.

29:14.140 --> 29:16.280
Look at this.

29:16.400 --> 29:18.840
This is non-obvious.

29:18.840 --> 29:25.940
And it shows how a chained attack is really hard in this mixed protocol stage.

29:25.960 --> 29:26.780
All right.

29:27.040 --> 29:30.600
Let's talk about the final sort of example.

29:30.600 --> 29:33.560
I think we're on ask number four.

29:33.860 --> 29:37.040
We could just say, look, this is just authentication stuff.

29:37.040 --> 29:40.260
Let's use our best practices like MFA, etc.

29:40.280 --> 29:47.500
Well, MFA usually doesn't work with token systems because tokens are after you've gone through MFA and they're good.

29:47.500 --> 29:49.180
You'll never go through a challenge.

29:49.920 --> 29:57.220
And you still have the problem that everything's at risk once those tokens are stolen.

29:58.280 --> 30:04.260
And probably the best example of that is what's well known is Microsoft's SSO.

30:05.200 --> 30:10.200
A lot of the reason they used device code OAuth was to implement SSO.

30:10.200 --> 30:14.340
And so I'm going to cruise through this.

30:14.340 --> 30:16.840
I've actually shown this before.

30:17.480 --> 30:29.340
But when you do Microsoft SSO, let's say you're a user, what you can do...

30:29.340 --> 30:33.500
Okay, I'm going to jump to the architecture diagram.

30:33.500 --> 30:35.300
Here's the problem.

30:35.500 --> 30:39.080
You can do this complicated OAuth piece.

30:39.080 --> 30:44.540
I can phish you as a Microsoft user pretending to be Microsoft Office 365.

30:44.620 --> 30:46.000
You'll approve it, right?

30:46.000 --> 30:47.540
I've got a good phish.

30:47.800 --> 30:54.080
But because this was done for SSO purposes, they used OAuth for SSO in the browser.

30:55.040 --> 31:00.660
They also implemented the OAuth, I would say, in a customized fashion.

31:00.660 --> 31:13.460
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.

31:14.960 --> 31:20.560
So at the time, this is outdated, there were some 20-some apps.

31:20.560 --> 31:21.320
It's up there.

31:21.340 --> 31:23.040
Secureworks does great work.

31:23.040 --> 31:23.280
Dr.

31:23.280 --> 31:28.460
Azure AD, he's here, did great work on sort of publicly showing this.

31:28.460 --> 31:30.020
It's not just a phish.

31:30.020 --> 31:40.100
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.

31:40.100 --> 31:43.440
Because you had an OAuth token, you could do it with API calls.

31:43.540 --> 31:44.720
Here's the problem.

31:44.780 --> 31:58.780
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.

31:59.360 --> 32:07.160
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.

32:07.860 --> 32:16.080
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.

32:16.080 --> 32:22.420
I can convince a user that I'm doing things just for Office 365 and get access to everything.

32:23.420 --> 32:29.680
And so, in wrapping up, this won't stop.

32:29.780 --> 32:34.260
We're going to continue to have problems here, mainly because of the protocol complexity.

32:34.600 --> 32:39.440
SAML, OAuth, and then implementation differs.

32:39.940 --> 32:46.060
We have diagrams that are complicated like this, and they're just hard to implement cleanly.

32:46.600 --> 32:49.660
OAuth is worse than SAML.

32:49.660 --> 32:53.580
It has different kinds of flows, like device code flow.

32:54.500 --> 33:00.120
And all that leads to obfuscation, really hard to defend, really easy to find new attacks.

33:00.400 --> 33:08.980
And all this mixing of models is a warning point, or at least the opportunity to attack in sort of crafty new ways.

33:10.100 --> 33:13.100
So, I'm going to finish up.

33:13.100 --> 33:17.500
If you need to reach me, email the service.

33:17.500 --> 33:19.760
We don't know what the hell to call it anymore.

33:20.200 --> 33:21.540
And Mastodon.

33:22.760 --> 33:24.900
Please do reach out if you have further questions.

33:24.900 --> 33:25.960
Thanks for coming.

33:36.150 --> 33:40.030
Alright, if anyone has questions, Jake will be available out in the hall.

33:40.670 --> 33:41.510
Thanks so much.

