WEBVTT

00:00.000 --> 00:04.920
To start our day, we've got a good friend of the Cloud Village speaking, Jenko Hong.

00:04.920 --> 00:11.400
Jenko is a principal researcher on Netscope's threat research team, focusing on cloud threats and identity abuse.

00:11.400 --> 00:20.960
In this talk, Jenko is going to cover research and tooling to improve cloud defenses in AWS, Azure, and GCP, using more stealthy measures which complement existing techniques.

00:20.960 --> 00:25.160
The title of the talk is Cloud Tripwires Fighting Stealth with Stealth.

00:25.160 --> 00:27.840
Everyone please give a warm welcome to Jenko.

00:29.140 --> 00:30.540
Thank you, Mike.

00:30.540 --> 00:34.900
And thank you, everyone, for coming Sunday morning.

00:35.080 --> 00:38.160
You look as tired as I feel.

00:38.360 --> 00:39.680
So thanks.

00:39.680 --> 00:41.480
Hope your con is going well.

00:42.700 --> 00:50.620
So as you might gather from the title, I'm talking about something a little less common, maybe a little less popular.

00:50.660 --> 00:51.780
Defense!

00:51.860 --> 00:53.980
Yeah, I've got my blue hat on.

00:54.060 --> 00:54.840
That's right.

00:54.840 --> 01:04.980
So we spend so much energy, and it's good energy, at DEF CON talking about research on the attack side, the red side.

01:04.980 --> 01:09.160
And ultimately, that helps us in the security community improve things, right?

01:09.160 --> 01:14.640
The vendors are a little bit slower than we'd like, but they ultimately do listen.

01:14.680 --> 01:24.980
So I'd like to sort of switch our brainpower, if you're willing, to the defense side, because I don't think we spend nearly as much time there.

01:25.380 --> 01:26.560
And we really need it.

01:26.560 --> 01:28.540
So I'm going to go through a few things.

01:28.540 --> 01:34.340
And I'm going to start with a demo, which I translated to screenshots just because of time constraints.

01:34.380 --> 01:39.480
And it's about a technique that is several years old.

01:39.480 --> 01:45.100
And if you're into Azure and Microsoft, and you don't know about Dr.

01:45.100 --> 01:46.900
Azure AD and Dr.

01:47.040 --> 01:49.580
Cinema, he's awesome.

01:49.580 --> 01:50.740
You should follow him.

01:50.740 --> 01:53.700
A lot of research has spawned off of that.

01:53.740 --> 01:59.020
His blog is sort of down because he's joined Microsoft from SecureWorks.

01:59.020 --> 02:15.740
But this is sort of an ode to something he published three and a half years ago, which is Microsoft's device code flow implementation being highly susceptible to phishing, as well as carry on lateral movement and privilege escalation.

02:15.740 --> 02:19.940
So I've got screenshots from a demo, and I'll talk you through it.

02:20.220 --> 02:25.480
And I basically want to point out how advanced and moving the research is.

02:25.480 --> 02:28.540
And even if it's three and a half years old, this is highly relevant.

02:28.540 --> 02:30.500
Not enough time is spent on this.

02:30.500 --> 02:35.100
So on the left, imagine you have a regular Microsoft user logging in.

02:35.100 --> 02:37.900
This is one of my throwaway accounts.

02:37.900 --> 02:39.760
And it actually has MFA on it.

02:39.760 --> 02:43.460
It's actually a global admin in Azure.

02:43.520 --> 02:49.960
It is cached, so I don't go through the MFA process, but normally I would.

02:50.000 --> 02:51.060
And I pop into Outlook.

02:51.060 --> 02:52.220
So nothing surprising there.

02:52.220 --> 02:59.140
On the right is the attacker executing device code flow in OAuth.

02:59.580 --> 03:03.920
Now, you may have to look at the slides to actually see it.

03:03.920 --> 03:06.460
I'll talk through the important points.

03:06.460 --> 03:09.340
Device code flow is really easy to execute.

03:09.340 --> 03:19.200
This is payload of invoke rest method in PowerShell, which is as close to raw curl with post get that you can get.

03:19.200 --> 03:24.040
There are two attributes supplied to kick this off as an attacker, right?

03:24.040 --> 03:26.980
A valid application obviously would do the same.

03:27.060 --> 03:32.080
One is the resource, which in Microsoft land is the API being requested, API.

03:32.080 --> 03:40.180
The client ID in OAuth terms is the application client ID when you as a developer of an OAuth app register it in your tenant.

03:40.180 --> 03:41.540
You get a unique ID.

03:41.540 --> 03:42.800
I have two things.

03:42.800 --> 03:52.120
These are sitting in a loop querying Microsoft saying as soon as that user logs in, give me the OAuth tokens as soon as they approve.

03:52.320 --> 03:58.500
So popping on the left is the phishing email.

03:58.640 --> 04:02.660
I want you to just appreciate my HTML capabilities.

04:02.660 --> 04:06.620
So this is an Office 365 phish for extra storage.

04:06.620 --> 04:14.440
Promo code, which is the user code I got as an attacker from Microsoft, from the device code flow.

04:14.440 --> 04:17.160
That's the official Microsoft device code login.

04:17.160 --> 04:18.480
There's nothing funny there.

04:18.480 --> 04:22.380
This is exactly what you would see in any device code phish.

04:22.380 --> 04:25.780
So if the user follows it, they pop in the code I sent.

04:25.780 --> 04:28.020
They go through normal login.

04:28.020 --> 04:32.180
It's cached, but again, normally this would be an MFA login, right?

04:32.180 --> 04:35.600
So one of the things we'll get is bypass of MFA.

04:35.600 --> 04:38.540
We're going to have the user put in their one-time code.

04:38.540 --> 04:39.720
We don't have to intercept it.

04:39.720 --> 04:41.160
We don't have to do whatever.

04:41.220 --> 04:44.020
It's a one technique to bypass MFA.

04:44.560 --> 04:47.040
I want you to focus on this endgame.

04:47.040 --> 04:48.900
This is all the user sees.

04:49.140 --> 04:51.140
Are you trying to sign into Microsoft Office?

04:51.140 --> 04:52.480
Why does that text appear?

04:52.480 --> 04:54.480
Because I use the client ID.

04:54.480 --> 05:00.460
If I'd use my own ID, some app I created, I pick a name when I develop it and register it.

