start	end	text
0	1200	All right, thanks Jeff.
1700	5040	We're here to talk about temporary credentials, right?
5280	6400	Here's a little bit about me,
6400	8940	but problem is I've got about four hours of workshop content
8940	10940	that I squeezed into 32 minutes of talk,
10940	12100	and we got 29 now,
12100	14240	because Jeff took a minute out of my time.
14240	14900	Thanks a lot.
14900	16460	So I'm gonna talk at one and a half speed, right?
16460	18780	So listen quickly, you know, wake up.
18780	20820	If you leave in the middle, I'm gonna be pissed, right?
21140	23260	All right, so let's get to it.
23260	25140	Basically, to understand temporary credentials,
25140	27260	let's just jump into a simple attack scenario.
27340	29280	So I've got a recorded video.
29280	30600	Let's just go through that.
30620	31920	Then let's switch to defender viewpoint
31920	34360	and see what the heck difference it makes, right?
34360	36180	And the whole premise is it makes some difference.
36180	38100	Both sides need to consider it.
38100	40460	And then we'll wrap up with do's and don'ts, all right?
40660	42360	So here's the basic scenario.
42360	43380	Nothing super fancy.
43380	45080	All you guys, I'm sure, have encountered worse
45080	46180	or done worse,
46180	49240	but we're basically gonna start with a compromise key.
49240	51160	We're gonna generate a temporary credential,
51160	52380	more for backdoor access,
52380	54060	though I could use it right off the bat.
54360	55980	Then I'll use that to escalate privileges
55980	58740	and get access to a bucket, right?
58740	61060	Okay, so let's move on.
61060	64100	So here we'll start the demo and I'll talk you through it.
64100	66000	Promise it's not huge.
66000	67480	We'll start with credentials.
67480	68680	And as we all know,
68680	71220	it's not hard to find credentials these days.
71520	73380	Whether you're on Pastebin,
73380	75180	you got GitHub check-ins,
75180	76420	you've got Gist,
76420	79100	and of course you're harvesting or taking them, right?
79100	81080	Plenty of malware still doing that.
81080	83240	So that's not a problem.
83240	84580	We've got a temporary credential.
84580	87760	And for those of you who've worked with access keys,
87760	89360	API keys, it's pretty much the same.
89360	90500	I said environment variables,
90500	92020	cause I'm gonna show CLI,
92020	96240	but this is my compromised credential and starting point.
96240	97800	All right, so let's continue on.
97940	99780	So first thing I'm gonna do,
99780	101900	I'm gonna immediately generate some temporary credentials.
101900	103900	This'll make more sense as we get into the fact
103900	106480	on the defensive side.
106840	108600	I'm showing command line.
109320	111300	Normally I'd run some Python code,
111300	112320	but command line's good,
112320	114800	nice and concise and fairly descriptive, right?
114800	117420	So get session token off the STS service.
117820	119860	If you can read the JSON,
119860	121900	just two fields are what you expect.
121900	124540	You get an access key ID and you get the secret,
124540	127640	which is what a normal access key looks like.
127640	129600	Then you've got the session token and expiration.
129780	132700	When I called it into the API, I set the expiration time.
132700	134240	We'll get into what those are,
134240	137740	but it can be up to 36 hours, minimum 15 minutes.
137980	138320	All right?
138320	140520	So right now at this stage as an attacker,
140520	143140	I've got backdoor access and we'll see why it's hard
143140	145520	to control and manage this from the blue side, right?
145520	146600	But I've got another credential.
146600	148100	I've got two, the compromised one,
148100	150640	and then right off the bat, I generated another one.
150640	152600	And functionally, it's pretty much the same.
152600	155900	99% privileges access, right?
156460	159220	All right, so let's continue on.
161480	163560	And well, I don't know anything about the environment,
163560	164980	so let's do a little bit of discovery.
164980	168180	So again, we're going to do a very simplified version.
168180	169320	Let me pause this here.
169740	172980	Bunch of CLI commands are very oriented to IAM.
172980	176040	I want to find out what user IAM, what groups,
176040	178300	what roles, what policies apply to me,
178300	180220	because I'm looking for escalation privilege, right?
180220	181060	Pretty basic.
181120	182740	I would normally enumerate a lot more.
182740	184100	Do I know EC2 instances?
184100	185400	Do I know what buckets are there?
185400	186440	Blah, blah, blah.
186520	190480	And so a lot of code out there to check yourself
190480	193100	as well as to utilize if you're on the red team side, right?
194540	196400	So nothing big and fancy.
196900	198280	I'm going to take a look at the output
198280	200380	and pull just some of the salient pieces.
200840	203660	And so I can barely read my screen,
203660	206280	but at the top, right, I had an access key.
206280	207880	Oh, it's JenkoTempUser.
207880	209160	That's the actual username.
209160	211220	I've got the account ID, super useful.
211220	212900	I'm going to be exploring the environment.
212900	215140	I'm going to need this in other API calls.
215420	217600	Basically, I start to look through this,
217600	220080	and I mean, no one reads JSON in their sleep.
220080	221840	This is a pain in the ass, basically, right?
221840	223260	But the point is I'm looking
223260	226220	for what policies are attached right off.
226220	227800	And boom, I start to see stuff
227800	230780	that hints at bucket roles, right?
230780	232000	And assuming bucket roles,
232000	233900	which is an elevation, right?
233900	238020	It's our cloud version of sudo wrapped in some other stuff.
238020	239920	So let's just keep going and taking a look,
239920	242520	because basically at the end,
243040	244640	there's a lot of verbose information,
244640	247060	but basically I can assume a role, right?
247060	248900	The user that I've compromised credentials
248900	250680	can assume this bucket role,
250680	253860	which has a policy and there's a JenkoBucket6.
253860	255540	And so I'm happy.
255540	257120	Man, this looks interesting.
257120	258180	Now it's only one bucket.
258180	259140	You can see the policy,
259140	260300	but it's a little bit wide open
260300	262840	because it's S3 colon star.
262980	265260	So you could argue Blue Team's done
265260	268300	maybe a little bit bad of a job here,
268300	269280	but it's not horrible.
269280	271400	It's one bucket and all the objects there, all right?
271400	273940	Maybe it's a support guy that I got keys off of
273940	275960	or something like that, a dev engineer.
276460	278100	All right, so now that I've got
278500	280520	a little bit more information,
280520	283860	basically all that JSON I've tried to distill,
283860	285900	what are the important relationships, right?
286460	288020	You think our discovery tools
288020	289740	could visualize a little bit better.
289740	292080	Basically we're saying, look, I've got a compromise key.
292080	294980	I'm going to call it A instead of the 50 characters.
294980	296520	So we all know what we're talking about.
296520	298320	That key that was compromised,
298320	300180	I found on, let's say, Pastebin.
300180	304980	I used, and I know it relates to JenkoTempUser.
304980	307660	It was created underneath that user.
307800	311400	It happens to be able to assume role, right?
311440	312920	To a bucket role.
312920	313920	Man, these guys are next door.
313920	315420	We got to tell them to be quiet.
316000	320360	And that has access to this bucket, JenkoBucket6, right?
320460	324760	That's basically the path that we're going to exploit, right?
325100	326800	With what looks like to be a hole
326800	329240	in escalation of privileges here.
329240	331280	So just to test though,
332380	334900	I did try to access the bucket directly
334900	336680	with my compromised credentials, right?
336680	338680	There's a hint that I have to escalate privileges,
338680	340280	but let's just make sure that bucket's not public
340280	341560	to begin with, right?
341560	343040	I mean, so why bother?
343040	343680	Let's go after it.
343680	348220	But I can't, I got an error just doing an LS on the bucket.
348220	350920	So great, let's then think about the exploits.
350920	352160	So taking that relationship,
352160	355300	the actual exploits more in terms of API and flow
355300	356940	more looks like this, right?
356940	359520	You're basically going to make a call
360160	364620	to the STS service doing an assume role.
364620	366420	And the way that works is you receive
366420	369420	yet another new temporary credential,
369420	372380	which when used takes that assumed role
372380	375140	in terms of permissions, right?
375540	378740	Then you're going to use that with your regular API calls.
379040	380740	Great, pretty easy.
380740	382420	Sounds pretty straightforward to me.
382660	385700	Real scenarios, there's a million of things, right?
385700	387580	We might be going after EC2 instances.
387580	388940	We might go after logs.
388940	390980	We might be putting in lambdas.
391000	392220	We'd be doing a bunch of things.
392220	393560	Right now it's super simple,
393560	396280	but everything we talk about today should apply, right?
396560	398280	In terms of temporary tokens.
398280	399320	So let's keep going.
401740	407740	So next thing I'm going to do is actually assume role, right?
407740	409080	So if you can make out the command line,
409080	413480	basically another call to STS and assume role.
413480	415780	And what I get back, again,
415780	418780	just looks like another temporary credential, right?
418780	420560	Same thing as my first attempt.
420560	422700	My first attempt gave me a little backdoor count.
422700	425380	Now I have assumed role and I get another temporary credential.
425380	427760	Let me call it A prime because I used,
427760	430740	you know, the original compromised credential A
430740	431960	and that I'm calling A.
431960	434680	And this gives me an A prime with elevated privileges.
434800	437460	Great. Set some environment variables if I want to use it,
437460	441720	but for the actual next step, copy, paste.
441720	443140	I'm going to use a CLI.
443140	447680	And now when I do the actual bucket command,
447680	449320	boom, comes back, right?
449320	450260	Makes sense?
450260	454020	Basically on the left, I've just fulfilled that whole path.
454040	456080	So no big deal.
456080	459200	And unfortunately, it's like, if you want to do CLI,
459200	460580	it's not that bad to do it.
460580	463740	If you're doing Python, you'd wrap in a few Python commands.
463740	465840	And all we've shown is that we started
465840	467780	with compromised credentials and we escalated.
467780	471700	So, so far, nothing big, strange and new, right?
471700	473660	I did generate temporary tokens.
473920	477180	So we're going to now flip to the defender side
477180	479600	to see what difference this all makes, okay?
482740	483180	So...
483800	484600	Ahem.
488800	490220	Sorry, reset here.
490220	492520	So let's go to the defender viewpoint.
493200	495940	So basically, put on your blue hat for a minute.
495940	499220	We've had an incident like we just went through, right?
499220	500340	You're catching up with it.
500340	501600	You're at least 20 minutes late
501600	503460	because we all know CloudTrail has a lag
503460	504800	that they document, right?
504800	506720	15 minutes to get the API logged
506720	508440	and five minutes at least to get to the bucket.
508440	509100	You're already late
509100	511360	by the time you pick it up out of CloudTrail.
511620	512240	Okay.
513080	516100	But your team is not terrible.
516100	517720	You've got AWS experience.
518160	521220	You've got logging in place, some kind of alarms,
521220	523300	CloudWatch, your SIM, whatnot.
523520	524640	You got a little bit of a gap though.
524640	526460	You haven't really studied up on temporary credentials.
526460	528260	So we're going to go through and sort of,
528260	531360	with me and you putting on your hats,
531360	533280	try to see what effect this makes.
533480	534700	So what's our starting point?
534700	536540	Well, you know, two obvious ones.
536540	539700	Someone tells you from outside that your data's up on GIST
539700	542260	or whatever financial information or something, right?
542260	543140	That happens.
543140	546420	Or maybe our venting is good enough that you get alarms.
546420	547880	So let's just say we're competent enough
547880	548960	that we actually picked this up
548960	550720	in a reasonable point of time.
550860	554740	So let's go back to the same kind of flow and architecture
554740	557340	and try to, let's go through a reasonable scenario
557340	560380	from the blue team side while we're catching up.
560380	561480	Did we detect it?
561480	563180	Well, yeah, we probably did.
563180	566580	Maybe the data exfil stage was a reasonable point, right?
566580	569200	I think maybe the action of copying
569200	571040	however it was done was suspicious
571040	573260	and you had filters on that.
573260	575560	Maybe the destination was definitely suspicious,
575560	577900	either another bucket that you weren't expecting
577900	579340	or an IP address that was strained.
579340	580760	So I think that's reasonable.
580900	582880	Maybe you did pick up the privilege escalation,
582880	584840	but I would say in this case, it's hard
584840	587700	because the sort of scenario I painted was
587700	590520	there's a valid maybe support role
590520	594540	that could be assumed to maybe support that bucket, right?
594540	596300	The problem really is compromised credentials.
596300	599140	It wasn't that this role shouldn't be there, right?
599140	600600	So I'm gonna say two is questionable
600600	602860	whether you picked up the privilege escalation.
602860	603840	That might be hard.
603840	606180	Of course, you might not be just looking at events.
606180	609280	You might have correlation anomaly detection in place.
609280	610020	I think that's fair.
610020	612100	That might've picked up some strange behavior.
612280	614360	But either way, we're off to a decent start
614360	618120	in that we were reacting reasonably fast.
618820	621380	All right, where does it start getting interesting?
621380	624060	So one, we're starting with the logs.
624060	626860	That's pretty much our main starting point with anything.
627040	628680	And so as we pour through the logs
629060	631760	to try to catch up with some notification we got
631760	633540	that something suspicious is going on,
633540	634840	here's CloudTrail.
634860	636980	I added some highlighting so we could all talk about it.
636980	639580	Up top is what I call access key A.
639580	641000	That's the one I started with,
641000	642780	the compromised credential, right?
643140	645420	This is when I use it to assume role
645420	648020	and get back another temporary key
648480	649600	with an elevated privilege.
649600	650980	So you see assume role.
651060	655060	And then in the response, you see that temporary token,
655060	657640	which I'm calling A prime, right?
658360	661080	Okay, this is where you're starting to look at
661080	662600	what the heck's going on, right?
662600	665300	And you're trying to go back and trace to the source
665300	667520	and shut off every little gateway.
668020	671600	So really, your analysis might, I think,
671600	673240	reasonably lead to, look, the roles
673240	675540	and the bucket access was okay.
675780	679280	I'm gonna drill that user, Jenko, whatever his name is,
679280	681880	and say, look, are you doing something bad
681880	683480	or are you just careless and losing your key?
683480	685100	And let's just say it was carelessness
685860	686760	through the interview.
686760	688660	And we say, look, it's a compromised key issue.
688660	690240	Let's handle it that way, right?
690240	691680	So we move on to mitigation.
691840	695040	We delete that access key, which was the one that I got,
695040	696320	or make it inactive.
697220	699560	Maybe set him, if he deserves it,
699560	700480	set him up with a new key,
700480	703880	but really focus on key rotation and other practices.
703940	705500	Definitely change the console password
705500	708160	and send that guy to training, right?
708160	709960	Or whatever is appropriate, right?
709960	712960	Maybe these are parts of a reasonable step.
713640	716860	So, you know, GUI has it, CLI, no big deal.
716860	718500	This is probably in your playbook.
718540	722180	Now the problem is we close off this incident,
722180	723960	but we're smart enough to keep looking through the logs
723960	726020	because we're just wondering what the heck happened.
726020	729400	So we pick up another event and here it gets interesting.
729400	731860	Here's where sort of blue thinks this might be different
731860	733340	than what they've seen before.
733340	734820	Maybe, but they don't really know.
734820	735820	They see get session token.
735820	736880	What the heck is that?
736920	737980	Not too familiar with it.
737980	739940	It's a STS, gotta go read up on it.
740120	741820	This is the part in the text scenario
741820	744280	where second step or first step,
744280	747020	I just generated backdoor set of credentials, right?
747020	748560	I'd probably do it for 36 hours.
748560	749880	And the demo is 900 seconds
749880	751080	because I don't trust any of you guys
751080	753100	just in case you're logged in, right?
753100	754740	To try to see if it's active, right?
754740	757520	But really I would have given myself 36 hours, right?
758080	760980	Here, defender might not be an expert,
760980	762680	but this is raising their hackles.
762680	765240	They read up quickly in five minutes, STS doc.
765240	767720	This is another access key, A prime.
767860	769260	The heck, I shot one off.
769260	770540	Now I gotta go worry about another one.
770540	773040	Hey boss, not quite over yet, right?
773040	774440	We're still working it.
774720	777440	So let's just pause for a minute
777440	779820	and explain any differences with temporary tokens.
779820	782500	You read up another hour on this if it's first time
782500	786180	or two or three, because the doc is pretty messy.
786980	790560	It's 15 minutes to 36 hours, which is an eternity.
791020	792480	On top of that, you're late
792480	796580	because CloudTrail is not anywhere near real time.
796580	800440	You're 20 minutes, I think, if you're lucky on top of that.
800440	801540	So they've got a headstart.
801540	803000	If they're smashing and grabbing,
803000	806440	they're maybe done by the time you see the event, right?
806440	807300	If they know what they needed,
807300	809160	they don't care if you pick it up.
810220	811640	There are some nuances.
811640	814180	Temporary credentials are used when you start up services,
814180	816980	often passing, assuming a role for an EC2 instance
816980	820040	to get proper privileges and AWS manages that.
820040	821620	So those tend to be an hour.
821620	823200	But if you compromise an EC2 instance
823200	824580	and grab that temporary token,
824580	826660	you more have an hour timeframe,
826660	828320	but it gets refreshed automatically.
828320	830320	So if they haven't detected you, you just keep grabbing it.
830320	832860	So there's all these nuances.
832860	836340	API access, 99% the same as a permanent access key.
836420	837320	A little bit of a difference.
837320	839840	You can't regenerate a new temporary token
839840	841620	off of a temporary token, right?
841620	845080	They're not quite that loose on the AWS side,
845080	847360	but you can, and you have to assume roles.
847360	848780	So escalation of privilege is key
848780	853080	to sort of long-term use of temporary tokens for that.
853080	856000	As we said, assuming roles and escalation of privilege
856000	858400	is not a big barrier.
858760	860960	The infrastructure is way too complicated.
861180	863960	And if you need some thinking on that,
863960	866160	love Rhino, they share a lot.
866160	868440	There's plenty of things on their blog
868440	871500	about the next dozen escalation of privileges.
871780	873500	And it's pretty, pretty scary
873500	874900	when it goes through other services
874900	876080	that you're not even thinking about,
876080	878400	like DynamoDB, hey, we never deployed that.
878400	878760	What do you mean?
878760	880960	You can go through that and maybe escalate privileges.
880960	884260	Okay, now that we're a little bit more knowledgeable
884260	886000	on the blue side about temp tokens,
886000	887640	let's revisit our whole process
887640	888960	and just see where we're short.
888960	891440	Because I still have an active key out there, right?
891440	895060	Maybe it hasn't been used, or maybe it is being used.
895060	896560	Either way, I gotta do something about it.
896560	897900	I mean, I'm aware of it
897900	900040	because of one event in CloudTrail.
900420	901600	Here's the problem.
901820	903700	Number one, it's untracked.
903740	905900	What I mean by that is there is no listing
905900	908580	of currently active or even historically generated
909100	912340	temporary tokens, at least not easily
912340	913800	in a form that you can do.
913800	916480	Your best bet is you could parse it out of CloudTrail.
916960	921060	But really what you want is a listing somewhere in the GUI
921060	923480	or the CLI and API call to say,
923480	926300	what the heck, temporary tokens have been generated.
926380	927840	When do they expire?
927840	929480	Click, cancel.
929480	931280	You don't have that, all right?
931280	932920	So bad news.
932920	935880	We're not getting a good feeling as we think about this.
935880	936920	Let's think about detection
936920	938960	because we are in CloudTrail land.
939440	940840	Number one thing you gotta do,
940840	943620	you're able to deal with it because you do get logs,
943620	945820	but it's a little obscure and confusing.
945820	947340	Focus on creation of tokens
947340	949160	because you just don't want tokens out there
949160	950580	that you never knew about.
950580	952720	So creation is looking for get session token,
952720	955780	which is what I did in the first step,
955780	960500	or any assume role will generate tokens underneath.
960500	963320	The problem is assume role happens all over the place.
963460	966160	So when you have federated identity, single sign-on,
966160	967840	you got temporary tokens.
967840	969420	So the problem is it's noisy.
969420	972040	So false positives are gonna kill you, right?
972040	973760	Get session token is gonna be rare.
973760	974980	Focus on that.
974980	979020	Assume role, boy, if you can escalate privileges,
979420	982120	on the red side, you're hiding, right?
982220	987300	But basically get your tracking with CloudTrail,
987300	988920	CloudWatch, your SIEM,
988920	990720	and make sure you got your filters on.
990720	993220	Focus on the usage, of course, as well.
993220	994860	This is not clear at all.
996160	998900	When you look at the JSON minus my red highlight,
998900	1001160	there's no obvious attributes saying
1001160	1002760	this is a temporary token.
1003080	1004160	But there is a naming convention
1004160	1006140	if you've been good enough to find it.
1006140	1009820	It took me a long time, but AWS says
1009820	1013120	if it begins with Asia, A-S-I-A, it's temporary.
1013120	1014860	A-K-I-A is permanent.
1014860	1017640	So you can do a regex or glob in your filter.
1017640	1018400	Do it.
1019460	1022840	And they publicize it, so hopefully it's at least stable
1022840	1024320	and they won't break that, right?
1024320	1025740	You gotta know when they're used.
1025740	1026800	You can figure out what to do with it,
1026800	1028240	but you gotta have some eyesight.
1028440	1030660	So let's keep going here.
1031220	1033960	Really, being aware of it's one issue,
1033960	1036000	you've got some ability through logs,
1036000	1037320	you gotta do something about it.
1037320	1040000	Here is where it gets worse and worse, okay?
1040000	1042020	So let's think about our normal reaction
1042020	1044480	when we did the permanent compromise key.
1045000	1046660	Let's delete it, make it inactive.
1046660	1047620	You cannot.
1047800	1051500	You can't even see it in the console,
1051500	1052700	so you're not gonna do it there.
1052700	1054880	And there is no CLI API command
1054880	1058100	to revoke or delete a temporary credential.
1058100	1059340	There is not.
1059340	1062600	And I think AWS is even public about that.
1062940	1064220	What do they recommend?
1064220	1067300	Number two, restrict the role
1067300	1069320	that governs that temporary credential,
1069320	1071300	which is the Django temp user,
1071300	1074380	like reduce their permissions or blow them away.
1076060	1078700	If it's one user, sure.
1078960	1081740	If it's a lot of tokens that you're using
1081740	1084920	because IOT uses temporary tokens,
1085860	1087880	what's the impact on the organization
1087880	1090860	that's running an app with thousands of endpoints
1090860	1093780	and clients that are suddenly invalidated
1093780	1096900	because you blew away a user account or role?
1097360	1098760	It doesn't make it easy.
1098760	1100820	You have things, but you have to think about it.
1100820	1103180	So really, number three is,
1103180	1105320	there's some things imperfect,
1105320	1107140	but they're not nice and clean,
1107140	1109380	but you gotta rethink your playbook.
1109380	1111720	You got probably a playbook for compromised accounts,
1111720	1115600	both console login and permanent access keys.
1115600	1118120	You gotta see if you've got one for temporary tokens.
1118140	1119100	And you gotta go through that
1119100	1120580	and see what the implications are.
1120580	1122540	Because if you end up at number two,
1122540	1124600	that's not something you wanna do in the middle of the night,
1124600	1125820	in the middle of an incident, right?
1125820	1128580	Hey, let's see what this does.
1128760	1131640	You know, stop the bleeding, but the patient's gone anyway.
1131640	1133100	So what the heck, right?
1133540	1135740	There is some hope.
1135780	1138720	You're not completely without means.
1139000	1141520	So if it was an assume role action,
1141520	1143220	which we did in this scenario,
1143220	1145180	that elevated role,
1145180	1149120	you have an ability to cancel or revoke active sessions.
1149620	1154720	So it's in the GUI, it's a fifth tab, it's right here, okay?
1154780	1156920	It's sort of faking it, I gotta admit,
1156920	1161800	in the sense that it doesn't really revoke the token.
1161900	1164100	It puts in place a deny policy,
1164100	1165700	look, it's all wildcarded,
1165700	1169220	with a condition that keys off of an attribute,
1169220	1171680	and finding those attributes, of course, is impossible.
1172100	1176160	But there's a creation time on the temporary token,
1176160	1178880	and you basically put in today's date
1178880	1180640	at the time you're looking at it.
1180640	1182980	And basically, the thing that was created in the past
1182980	1187120	by the attacker will be denied by this policy.
1187600	1189780	So hey, it's good for mitigation,
1189780	1191180	but it doesn't solve it, right?
1191180	1191980	Because guess what?
1191980	1194400	The temporary token still works.
1194540	1196640	And if they can find another way to assume role
1196640	1198060	and escalate privilege again,
1198060	1199600	they're gonna be in your face,
1199600	1200680	and you're gonna have to come back again
1200680	1202660	and update this policy, right?
1202820	1205680	But hey, we'll take what we can get, right?
1205820	1207280	Let's not deny that.
1207280	1210480	So let's try to step away from the fire drill.
1210480	1212760	Let's just say, for better or worse,
1212760	1216440	we're able to nail or restrict this temporary credential
1216960	1218080	that's been hanging around.
1218080	1220140	So we got a minute to pause, but we're not feeling good.
1220140	1221080	How do we actually prevent this
1221080	1222780	from happening in the first place, right?
1223240	1225480	Well, your first thought, at least mine is,
1225480	1227700	can't we just lock down in some permission schemes
1227700	1230980	and use all API calls that create temporary credentials?
1230980	1232400	You can't with GetSessionToken.
1232600	1234880	You can do stuff with assume role,
1234880	1237320	but you cannot do it with GetSessionToken.
1237420	1240860	And clearly, it's not just me saying that and testing it,
1240860	1244680	which is true, it's an AWS by design thing.
1245220	1247680	Some engineers thought hard about this,
1247680	1249780	and they said, look, GetSessionToken
1250240	1252560	is a part of our authentication,
1252560	1253580	and nothing restricts that.
1253580	1256180	You gotta let people attempt to log in.
1256180	1257380	Doesn't make any sense to me,
1257380	1260040	but that's what you find in the doc, all right?
1260040	1262440	So if your boss needs an explanation on BlueSide,
1262440	1264620	you can go point him, yeah, that's what our CSPs know.
1264620	1266400	They took their shared responsibility.
1266780	1271280	Okay, sorry, was that a bad burn there?
1271280	1274080	Okay, so we can't prevent GetSessionToken.
1274080	1275020	How about MFA?
1275020	1276380	Same reason, can't do it.
1276380	1277760	Can't restrict with MFA.
1278180	1280680	They consider this like the first step of the auth.
1281180	1282840	You can't do permission boundaries,
1282840	1284980	which specify max permissions
1284980	1289380	for, right, the sort of maximum permissions
1289380	1291560	could be assigned to an IAM user.
1291560	1293040	Try it, doesn't work.
1293040	1295720	I mean, they'll allow you to enter it, won't do anything.
1296720	1299960	If it's assume role, you can restrict that.
1299960	1303640	It's post-authentication in their minds, and you should.
1303640	1305180	And we did in that scenario.
1305180	1306980	We restricted it to some support guy,
1306980	1309020	Django temp user, and he blew it.
1309040	1311800	So you should still do it, minimal privileges,
1311800	1314440	but again, this is not a silver bullet.
1315060	1319700	And you do have the revoke active sessions for any role.
1319700	1321460	Again, assume role path,
1321460	1325360	but that's really mitigation, my, my, not really prevention.
1325360	1329400	So the problem is, we've got a temporary token feature,
1329400	1331940	which is sort of obscure to detect in the first place.
1331940	1333060	And while it's being used,
1333060	1335420	you don't have a direct way to cancel it.
1335540	1336880	But in your mitigation procedures,
1336880	1339120	you have some in some cases.
1339160	1342180	And then in terms of lockdown and prevention for the user,
1342180	1345060	you also don't quite have stuff.
1346000	1347780	So this is what you're dealing with, right?
1347780	1352300	This, this is sort of the story with temp tokens.
1352600	1355460	And I guess I've been talking at 1.5x speed.
1355460	1358140	So we got about seven minutes, Jeff, by my time.
1358140	1359580	So I've got two more slides.
1359580	1361340	So we might even be able to squeeze in a question.
1361340	1362780	Otherwise, out, out front,
1362780	1366960	I'd be happy to pursue more, more discussion.
1366960	1369360	So let's, let's talk about sort of the wrap
1369360	1370800	of do's and don'ts.
1371480	1374480	And for anyone who's red teaming,
1375160	1376960	pentesting, researching anything,
1376960	1380520	my view is why not generate temp credentials
1381080	1383900	immediately for every account you have access to,
1383900	1385620	at a minimum for backdoor access.
1385620	1388720	It's true, if they're savvy, they might pick that up,
1388720	1390500	your get session token call.
1391120	1392540	That's okay.
1394780	1397360	What's more interesting is not just using
1397360	1398800	those temp credentials,
1399660	1401980	but combining it with all the other techniques
1401980	1404040	you might use on the red team sign.
1404040	1406200	So pre-signed URLs are nothing super fancy.
1406200	1408440	If you use them, you wrap in a URL,
1408440	1410220	it's pre-signed and you can download,
1410220	1412080	but also upload data to a bucket.
1412080	1413440	It's just the convenience.
1413520	1416440	Instead of having, you know, two or three lines of code,
1416440	1417540	you can have a URL.
1417600	1419900	But I sort of wonder, well, hey,
1419900	1422380	how about a phishing campaign with a bunch of URLs
1422380	1426040	that mucks with buckets of, you know, some, some account.
1426040	1427680	That might be sort of an interesting thing
1427680	1429720	and more a distraction to obfuscate
1429820	1431160	a bunch of other activity.
1431340	1434280	Lambdas, certainly the point is,
1434280	1436620	whether you attack logs or use lambdas,
1436620	1439900	the trail will end up at a temporary credential,
1439900	1443200	which if my premises holds water,
1443200	1445620	it's going to be harder to deal with temporary credentials
1445620	1446700	for the most part.
1446700	1448500	So why not add an extra layer of friction
1448500	1450460	to the whole thing, confusion.
1450740	1452680	But another way to look at it too,
1452680	1454500	is you could use something like lambdas
1454500	1459160	to facilitate persistence of your temporary credentials,
1459160	1459320	right?
1459320	1462060	It expires in 36 hours, the max.
1462060	1464920	If you do escalate privileges and have access to lambdas,
1464920	1467780	why not put a hook in to create user,
1467780	1470380	modify user somewhere in there.
1470420	1472320	And every time that happens,
1472320	1473560	generate new temporary credentials
1473560	1476860	and put it to a public bucket that you pick up later, right?
1476860	1478140	Just why not?
1478140	1481320	And it just, just makes everything more obscure,
1481320	1483460	harder to track, harder to figure out.
1484500	1487220	For sure, in your discovery,
1487220	1488500	you're probably looking at logs
1489070	1491480	and you could ascertain whether
1491480	1494300	they're specifically looking for temporary credentials.
1494300	1497980	If they're that knowledgeable and ready,
1497980	1499980	I mean, nothing lost, but you at least know.
1499980	1500900	And if they aren't,
1500900	1503160	well then everything above first three bullet points
1503160	1507040	is just going to be easier, more impactful, right?
1507040	1509860	So that's the sort of, you know,
1509860	1512520	attack mindset with temporary tokens.
1512520	1515580	Now let's try to end up on the blue side
1515580	1516760	and see where we're at.
1516760	1519560	So number one, no matter what you take away from this talk
1519560	1523120	is if you never heard of temporary tokens,
1523120	1524100	I don't want to say that in a bad way.
1524100	1527000	If you haven't spent time on it, do it,
1527000	1528760	get your plan in place, just revise it.
1528760	1530720	If you have, good for you,
1530720	1533700	but I would still suggest reviewing it
1534480	1536500	because the APIs change all the time.
1536500	1537900	And, you know, you're not sure
1537900	1540500	what tools are available for you.
1540500	1541100	Who knows?
1541100	1544180	We'll probably get a revoke token API call at some point,
1544180	1546560	right, if there's enough abuse.
1546560	1547720	Talk about prevention.
1547720	1549240	A lot of things I already covered.
1549340	1551200	Yeah, you're going to lock down access keys.
1551200	1552980	You can't prevent the temporary credentials,
1552980	1554460	but you can try to minimize the impact
1554460	1557020	once they're used or in your environment.
1557020	1558820	So minimal privileges everywhere.
1559300	1560480	You could isolate,
1560480	1563180	if you have to use temporary credentials for some reason,
1563180	1564900	like some business application reason,
1564900	1566100	isolate in a separate account
1566100	1568000	because cross-account access
1568000	1571100	can be controlled no matter what, right?
1571100	1573380	So that's a way to sort of,
1573380	1576460	because it comes through an assume role path, right?
1576460	1579300	So thinking about your org structure,
1579300	1580840	your account and org structure
1580840	1584000	is pretty important to dealing with messy stuff
1584000	1585680	like temporary credentials.
1585680	1587380	Minimal privileges, so on.
1587380	1588440	Detection.
1588440	1589460	We went through that.
1589460	1591080	Focus on get session token.
1591080	1593920	Think about assume role, if that's noisy or not.
1593980	1597720	Pick up the usage with the ID scheme,
1597720	1601140	the ASIA, and obviously harden like heck
1601140	1603300	and test your logging,
1603300	1605300	because if you're hosed on logging,
1605300	1606440	then all of this doesn't matter.
1606440	1608380	You have a lot worse problems.
1608380	1609560	Mitigation remediation.
1609560	1611080	The hardest part last.
1611080	1612220	You don't have great things,
1612220	1614280	but review your playbook.
1614500	1617480	Don't use get session token if you don't need to,
1617480	1620100	because then it's easy to pick up true positives
1620100	1621600	out of the logs.
1621600	1623100	Any use of get session token
1623100	1626220	is immediately worth investigating, right?
1627720	1629840	Use assume role because you can control it,
1629840	1631620	but it's really noisy, right?
1631900	1634320	But it allows you to revoke those active sessions, right?
1634320	1636320	Gives you some mitigation means.
1637320	1638940	Recovery, I can't stress enough
1638940	1643040	because I think we may be focused on mitigation.
1643260	1644520	You guys are probably better,
1644520	1647560	but it's great even if you can manage
1647560	1650080	and kill and restrict the temporary tokens,
1650080	1652580	but how do you get the apps back and running?
1652580	1654680	Because you might have blown away user accounts.
1655320	1658640	And then finally, last step is really first,
1658640	1659620	probably in your process,
1659620	1661920	it's before you get into real-time ops,
1661920	1664020	it's more did you plan and provision
1664020	1665440	and manage your inventory?
1665780	1668200	I think if you do have a good business case
1668200	1671160	of creating temporary tokens for some application,
1672280	1674900	then you're in control and you should log it,
1674900	1677280	even if not log it, you should put in a database,
1677280	1679020	even if AWS doesn't,
1679020	1681020	because then you'll know what you've created
1681700	1684560	and you'll have more context at a minimum
1684560	1687700	when they're abused or compromised.
1687860	1689960	But you're not in control of everything,
1689960	1692820	so assume role and what AWS does,
1692820	1695460	when you run an EC2 instance and pass along a role,
1695460	1697740	boom, there's a temporary token created,
1697740	1701080	it's in the user metadata of the EC2 instance,
1701080	1704200	you didn't create it and people exploit it all the time.
1704200	1706600	So there, your only choice is to go to the logs
1706600	1709940	to see, look at, assume role creation
1709940	1714580	as well as usage and see that key pop up, that ASIA key.
1714720	1717400	But again, that would be valid activity in a lot of cases,
1717400	1719240	so imperfect, right?
1719380	1725560	So net-net, I don't have all the answers by any means,
1725560	1727240	I have more questions than that,
1727240	1729820	but I think it's to elevate the importance of this
1729820	1733080	as whatever perspective, you gotta pay attention,
1733080	1734220	even if you haven't been paying attention,
1734220	1735560	you gotta re-look at it.
1736900	1737780	Thanks.
1737780	1738800	Thank you.
1738800	1739620	Thank you.