05:00.460 --> 05:02.740
And I can't choose Microsoft Office.

05:02.740 --> 05:05.960
They prevent you from doing common derivatives of their own products.

05:05.960 --> 05:07.980
But I chose their app ID.

05:07.980 --> 05:08.800
So great.

05:08.800 --> 05:12.760
This looks all official to the user, right?

05:12.780 --> 05:16.100
No reason not to trust it once you get to this process.

05:16.100 --> 05:17.260
The domain is Microsoft.

05:17.260 --> 05:19.400
Nothing funny there, right?

05:19.960 --> 05:21.780
What does the attacker see?

05:21.960 --> 05:26.160
So finally, after you set next on the left, you just get a simple confirmation.

05:26.160 --> 05:26.340
Good.

05:26.340 --> 05:27.100
You're done.

05:27.340 --> 05:28.700
What's the attacker see?

05:28.700 --> 05:34.200
Well, they return from that polling call and they get an OAuth token right there on the bottom.

05:34.200 --> 05:35.180
Access token.

05:35.180 --> 05:37.960
They also get scopes, which is part of OAuth.

05:37.960 --> 05:43.380
I want to point out that at no point to this up till now did the attacker have to specify scopes.

05:43.380 --> 05:48.180
In normal OAuth world, you specify scopes as an application.

05:48.180 --> 05:52.420
You are going to ask the user for their permissions for the such and such.

05:52.420 --> 05:55.760
These are directory scopes, graph API scopes.

05:55.760 --> 05:58.640
Microsoft decided to implement default scopes.

05:58.720 --> 05:59.800
That's stupid.

05:59.800 --> 06:02.240
That's not really common or part of OAuth.

06:02.240 --> 06:03.480
But they did it.

06:04.400 --> 06:07.600
I also get a refresh token, which is part of OAuth.

06:07.600 --> 06:13.400
The dirty secret is, everyone says temporary token systems are more secure because they're temporary.

06:13.400 --> 06:17.540
Yet we have a refresh token that for all intents and purposes is permanent.

06:17.540 --> 06:21.480
Yes, you can revoke it on the user side.

06:21.480 --> 06:34.700
But if you don't, if you use it like every four months, it just says fresh and you will have permanent access because, of course, third-party apps like your email client or something needs to continue to get email without having you re-log in.

06:35.300 --> 06:38.460
Back on the user side, they do have an Azure account.

06:38.460 --> 06:39.560
They happen to be global admin.

06:39.560 --> 06:40.780
Here's some resources.

06:41.220 --> 06:47.120
What the attacker is going to do with this graph API token is, of course, do graph calls.

06:47.120 --> 06:50.820
They will get the users out of AD because that's a Microsoft thing.

06:50.820 --> 06:53.520
You can enumerate users very easily.

06:53.860 --> 06:56.580
They will get email as well.

06:56.580 --> 06:58.340
Another graph API piece.

06:58.340 --> 07:01.960
Now, here's the kicker with this technique.

07:02.000 --> 07:04.440
Microsoft implemented a really bad thing.

07:04.440 --> 07:13.400
In OAuth land, you don't get to switch your permissions once you have a token without going back to the user to ask them for new permissions.

07:13.480 --> 07:22.620
This case, the attacker faking or impersonating Outlook asked for graph API and whatever scopes there were.

07:22.840 --> 07:32.840
Now, they're going to use the refresh token because Microsoft allows them to get a token, a new token with Azure access, which is what's highlighted there.

07:33.120 --> 07:40.100
That breaks the OAuth model and there's a reason why Microsoft did that besides being stupid.

07:40.100 --> 07:41.960
It's for SSO reasons.

07:42.600 --> 07:45.940
They're using OAuth for SSO, which is also stupid.

07:45.940 --> 07:50.520
Don't use authorization protocols for authentication, but they did it.

07:50.760 --> 07:55.800
So, because as an attacker, they're continuing on their flow, they've got a new token.

07:55.800 --> 07:59.560
It's Azure management API enabled.

07:59.560 --> 08:01.660
They can now enumerate all resources.

08:01.860 --> 08:03.380
Okay, it's the user's permissions.

08:03.380 --> 08:05.460
This case is global admin, so it's everything.

08:05.460 --> 08:06.480
Okay, great.

08:06.480 --> 08:10.380
We just went through this flow as a user and attacker.

08:10.400 --> 08:21.060
It's fairly complicated, but I want to point out that normally, if this weren't an attack, there's a step one, which is the user installs an app and then they're expecting all of this prompting.

08:21.060 --> 08:23.080
Well, we convert it to a phish.

08:23.080 --> 08:26.080
The attacker starts with step two.

08:26.080 --> 08:27.780
They're fully in control.

08:27.800 --> 08:34.280
And again, the client ID is not even something they had to create that traces back to them in the logs.

08:34.280 --> 08:37.980
It is Microsoft Office client ID.

08:38.680 --> 08:54.100
The other piece at the tail end was we switched permissions and did a lateral move, which could also call privilege escalation by trading our token, refreshing, and getting Azure management resource permissions.

08:55.120 --> 09:09.940
From a logging perspective, when you look at the logs, when the attacker script actually gets the first token that is logged, yay, when they refresh and pivot to Azure, it is not logged.

09:09.940 --> 09:17.700
You might guess that developers didn't want to busy up the logs with a refresh, which might have to happen like every hour.

09:17.700 --> 09:18.600
Who knows why?

09:18.600 --> 09:22.460
It's dumb because you're not seeing the lateral movement.

09:23.740 --> 09:30.060
The details of the actual log are what you get in the sign-in logs.

09:30.060 --> 09:30.880
It's not bad.

09:30.880 --> 09:35.020
It means you have a chance to mitigate this with conditional access policies.

09:35.020 --> 09:37.900
That is the recommended way to do it.

09:38.940 --> 09:41.760
Conditional access policies are a bit of a Swiss cheese thing.

09:41.760 --> 09:42.720
They are imperfect.

09:42.720 --> 09:46.780
If you do research, you'll find that there are ways still to bypass it.

09:46.780 --> 09:49.160
Knowing this, Microsoft didn't stand still.

09:49.160 --> 09:52.020
They added device code as an attribute.

09:52.020 --> 09:54.300
You can put that in conditional access policies.

09:54.300 --> 09:57.160
You can prevent all apps from using device code.

09:57.160 --> 10:02.180
That's not a bad idea, other than the fact that Azure CLI uses device code.

10:02.180 --> 10:05.620
So you're going to have to be creative to actually get the right policy.

10:05.620 --> 10:12.040
Second, there's an enumeration, a static list that they keep adding to of apps.

10:12.040 --> 10:16.560
Microsoft Office, the actual app ID I picked, is not in that list.

10:17.020 --> 10:28.600
It just means fine-grained control of conditional access policies with this app that I impersonated is still very, very tricky to get right, even if you know all of this.

10:28.800 --> 10:30.140
So there we have it.

10:30.140 --> 10:36.600
A three-and-a-half-year-old attack that is still popular, not well educated.

10:36.600 --> 10:44.560
So when we look at the big picture, let's just go to Microsoft, since we're bashing them a bit, and look at their unfortunate incidents.

10:44.560 --> 10:50.720
So we have Blizzard from March, a favorite nation-state, maybe along with China, Russian hackers.

10:50.720 --> 10:53.140
I'm sure you all have reviewed it.

10:53.140 --> 11:07.880
Some techniques are old, like password spraying, exchange or email as a target, proxies with a little twist of residential, and then OAuth apps coming more and more common if you've been reading the news.

11:07.880 --> 11:19.860
In there, maintain access, persistence, elevated access, privilege escalation, being a little clever, using a legacy app to create a new user account, and then bless another app, right?

11:19.860 --> 11:22.140
Leave your, you know, a little creativity.

11:22.960 --> 11:25.420
Let's switch to Storm last summer.

11:25.420 --> 11:28.340
Let's switch nation-state actors to China.

11:28.980 --> 11:43.140
Now we're going through a common attack vector of email again, but it's more complicated because underneath we have MSA tokens from the consumer side of email, and somehow there's a bug that allows that to sort of switch over to corporate email.

11:43.860 --> 11:47.900
At the end, I'm not here to say Microsoft's bad.

11:47.900 --> 11:49.700
They've got smart people.

11:49.800 --> 11:52.060
They've got legacy code and a big installed base.

11:52.060 --> 11:52.980
Defense is hard.

11:52.980 --> 12:06.200
When you look through Storm's techniques, anyone who's read, and I applaud Microsoft for disclosing their process, but if you read it closely, Microsoft got confused in their own analysis.

12:06.200 --> 12:12.060
They'd be like, oh, we think it's a race condition, and we think there's a crash dump, but we don't actually have that evidence.

12:12.160 --> 12:16.640
But it seems that, you know, out of code review, it seems very, very plausible.

12:16.680 --> 12:25.680
So steps one, two, three, four, five, it looks like a perfect storm that allowed this to, pun I guess intended, to actually happen.

12:25.680 --> 12:34.620
Obviously a very sophisticated APT-level nation-state actor, but the point is defense is hard, even for the best who have money and expertise.

12:35.060 --> 12:41.820
All this to say, before we talk about defense, the question is why do we even have to talk about new defense?

12:41.860 --> 12:46.420
Because attackers are winning, and we know which side of the field they're on, right?

12:46.780 --> 12:51.480
And it's not just buzzwords and headlines, which is easy to paint a story.

12:52.120 --> 13:06.740
What I appreciate about DEF CON is you meet some of the greatest researchers sharing their work, and here's just a smattering from the last couple years that I've just jotted down and are somewhat related to things I think about.

13:06.760 --> 13:10.180
Every year, there's another 20 of these.

13:10.180 --> 13:12.040
So enumeration without logging.

13:12.040 --> 13:20.020
I think Nick Frechette, big fan of his, he spoke last year, he spoke in that black hat, he spoke, he's speaking after me.

13:20.060 --> 13:25.020
AWS enumeration without logging and other sophisticated techniques.

13:25.020 --> 13:27.200
Obviously, we know about Rhino Labs.

13:27.200 --> 13:34.120
There's classic techniques, though, still sitting around to enumerate SharePoint URLs without authentication, right?

13:34.120 --> 13:39.960
Enumeration is tough to stop, even if the vendor plugs a hole.

13:39.960 --> 13:47.760
There's access and persistence in unmanaged, or at least less commonly thought of, full-blown virtual machine environments.

13:47.760 --> 13:48.220
Guess what?

13:48.220 --> 13:49.780
Cloud Shell runs in a VM.

13:49.780 --> 13:50.160
Guess what?

13:50.160 --> 13:52.960
The protections there are pretty low.

13:52.960 --> 13:54.140
Guess what?

13:54.500 --> 13:58.700
They want to push it for free to everyone because it's really easy.

13:58.700 --> 14:02.500
Pre-configured environment with a CLI set up and full access.

14:02.620 --> 14:11.860
So open ports have been spoken about by my colleague Hubert Lin at this DEF CON of how you can abuse that to get access to a whole bunch of services.

14:12.120 --> 14:19.660
We just went over number three a couple years ago, Matthew Bryant, server-side scripting in Google Apps.

14:19.660 --> 14:23.960
I didn't know that existed until he talked about that with loose permissioning, right?

14:23.960 --> 14:34.820
As if Microsoft didn't tell the world and Adobe that embedding scripting code and documents was a bad idea, Google had to go copy them and say, no, we're going to put it in the server.

14:34.820 --> 14:37.560
An ability to open a doc and execute code.

14:37.560 --> 14:39.600
What could go wrong, right?

14:40.720 --> 14:43.580
Five, service principles at this DEF CON.

14:43.580 --> 14:45.860
I loved Cloud Village talks.

14:45.860 --> 14:58.080
There were at least three, four people that I listed that were diving into Azure service principles, managed identities, enterprise apps, app registrations, cross-tenant access, and the admin roles.

14:58.120 --> 15:00.700
And there is so much there to mine.

15:00.700 --> 15:04.080
We're just scratching the surface of abuse there, right?

15:04.080 --> 15:08.040
It's being talked about a lot more, and a lot more is coming from that.

15:08.040 --> 15:27.260
And then, Asterix a couple years ago had a GCP attack where they used the temporary deletion of a project for 30 days to hide stuff, because once you deleted it, it disappeared from APIs and portal views, and in there was an OAuth app, so it's a persistence move.

15:27.260 --> 15:37.080
You need access, set it up, you undelete the project, you use the app for whatever privilege escalation, you delete it again, just make sure you come back in 30 days.

15:37.100 --> 15:51.160
And so, as I'm working this year's CTF a little bit, creating a challenge, Azure has a similar temporary delete status folder for Azure objects, including service principles, right?

15:51.160 --> 15:55.520
So, ability to hide code and privilege really easily, right?

15:55.520 --> 15:58.880
So, this is just off the top of my head.

15:58.880 --> 16:04.860
The point is, attackers are winning, they're smart, even our research shows that, right?

16:04.860 --> 16:06.460
Our greatest minds.

16:06.460 --> 16:26.380
So, you can feel like you're going to a gunfight , but the attacker is the one who has the gun, and you're walking uphill, they change the rules, the asymmetry, and what I mean by that is every dollar and every hour they spend causes like an order of magnitude on the defensive side.

16:26.880 --> 16:31.300
They have stealth, almost by the get-go and default.

16:31.540 --> 16:38.920
They take advantage of every single ability to execute code within our blue hat environments.

16:38.920 --> 16:54.940
That is, like, VMs, the obvious one, then there's serverless functions, then those things hiding as VMs, like Cloud Shell, or as I think Nick Frechette pointed out, VPC endpoints in AWS are just running on some kind of VM.

16:54.940 --> 17:04.080
OAuth apps, which is code, and privileges, and app scripting in Google, among other things, with a ton of backdoors.

17:04.080 --> 17:12.580
This ghost token, these OAuth apps, this code, and then, of course, they can attack the human layer, which we know is the weak link, right?

17:12.580 --> 17:20.500
All of this, while the defensive reality is you feel like you're fighting with a butter knife, okay?

17:21.280 --> 17:26.820
And unfortunately, here's where I think security, we've fallen into a rut.

17:26.820 --> 17:28.360
We don't challenge ourselves.

17:28.360 --> 17:32.520
I think security is too much done by checklist.

17:33.120 --> 17:34.460
You think about it.

17:34.460 --> 17:36.840
What's a good best practice by a vendor?

17:36.840 --> 17:44.280
It's a checklist of usually configuration, sometimes some detection, sometimes some remediation.

17:44.280 --> 17:47.800
So you feel good if that's your job, you're done with the list.

17:47.800 --> 17:50.760
Your boss is good, compliance will pass you.

17:50.760 --> 17:51.720
Are you really secure?

17:51.720 --> 17:53.020
We all know better.

17:53.020 --> 17:54.960
You have to actually think about it.

17:55.520 --> 18:04.160
But we don't really think about the design issues, software issues, the things that are causing havoc, like the demo screenshots.

18:04.580 --> 18:08.700
Is OAuth really designed well in Microsoft?

18:08.700 --> 18:10.080
The answer is no.

18:10.340 --> 18:15.760
So that should cause you a different stance rather than here's the best practice for securing Microsoft OAuth.

18:15.760 --> 18:18.580
Put in a conditional access policy and be done with it.

18:18.580 --> 18:21.340
No, you're still exposed, you know that, right?

18:21.540 --> 18:34.980
Staying behind the moat is this idea that it's great, we paint these analogies, the moat is our outer perimeter, then we hide behind it with a good drawbridge, we throw some alligators in the moat, we go with a high wall, put some archers on top.

18:35.300 --> 18:44.460
Okay, do that, but how about send some peasant spies out into the barbarian lands and do something a little more proactive?

18:44.600 --> 18:51.820
Because that's what the red team's doing, that's what the attackers are doing, that's what social engineering is doing, right?

18:51.820 --> 18:56.700
Why don't we borrow and apply the same brainpower on the blue side?

18:56.740 --> 19:00.540
Now, defense in depth leads to layered defenses, which is great.

19:00.540 --> 19:05.620
The problem is the implementation at the human level, I think, leads to isolation.

19:05.620 --> 19:15.760
My firewall team doesn't talk to the IPS team, which definitely doesn't talk to the malware team, much less my machine learning risk analysis sim team.

19:15.980 --> 19:19.860
So we've broken the problem into three discrete components.

19:19.860 --> 19:21.960
The attacker's like, you're a fool.

19:21.960 --> 19:30.960
I'll social engineer the network guy through the help desk, I'll pivot and I'll get app credentials and blah, blah, blah, and we have groups not talking to each other.

19:30.960 --> 19:38.160
The threat and attack vector and attack chain cuts across everything, but we're organized in layers that don't talk to each other.

19:38.160 --> 19:39.240
What's an example of that?

19:39.240 --> 19:41.840
Here's a minor one, which could be a major one.

19:41.840 --> 19:44.560
It shows itself in product features.

19:44.560 --> 19:52.320
Google Cloud has a session timeout for your cloud logins through the portal, as well as the tokens you might get.

19:52.320 --> 19:53.640
Good idea.

19:53.640 --> 19:55.800
Default sucks, but it's a good idea.

19:55.800 --> 19:59.120
Where is that located in API land or the portal?

19:59.120 --> 20:01.280
In Google Workspace.

20:01.340 --> 20:10.880
I get we have a common identity service, but that might be two separate groups in a large organization who don't talk to each other.

20:11.040 --> 20:15.460
Imagine an incident happens and you have to revoke access and force a revocation.

20:15.860 --> 20:21.660
Are you trusting the guy on the Google Cloud side to know where to go to set the timeout?

20:21.660 --> 20:26.680
Of course it's not going to happen, but this is the the world we have fallen into.

20:27.080 --> 20:28.040
Defenses are static.

20:28.040 --> 20:29.400
They don't change much.

20:29.640 --> 20:32.120
Same for all attackers and all environments.

20:32.120 --> 20:33.380
They tend to be pretty generic.

20:33.380 --> 20:37.240
Not completely, but we tend to be like, let's go through the checklist.

20:37.240 --> 20:37.720
We're done.

20:37.720 --> 20:38.580
Let's move on.

20:38.580 --> 20:40.500
And everything's in plain sight.

20:40.500 --> 20:42.860
So what could the future be?

20:42.860 --> 20:47.260
My whole premise is think more about design and less about checklists.

20:47.400 --> 20:49.200
Go towards the attacker.

20:49.200 --> 20:53.660
Yes, think in their mind and be in their shoes, but get closer to them.

20:53.660 --> 20:54.660
Do recon.

20:54.940 --> 20:56.740
Figure out how that fits.

20:57.260 --> 20:59.900
Cut across your organizational boundaries.

20:59.960 --> 21:03.540
If we're going to do stuff, we've got to start with engineering teams within organizations.

21:03.540 --> 21:07.220
They're developing crap and sending it through DevOps, right?

21:07.700 --> 21:10.960
Insecure apps are going to cause havoc on the ops side.

21:10.960 --> 21:13.460
And then you get to threat hunting and risk assessment.

21:13.460 --> 21:15.100
Everyone's got to be working together.

21:15.100 --> 21:20.580
Now I get this is stuff that we may not be able to control, but the advantage is I'm not trying to create a product.

21:20.580 --> 21:25.340
I'm trying to burn everything to the ground and rethink how would we do this better?

21:25.340 --> 21:27.940
And we would definitely address some of these.

21:27.940 --> 21:30.800
We would be dynamic and changing and make things stealthy.

21:30.800 --> 21:34.620
To the extent that it doesn't screw us up, we would be changing things.

21:34.620 --> 21:47.140
So attackers, the analogy would be change the bank vault code every day because if you get an ex-employee or a paid insider, it makes it harder for the thieves to break into your vault.

21:47.140 --> 21:49.720
Not perfect, I would rotate the key.

21:49.880 --> 21:52.080
Instead, we tend to be static, right?

21:52.080 --> 21:58.100
And all of this is about tailoring things to buy CSP because every CSP is different.

21:58.100 --> 22:01.600
AWS is different, obviously, than every other one.

22:01.600 --> 22:04.940
We would also tailor it to the attacker techniques.

22:04.940 --> 22:12.700
To the extent I can intuit attackers shifting their techniques in a fundamental way, I have to change and create new defenses.

22:13.500 --> 22:15.640
We do do some of that.

22:15.640 --> 22:17.180
It tends to just be reactive.

22:17.180 --> 22:19.520
Come to DEF CON, wait for someone to publish something.

22:19.520 --> 22:21.220
Oh, there's a CVE.

22:21.220 --> 22:21.580
I did.

22:21.580 --> 22:22.400
I mitigated it.

22:22.400 --> 22:23.100
Move on.

22:23.100 --> 22:24.840
I think we need to think more fundamentally.

22:25.940 --> 22:33.580
I think in the coming year will be a whole bunch of service principle attacks and related ones on Azure because that's the gold mine.

22:33.580 --> 22:36.200
It's complex and it's a way to escalate privileges.

22:36.200 --> 22:39.760
Let's get out of the curve, think about that design, put in defenses.

22:39.760 --> 22:41.020
Okay, enough of that.

22:41.020 --> 22:42.140
That's really high level.

22:42.140 --> 22:42.860
I get it.

22:42.860 --> 22:45.320
Let me tell you a story to try to make this real.

22:45.320 --> 22:47.120
It's an old school story.

22:47.120 --> 22:48.020
Unix.

22:48.180 --> 22:50.860
This is before Linus ate the world.

22:50.860 --> 22:52.260
So Solaris was still around.

22:52.260 --> 22:54.440
It was probably 20 years ago.

22:55.700 --> 23:01.480
The idea is if you have an inner sanctum kind of server, super important data.

23:01.480 --> 23:05.240
Maybe it's you know, Hunter Biden's real laptop.

23:05.600 --> 23:12.020
Maybe it's the Zelensky audio that got hidden or the video of Trump in Russia, whatever it is.

23:13.020 --> 23:14.920
You put in protection, right?

23:14.920 --> 23:15.940
Layer defenses.

23:15.940 --> 23:20.940
But you got to be thinking, what if someone breaches the ring zero?

23:21.000 --> 23:21.960
What am I going to do?

23:21.960 --> 23:23.160
How do I detect?

23:23.160 --> 23:25.500
And then how do I do?

23:25.500 --> 23:27.160
It's not really remediation.

23:27.160 --> 23:29.100
It's just save the jewels.

23:29.100 --> 23:32.900
How do I, you know, pull the plug, take it offline?

23:33.620 --> 23:37.540
So you think about, it's likely they'll be on a shell.

23:37.540 --> 23:42.960
Even if they have a sophisticated RCE, usually at some point the attacker is going to get shell.

23:43.440 --> 23:49.700
Then you think about, this is a story told by a really good CTO boss of mine.

23:49.880 --> 23:52.320
Then you think about the attacker, what they might do.

23:52.320 --> 23:56.560
Well, they're likely going to do LS in the first like two commands, right?

23:56.960 --> 24:01.040
And then you switch it up on the attacker.

24:01.620 --> 24:07.040
So instead of the real LS, you make it execute shut down now in some form.

24:07.040 --> 24:10.800
Now you might not do this crappy little shell script, but you get the idea.

24:10.800 --> 24:12.900
If you can read jokes in Unix, right?

24:12.900 --> 24:14.440
In bash or shell.

24:14.460 --> 24:20.800
The idea is you fool the attacker so that it not only detects it, it fixes the problem.

24:20.800 --> 24:22.100
Yes, it shuts it down.

24:22.100 --> 24:27.660
Someone has to probably physically or remote get into it, but just save the crown jewels.

24:28.840 --> 24:33.180
Now, that's all well and good, but you do have to use this, right?

24:33.180 --> 24:35.640
It's not just a fake trap.

24:35.640 --> 24:37.360
So what do the good guys do?

24:37.580 --> 24:38.780
They train themselves.

24:38.780 --> 24:42.840
Now, I know this is a little hard, but this is the true story.

24:42.840 --> 24:48.220
They learn how to do echo star and shell expansion as their poor man's LS.

24:48.220 --> 24:51.360
So for, you know, Unix guys, that's the story.

24:51.360 --> 24:58.200
True story, but what it represents is this idea of tripwires and this whole point.

24:58.200 --> 25:02.880
Can you identify choke points that are likely to be traversed by the bad guys?

25:02.880 --> 25:07.460
Can you create a tripwire that is stealthy that they will trip themselves?

25:07.500 --> 25:09.540
Three, can you create a grenade?

25:09.540 --> 25:23.540
And it could be something a little less than a grenade, like a video logging, whatever alert, but you get the idea, something for an action, but don't kill the good guys and don't confuse yourself.

25:23.540 --> 25:35.720
So in Unix land 20 years ago, this was an anecdote, but it sat in my mind for 20 years of how can we do this in the cloud?

25:35.900 --> 25:40.280
So I think I got about five minutes.

25:40.280 --> 25:42.880
So I'm going to have to get into the good stuff really quickly.

25:42.880 --> 25:44.240
You guys got to keep up.

25:44.240 --> 25:44.640
All right.

25:44.640 --> 25:50.460
There are some common techniques that I think we can incorporate in detection.

25:50.460 --> 25:57.320
The trouble with trying to stop an individual technique, as you've seen, is they're very sophisticated.

25:57.320 --> 25:58.320
They change.

25:58.320 --> 26:02.300
You stop Nick Frechette's cool, awesome enumeration technique.

26:02.300 --> 26:03.500
He's got another one.

26:03.500 --> 26:05.440
I guarantee it next year.

26:05.440 --> 26:06.300
He's that good.

26:06.300 --> 26:08.480
If you've been following him, it doesn't matter.

26:08.480 --> 26:13.560
Think about, you know, China, APT zero, we got smart guys.

26:13.880 --> 26:17.300
So instead I wanted to look at choke points.

26:17.300 --> 26:22.480
What do attackers, pen testers, and you guys feel free to disagree, think about it.

26:22.480 --> 26:25.680
What do you do once you get initial access?

26:26.020 --> 26:32.920
Even after you get privilege escalation, you often do more recon because you don't want to leave money on the table.

26:32.920 --> 26:34.060
You could.

26:34.200 --> 26:46.020
I'm not trying to solve every case, when you do discovery, you might, to take an AWS example, enumerate resources or security principles, right?

26:46.080 --> 26:48.080
What buckets are there?

26:48.200 --> 26:50.420
Do a list on buckets.

26:50.560 --> 26:52.960
And then go probe, right?

26:52.960 --> 27:05.840
You might be worried about being detected and think about what's in CloudTrail or not, but some of this is in CloudTrail and you're just going to be like, let me go slam into the Apple store, grab the stuff, I'll be out of here by the time they come, doesn't matter,

27:05.840 --> 27:06.560
right?

27:07.020 --> 27:07.980
Of course you will.

27:07.980 --> 27:09.260
What else might you do?

27:09.260 --> 27:20.240
You might check your own permissions, list your IM policies or equivalent, because that'll tell you what the admins granted that user.

27:20.240 --> 27:34.960
And there might be explicit listings of an AWS LAN generic sort of policy of, oh, I can do things like assume role, that's interesting, privilege escalation on, you know, such and such service.

27:34.960 --> 27:38.640
I can get and list this bucket called finance, right?

27:38.640 --> 27:39.820
So on and so forth.

27:39.820 --> 27:41.560
I might have wild cards.

27:41.560 --> 27:43.220
I've got stuff to work with.

27:43.220 --> 27:48.040
Directly try or do a little bit more discovery.

27:48.040 --> 27:49.500
So what's my premise?

27:49.500 --> 27:50.780
This is pretty common.

27:50.780 --> 27:54.440
Enumeration, resource access, security principle access.

27:55.520 --> 27:57.540
Back to tripwires.

27:57.540 --> 27:59.740
I'm going to set up some fake ones.

28:00.260 --> 28:08.760
Very enticing ones that are highly monitored, that are unlikely to be used by my good users or valid users.

28:08.760 --> 28:13.720
Simple enough concept, hard to implement without false positives, but it can be done.

28:13.720 --> 28:25.820
And my point is, if we don't start the hard thinking now, we'll just be in checklist security forever, which is good job security for everyone in the room, but not great for society at large.

28:25.900 --> 28:28.100
So what do I mean by that?

28:28.160 --> 28:35.800
I might allow finance acme.com, of course, to be a fake bucket, among others that they can enumerate.

28:35.800 --> 28:40.100
The real finance one is inaccessible or it's named something else.

28:40.100 --> 28:46.500
It's just one method among dozens I want to bring to even that playing field.

28:46.920 --> 28:53.060
If they assume role, I can see what roles this user is allowed to list.

28:53.060 --> 28:54.860
There might be the default admin.

28:56.700 --> 29:03.440
And so I might want to be smart about setting up fake roles that are real, but maybe with stunted permissions.

29:03.740 --> 29:06.020
And in explaining that, I want to point to tools.

29:12.880 --> 29:20.720
I will use a very nice, sophisticated technique to check if it can assume it and it's not logged.

29:21.540 --> 29:26.980
Well, if this is a popular tool, I'm not just going to get the benefit as a red teamer.

29:26.980 --> 29:29.540
I'm going to set up some fake ones based on this.

29:29.540 --> 29:37.840
Yes, admin I can get to on my own, but how about, I don't know why they have Aaron in there, but API gateway and AWS, I don't use this in my org.

29:37.840 --> 29:42.120
I'm going to set up some fake ones with restricted permissions, monitor the hell out of it.

29:42.120 --> 29:48.000
And my valid users shouldn't be running Paku internally.

29:48.160 --> 29:53.140
And so I'm thinking ahead, maybe this gives me low false positives.

29:53.140 --> 30:02.380
Someone who hits a account or Abram, as an example, might be a high true positive detection that I can act on.

30:02.380 --> 30:04.960
And it's just a tripwire that I've set up.

30:04.960 --> 30:06.460
Be tool specific.

30:06.680 --> 30:07.580
It's dumb.

30:07.580 --> 30:10.480
Why would I set up defenses ignoring all the tools?

30:10.480 --> 30:13.100
So the dictionary lists are a big one.

30:13.100 --> 30:17.300
Let's shift gears to compute, which is highly open-ended.

30:17.300 --> 30:22.100
This brings us into the old world that the fully open ports run any code.

30:22.100 --> 30:22.960
It's a nightmare, right?

30:22.960 --> 30:24.760
But of course it has to be provided.

30:24.880 --> 30:29.060
Netflix security team does awesome work and this is years old.

30:29.080 --> 30:31.840
And of course they have the resources to know how to implement this.

30:31.840 --> 30:33.980
So it's sort of guidance with a little bit of code.

30:34.220 --> 30:37.120
They took the normal process.

30:37.120 --> 30:39.480
This is a big attack vector.

30:39.480 --> 30:46.360
Grab the credentials of the EC2 instance if you can get on it or hit the metadata service, right?

30:46.360 --> 30:54.100
So normally application will hit that locally on the server and grab credentials and have it returned to them.

30:54.120 --> 30:59.600
But what Netflix did is said, uh-uh, I want to IP restrict that credential.

30:59.600 --> 31:04.580
So if it's used off board, I detect it or it won't work or I can monitor it.

31:04.580 --> 31:07.700
So instead they did some sophisticated things.

31:07.700 --> 31:11.320
They set up their own proxy, reworked IP tables.

31:11.360 --> 31:15.900
So any request to the metadata service hit their proxy right there in white.

31:16.520 --> 31:20.840
At boot up time, that proxy got the IP address of the EC2 instance.

31:20.840 --> 31:21.460
It did.

31:21.460 --> 31:23.360
They did something really clever.

31:23.400 --> 31:24.680
They assumed role.

31:24.680 --> 31:28.720
They set it up so they could assume the role of the EC2 instance in step three.

31:28.780 --> 31:30.080
They can wrap.

31:30.080 --> 31:36.000
When you do that, you can optionally set a policy when you assume a role and get those credentials back.

31:36.000 --> 31:40.540
So they've set an IP policy like this in red.

31:40.540 --> 31:42.500
And that IP is the EC2 instance.

31:42.500 --> 31:50.420
They effectively are getting temporary tokens that they created that are bound to the IP address.

31:50.520 --> 31:52.400
And they can do whatever they want with it.

31:52.400 --> 31:55.260
It can be a straight out deny, right?

31:55.480 --> 31:56.940
Very clever.

31:56.940 --> 31:58.260
Takes some work.

31:58.260 --> 31:59.740
Very clever.

32:00.120 --> 32:05.460
And it's doing to, it's going to mitigate breaching and compromise of your EC2 instance.

32:05.460 --> 32:09.840
I want to take that idea and be a little more subtle.

32:09.840 --> 32:11.240
I may not want to stop it.

32:11.240 --> 32:13.580
I just may want to log it, right?

32:13.580 --> 32:18.400
I know my policies and procedures are to do certain things, never go off board.

32:18.400 --> 32:25.740
But if someone steals it, I might want to just record their IP address and do something else with it and not just outright block them, right?

32:25.740 --> 32:27.780
I'm thinking defense and detection.

32:27.780 --> 32:32.120
I might want to give them some fishing line, let them do it.

32:32.120 --> 32:33.460
Or I might want to block them.

32:33.460 --> 32:37.280
My point is, we got to think about prevention in a new way.

32:37.280 --> 32:42.840
If you prevent something, I don't want you to drop that deny block on the floor.

32:42.840 --> 32:44.380
Think about firewalls.

32:44.380 --> 32:46.360
Gets really noisy on the perimeter.

32:46.460 --> 32:48.080
Denies usually are not logged.

32:48.080 --> 32:50.220
Because of that, they get dropped on the floor.

32:50.220 --> 32:53.760
They're also false positive land, like a Tor exit node.

32:53.760 --> 32:56.040
You get down on the firewall, what's the use of logging that?

32:56.040 --> 32:57.500
Are you going to really act on it?

32:57.500 --> 33:00.260
Better just to deny it and drop it.

33:00.260 --> 33:01.860
No, I want to change that.

33:01.860 --> 33:08.420
I want you to do the job, but I want to collect information that I got traffic from China or a Tor exit node.

33:08.420 --> 33:13.560
And if I ever see that elsewhere in my environment, that helps me.

33:13.960 --> 33:22.220
My defenses internal to the moat get helped by perhaps defensive measures outside at the perimeter.

33:23.060 --> 33:25.460
Really, really nuanced view.

33:25.560 --> 33:29.620
Let me cover one last cache, sort of external credential.

33:29.620 --> 33:31.480
I want to move forward towards attackers.

33:31.480 --> 33:33.740
I don't want to sit behind my moat.

33:33.740 --> 33:39.720
So, most of the external programs, including the CLIs, cache credentials.

33:39.840 --> 33:43.020
Most all of them, put them in clear text.

33:43.320 --> 33:47.540
You ask the vendors, they're sort of like, well, yeah, if you're in points, compromise, you're screwed.

33:47.540 --> 33:48.600
Sorry, good luck.

33:48.600 --> 33:51.340
You know, that's CrowdStrike's problem, not AWS's problem.

33:51.900 --> 33:55.340
That's what, don't use static API keys.

33:55.340 --> 33:56.500
Oh, great, thanks.

33:56.500 --> 33:58.780
But I do need something.

33:58.980 --> 34:04.160
So, in their SQLite database, this is Google, everyone's the same.

34:05.900 --> 34:09.580
What I want to do from a detection perspective is put fake credentials in there.

34:09.580 --> 34:15.520
If they actually work, are highly limited, they go to empty accounts, monitor the hell out of them.

34:15.620 --> 34:17.840
These survive updates, they're config.

34:17.840 --> 34:26.200
I can plant that one time on my admins who work from home or over whatever VPN, plant them.

34:26.600 --> 34:31.600
They'll probably stay live forever with the most tokens the way that they work.

34:31.940 --> 34:37.520
If they're ever compromised, and I detect that activity in an account, boom.

34:37.520 --> 34:39.960
Low chance of the admin using it, they'll be trained.

34:39.960 --> 34:49.200
But unless they're looking in their own config or listening configs, I want to think more like this, right?

34:49.200 --> 34:57.500
Choke points, tripwires, specific to the design of cloud providers, grenades or actions have to be really thought about carefully.

34:57.820 --> 35:00.140
And don't killing the good guys is probably the key here.

35:00.140 --> 35:06.460
Because even if you buy that there's ways to detect advanced attackers, the key is, how do you not screw yourself?

35:06.460 --> 35:13.240
Because you screw yourself, create work for yourself, if you're a blue hat, you're out of a job, your boss gets pissed, blah, blah, I get it.

35:13.240 --> 35:16.500
So what do message of the days do in honeypots?

35:16.500 --> 35:22.500
They probably in some way, disinvite or invite the bad guys or good guys, right?

35:22.500 --> 35:29.160
It says, hey, this is not allowed as a site, you really should log off the server, right?

35:29.160 --> 35:31.220
That's the message of the day in a honeypot.

35:31.220 --> 35:32.720
And the attacker ignores that.

35:32.720 --> 35:35.560
So when they do further activity, you have a higher probability.

35:35.560 --> 35:37.900
What's the example in S3 bucket?

35:37.900 --> 35:41.300
It's the top level file because everyone's going to enumerate from the top.

35:41.420 --> 35:49.560
So yeah, a valid user might go there, but I've got to read me that says, you know what, this is the old finance bucket and it's only, you know, authorized for finance personnel.

35:49.560 --> 35:51.880
If you're looking at it, you should really not look at it.

35:51.880 --> 36:05.520
Three levels deep in the path, I have all the interesting finance files with further warnings of, hey, this is not really current, you should ask your administrator for access to the current one, but this is current as of a month ago.

36:05.520 --> 36:13.200
And if there's enumeration down that path, ignoring the signs, then you have a higher probability.

36:13.240 --> 36:18.460
You add this into the mix to refine and lower your false positives, right?

36:18.460 --> 36:22.400
You take a simple access to a resource and you try to make it work for you.

36:22.760 --> 36:24.620
You restrict admin roles.

36:24.680 --> 36:25.940
What do I mean by that?

36:25.940 --> 36:30.240
It depends on CSP, but maybe you keep the real admin role.

36:30.240 --> 36:32.580
You create a custom role that has that privilege.

36:32.580 --> 36:34.420
That's what the valid users use.

36:34.420 --> 36:36.160
What do you do with the real admin role?

36:36.160 --> 36:37.100
You restrict it.

36:37.100 --> 36:42.340
If the CSP allows you to do it, take root, for example, in AWS, right?

36:42.340 --> 36:46.400
Common wisdom when you first get on AWS is root can do everything.

36:46.460 --> 36:55.800
Well, not actually, you can have a VPC or you can have a, at the org level, you can have a boundary control, right?

36:55.800 --> 36:59.100
That you implement that can prevent root from doing things.

36:59.160 --> 37:04.260
So if there's a capability, you can stunt the default admin roles.

37:04.340 --> 37:06.500
Use a copy or custom role.

37:06.640 --> 37:14.080
Now you have a way to distinguish valid users, don't kill them, versus attackers who always go after the default admin roles.

37:14.300 --> 37:15.500
Not doesn't work everywhere.

37:15.500 --> 37:17.640
You got to put your mind and design.

37:17.740 --> 37:19.200
So you keep doing these things.

37:19.200 --> 37:22.400
You also add in signing and tagging.

37:23.060 --> 37:28.600
Session tags in AWS, when you assume a role, you can basically pass along some tags.

37:28.740 --> 37:31.060
You can incorporate that into workflow.

37:31.160 --> 37:33.420
Valid users, pass in the right ID.

37:33.420 --> 37:40.680
It doesn't prevent them from assuming role, it just identifies them as, I know the current month's secret ID.

37:40.680 --> 37:44.940
Attacker wouldn't do that, they would get success, they would plow ahead.

37:45.000 --> 37:47.480
They're not stopped, they would plow ahead.

37:47.480 --> 37:51.240
They wouldn't bother backtracking trying to figure out if an ID is being used.

37:51.240 --> 37:55.160
Okay, that's the AWS session role.

37:55.160 --> 37:58.320
I got to wrap this up so I don't cut too much.

37:58.320 --> 38:00.100
So this is my last slide.

38:00.200 --> 38:01.900
What's the practical of all this?

38:01.900 --> 38:11.180
If you've heard the theory and you think there's a chance of this approach, there's some requirements for this to even see the light of day.

38:11.180 --> 38:12.880
So I'm starting in the middle.

38:13.180 --> 38:14.880
There's got to be comprehensive research.

38:14.880 --> 38:17.680
That's my job and anyone who's interested.

38:17.680 --> 38:25.880
You got to look at everything to try to see where are the choke points across APIs, not just the CSPs, but the app APIs.

38:26.180 --> 38:30.060
They have to actually work and not kill the good guys, efficacy.

38:30.220 --> 38:37.740
The cost of using this has to be low enough because none of us are going to do a lot of work for little return on the blue side.

38:37.920 --> 38:42.060
And it has to sort of pass that open source kind of sniff test.

38:42.060 --> 38:51.740
If you're a red hat and you know this is in place, are you still slowed down so that it's a more of a level playing field?

38:51.740 --> 38:58.300
And the point I would say is even if you know I have fake roles and resources in play, you don't know exactly which ones they are.

38:58.300 --> 39:01.620
And at a minimum, you are slowed down when you enumerate.

39:01.620 --> 39:06.040
And before you assume a role, you have to think about whether that's real or not.

39:06.040 --> 39:12.000
And you likely can't a priori know that if I've set up the environment right.

39:12.000 --> 39:13.640
You have to try it.

39:13.640 --> 39:19.220
And when you try it, I'm counting on I've set things up to distinguish you from a good guy.

39:19.560 --> 39:33.840
So practically speaking in next coming weeks, I'll be publicizing some tool set as a POC, some software to sort of show how you can implement these, do CRUD operations, report on and delete them.

39:34.400 --> 39:47.360
The idea that you could have a CLI that helps you with creation of tripwires and not have it be a hassle like wondering what the heck is in place, how do I delete it, did it actually work, and so on.

39:47.920 --> 40:00.180
But we have to keep publishing research, keep thinking about this, putting as much time and effort as we do on all the good stuff on the red side.

40:00.380 --> 40:04.300
So I think I'm over time and I apologize.

40:05.540 --> 40:06.360
That's the end.

40:06.360 --> 40:10.020
I would love if you have comments, even if that's the dumbest idea I've ever heard.

40:10.020 --> 40:13.800
Love to hear it because that just makes me work harder on this effort.

40:13.800 --> 40:20.260
It's a long -running research project and it's just something of we got to think different is the bottom line and we've got to try it.

40:20.260 --> 40:30.860
I'm convinced if we took the smart people at Khan, we would make greater strides than just a tool of the day which fixes an issue of the day on a checklist.

40:30.860 --> 40:31.780
Those are important.

40:31.780 --> 40:33.020
I'm not saying don't do it.

40:33.020 --> 40:40.340
I'm saying what prevents us from doing the same damn thing every Khan with just a different list.

40:40.660 --> 40:46.080
Only if we're as creative and smart on the sort of long term with some implementation.

40:46.080 --> 40:47.100
Thank you.

