start	end	text
0	6080	But yeah, let's get the show started. Build to hack, hack to build. Who am I? My name is Chris.
6080	11200	I'm a security engineer at Heroku. We're pretty much remote code execution as a service. If you
11200	14860	don't know what I'm talking about, go look at the platform and you'll see what I mean.
14940	20400	Find me on Twitter, Brompony. But yeah, I like hacking stuff. I like building stuff. I am lazy,
20400	24880	so I build stuff that helps me hack stuff quicker. Whether it's web, Windows, Android,
24880	28920	and recently I've been looking at containers. They're a lot of fun. So this is what we're
28920	34940	gonna look at. Problem, some existing research. I'll introduce to you Bob. So it's Bob with a
34940	40360	silent T. And we'll look at some stuff that Bob can do. And yeah, this slide's more for me just
40360	44020	to actually remind myself what it is that I actually share with you today. So we might
44200	50380	deviate a bit, but I'll try to bring it back in. So what are the problems? So in a modern cloud,
50380	55480	DevOps, SDLC, Agile environment, there was one big question that I had to ask myself
55480	59940	quite often was, how do we identify and exploit container vulnerabilities? So if you're a pen
59940	62920	test, or if you know, you got a shell in a box and you want to break out, you want to
62920	67300	pwn some stuff, you know, how do you identify and exploit container vulnerabilities? But then
67300	71820	in an engineering environment, how do we test, secure, and monitor our containers? So I come
71820	76800	from a red teaming consulting background, and I do more engineering. So I'm constantly trying
76800	81160	to break our platform. And when you've got thousands of containers, and you don't always
81160	84920	want to pop shells and stuff, how do you do security at scale? So these two questions are
84920	89820	very much aligned, but they're pretty much asking the same thing, which is how do we
89820	94040	basically identify and pwn stuff, and break out of containers? So in terms of existing
94040	99660	research, these are just categories of types of tools. This list is by no means complete,
99660	103240	but if you're in a terminal, you got a shell, and you want to find out if you're in a
103240	107580	container, am I contained? Identify as the SACCOM, CAPS, LXE, or Docker environment that
107580	111220	you're in, and it will tell you, very important. Then there's a whole bunch of Google
111220	114580	container tools. I highly recommend you look at their repo. Great stuff in terms of static
114580	121600	analysis for container images, be it a Docker or an LXE image. Clay is really good, if you
121600	124960	want to look for vulnerabilities in images, it's a really great tool. And when it comes
124960	128560	to benchmarking, Aqua Security has done a lot of good work there, if you actually want
128560	134040	to benchmark your images and your security controls that are in place. Now you'll see
134040	140260	that from this list, there's not really much there in terms of actually breaking out and
140260	147060	pwning containers. So, I came up, I had this problem that I experienced, that was the
147060	152240	existing research that I had, so generally when I like to solve a problem, I like to just
152240	158260	pwn everything if I can, so that's why I did Bob, you can find it on GitHub, it's written in
158260	161780	Go, yeah the hipsters were doing it, so I figured let's see why the hipsters are doing
161780	165720	everything in Go, I'm gonna, slightly ironic by my hat and beard, but you know I'm in
165720	172500	denial. So basically like I said, I'm lazy and I just wanted something, you know when you're
172500	176820	writing the same exploits over and over again and doing the same breakouts, you know, you
176820	181040	kind of want to automate that stuff. So Bob will give you the ability to auto-pwn, so
181040	186460	these kids are gonna love that, sorry I had to say it, but it's definitely a thing. Also
186460	191180	helps you do not only breaking out of containers, but think Linux post exploitation, when
191180	194140	there's a lot of things that you want to do when you get into it, you want to automate it, so
194140	198320	Bob will help you do that. And of course you can do all these things in a pentastic kind of
198320	202900	way, so if you want shells, you get shells, but if you also want to, you know, help your
202900	206520	engineering environment, so set things up with turn codes and plug into your CR
206520	210700	environment, Bob's also designed for that, and I'll show you what I mean by that. So that's
210700	215220	Bob, like I said we're gonna be pwning stuff. When you're pwning containers, the
215220	220320	hollow world of pwning containers is exploiting docker.sock, it's a Unix domain socket
220320	224780	that docker uses to orchestrate basically containers, if that thing is ever exposed, you find
224780	229920	it, it is game overs. So basically it comes from people wanting to use docker within
229920	234160	docker, don't do that, use that, there's better ways to do it originally, but basically this
234160	238380	allowed us to do a local privilege to root and basically break out of the container. It's a
238380	242440	really fun, you know, way to get into container exploitation. So how do you do it? What are
242440	246620	the manual steps? So first you gotta find docker.sock, so it's a Unix domain socket, it's
246620	251740	speaking HTTP, it's basically a RESTful API on a domain socket. Then you want to interact
251740	257040	with the socket with curl or a docker client or netcat. Once you find it and you can
257040	262580	interact with it, you then want to create a new container and mount the hosts up, uh, file
262580	267900	system in your container with the dash v command. Then run that new container and then
267900	272340	use chroot or chroot or troot as I found this week, there are multiple pronunciations for
272340	277760	that. Um, and there you go. You are then pretty much root on the host and you have access to
277760	281580	the host file system. And now you know if it's Linux and you access the file system,
281580	286100	everything's a file, it's game overs. So that's the manual step. Now you don't want to do
286100	291660	that all the time. Excuse me. But now things get a little bit tricky in containers.
292040	295700	Because when you're living off the land, especially in containers, the commands that you
295700	299280	need, for example the found command, might not be in the container. So if you're using
299280	302980	really minimal images like the docker image or the alpine image, that's the thing, you might
302980	306560	not have the tools to actually do the stuff that you need to do. Like what if there's no
307140	311920	ifconfig or ipadder. Sure you can read from procfs but this stuff can slow you down.
312360	315600	Especially if you need to find docker, uh, the docker socket. It's not always at
315600	320300	var on docker.sock, it could be at mu slash bob. If you don't have the found command, you
320300	324280	don't have recursive searches, how are you actually going to find the socket? So this is
324280	327520	where syscalls come in. So on the left there, those are the syscalls that the found
327520	332040	command makes use of. And on the right there, that's what bob does in go code to do pretty
332040	336800	much the found command. The nice thing about go is that when you start interacting uh, uh,
336800	340400	with the operating system, go makes use of syscalls. It won't actually make use of actual
340400	344440	shell commands. Some languages do that. So nice thing is, is that if the command isn't
344440	348400	there, you can use the syscalls and the syscalls will be there to allow you to perform the
348400	352820	actions that you want to do. So that, that's what we do with bob. And I'm going to show you a
352820	359280	demo now. Um, these are pre-recorded. I'm done doing live demos because I just ran out of
359280	365840	sacrifices all the time. Um, so what we're going to do here is, um, at the bottom terminal,
365840	368940	so I know it's a little bit small, but basically that's our host. And we're just going to
368940	374680	watch a directory on the host. Um, so you see there's one file called bob linux. In the top,
374680	378320	we're going to run in, in a container. So we're just saying a docker run and then we're
378320	385480	mounting a socket. Turn off the light. Yeah, unfortunately that's, can we turn the lights
385480	391680	down? Can we? No. Yes. Yeah. Unfortunately I can't make it bigger because the resolution
391680	404100	will go off the board. We can just break the lights. Ah. Ooh. A room full of hackers and you
404100	414060	just turn the lights on and you get that reaction. It's magic. So we're in a container now and
414060	418980	we're going to run bob. And you know, if you're inside a container, you want to find
418980	422680	socket. So we're just saying dash socket equals true. And now what Bob's going to do is
422680	427040	going to go and look for all the Unix domain sockets. Now you found a Unix domain socket.
427040	431220	What now? What do you do? So of course you want to auto-pwn this stuff. So I'm now
431220	436600	providing dash auto-pwn equals true. And what Bob's now going to do is it's going to look
436600	441280	for the domain sockets that it can find. And it's going to try and pop it basically. And
441280	446100	what you'll see now, Bob is now giving me a TTY. So this terminal that I'm in now is not
446100	450360	actually a terminal on the host. You'll see that that's a OSX host there. And I'm now going
450360	454460	to create a file inside a temp folder and that file is now going to appear at the bottom
454460	461520	terminal which is on our host. And we'll see that appear in a bit. So now I'm in a TTY that
461520	465980	Bob has provided me. And you'll see that file has now appeared on the underlying host.
465980	470100	And within the container. Now once you're done with that, you can now exit Bob and now
470100	474760	you're back into your container's terminal. So that's one way that, you know, instead of
474760	480440	doing those steps that I mentioned earlier, you can just basically say auto-pwn and boom,
480440	485340	your root on the host. Of course if the docker socket is not authenticated or protected,
485340	491180	often it's not. So automatically just auto-pwn all that stuff. So it's quite nice to get a
491180	496080	TTY on the host. If you want think pen test, you want to get a shell on the host. Also, if
496080	500760	you want to test maybe in your CI environment, if there are exploitable sockets in your
500760	504720	pre-production staging environment, you can tell Bob to do this and we'll make use of
504720	511300	return codes. So what we'll do here is we have a CI environment and we're going to run the
511300	514480	same thing. So what's happening over here in the top right, I've configured my CI
514480	519160	environment to run Bob and I've provided the auto-pwn but you'll see that I've added the
519160	523760	CRCD equals true flag. So what that means is, don't drop into a shell, but if you
523760	528380	successfully exploit that vulnerability, set the return code greater than zero. Because if
528380	533300	you're familiar with CI environments, fail tests are marked as any test that has a return
533300	537600	code greater than zero. So if your CI environment runs a command, a test, and the return
537600	541940	code is greater than zero, the test has failed. So Bob will do that. So this is very useful
541940	546720	for engineers and for CI environments. And if you look on the left, the test is running and
546720	551200	we'll see that Bob picks up a couple of Unix domain sockets, but because they're not
551200	556660	exploitable, they're not docker sockets, you'll see Bob's found them, the test will actually
556660	562200	pass. So this is quite a nice thing that you can do if, you know, it doesn't make sense to try
562200	566760	to get a shell now. Like if you're doing thousands of, uh, push, uh, push requests, pull
566760	571140	requests a day, you know, you're not going to want shells in this context. But from an
571140	575480	engineering environment, you want to test, you know, are there exposed docker sockets? Is
575480	579380	this thing pwnable? So you don't want your engineers focusing on understanding, okay, now
579380	584120	I've got a, you know, exploit docker sockets, like, you know, just run it automagically and
584120	588640	then you can find out if that's the case. So it's very useful in CI environments. But of
588640	592620	course, there's more to pwn, there's more to will than docker sockets. It's called
592620	598560	privileged containers. Anybody raise a hand, privileged container in here? Cool. So thank you
598560	601200	for putting your hand up, but it's worse when you're at a talk and someone's like, can you
601200	605680	please put your hand up if you have, you know, seen X or A or B or C. It's always the worst.
605680	611060	But, um, privileged containers are pretty much the worst thing in the world of containers. Why?
612860	617840	Cue awkward silence. The case for that is, I know, I just try to hide behind comedy and
617840	623820	it's always an epic fail. So privileged containers are basically a, a, a, I was going to say
623820	628100	another word there, but it's not a good thing. Um, and it's very dangerous when it comes to
628100	632780	your syscalls that you have access to and the Linux capabilities. And this basically means
632780	637260	very, very easy container escapes. But now you're in a privileged container, how do you
637260	642120	break out? So, I'm going to show you a new feature that I released this week. Um, what this
642120	648800	does is Bob makes use of C group controllers and we're inside a privileged container. And
648800	652480	what we're going to do is we're going to abuse the C group Linux release agent, uh,
652480	657100	capability. And what that means is that we're going to get command execution on the
657100	662440	underlying host. This is how C groups work because we have access to the mount syscall and
662440	667280	also because the Linux capability sysadmin has not been dropped, we can abuse that. So
667280	671720	basically we mount the RDMA C group controller, we then kill off a process and then basically
671720	677400	we get command execution. So you'll see now I'm using the pwn group, uh, host, uh, command.
677400	682600	I'm saying hostname and I've got a hostname of, uh, docker desktop. So now I'm getting
682600	686820	command execution, blah, blah, blah. Fun stuff. Let's get a shell. So at the bottom, I'm on
686820	694060	my jump box, standard Netcat listener. The great thing, if you're using Dockon OS X, be aware
694060	700360	that your VMs, uh, your containers are running in a Linux kit VM. That VM by default comes
700360	704160	with Netcat enabled, of course, because it's got busy box, but of course it's got the dash E
704160	710020	flag is enabled. The evil command. You do not want Netcat on your boxes with that. So it
710020	714980	makes getting shells really easy. So we're gonna tell it, Bob, pwn the C group, so we're in
714980	719740	the container, run this Netcat command, connect back to our jump box, and what's gonna
719740	724800	happen is that we're gonna get a shell on the underlying host which happens to be the Linux
724800	731140	kit VM. And in an OS X environment, that's basically game overs. So, cause we're running in a
731140	735440	privileged container, this is really easy. Trail of bits did a great write up on this. Uh, C
735440	739560	group, uh, pwnage, um, it's really interesting. And you'll see now we've got a shell at the
739560	743480	bottom, and you'll see we're on a host called Docker desktops. If you see that host name,
743480	749200	that is the VM that, uh, Docker for OS X uses. And now we're in the host file system. And if
749200	753560	you ever want to find out where your container is living on the underlying host, look at the
753560	757900	mount command, and if you look there, you'll see var lib docker overlay 2. That's where your
757900	763980	container is living. And what I'm actually gonna do now is I'm gonna create a file in the
763980	772040	Linux kit VM, and you'll see that it'll appear inside my container. So I'm in a container, and
772040	776060	you'll see the OS does not like it, because there's some Docker weirdness, but you can see
776060	781740	hello is over here, and we created it on our jump box. So basically, pwning C group, you
781740	786280	break out of the container, and you basically root on underlying host. If you're running
786280	791740	something on a Debian system, it's running bare metal, you'll end up actually being root on
791740	798360	the host. So of course, if you added the CRCD flag to Bob with this, uh, it would exploit this,
798360	802120	but then set the return code. So you wouldn't be getting shells, we can just execute a
802120	806720	command that you want. So pretty useful, privileged containers, um, they are out there. But
806720	811480	when it comes to containers, um, there's also environment variables, very, very good place to
811480	815880	look when you wanna pwn containers, you'd be surprised what's in environment variables. So
815880	819260	there's good old env, if you type that in the terminal, that's what you'll get. But there's
819260	824180	also the procfs in Linux. Procfs, it, it, it, it's given me a lot of this hair loss that you
824180	829080	see over here today. Um, but basically if you read proc and then the PID of the process
829080	832140	environment, you'll get access to the environment variables that have been set for that
832140	838340	process. Now this gets interesting, because env is not always cleared, and things might be
838340	843700	living in proc PID. And this is when, uh, ephemerality becomes a problem. So you might do
843700	850100	like a PS orcs and see, okay, there's a process with PID 99, you go read proc 99 in
850100	853240	Viron, there'll be, there might be nothing there because the process is dead. So you gotta be
853240	857820	really quick when you're doing this. Bob does this really quickly via OS and Viron, and Bob
857820	863300	will go ahead and check the env, OS.env, so like typing env in your terminal, and go in the
863300	867520	procfs and analyze it. Because sometimes there's the case where the env in your terminal's
867520	872680	been cleared, but the proc in Viron, uh, mapping has not been cleared. So sometimes you can
872680	876300	find a whole bunch of stuff, because of course, you know, environment variables, it's, you
876300	882320	know, the next gen, uh, secret storage, uh, mechanism. So that's pretty much what the Go code
882320	887600	looks like if you want to process procfs. It's really nice and minimal. Um, I'm a big fan of
887600	893040	Go, um, as you can probably hear or see. But how do we actually go about doing this? So we're
893040	898240	gonna run a container, and I should probably press play, that's a good place to start. And we're
898240	902840	gonna add in an environment variable. So it's called touch of approval and super secret
902840	911000	password. So what Bob will do by default, if you do the recon flag, if you don't pass a word
911000	915980	list, Bob will look for password and secret. And you can see now Bob has said, okay, we've
915980	923020	now found these PIDs that have this, uh, key term in proc in Viron, and Bob will then look for
923040	929120	the process that it exists in. And that's by default. But what you can also do with Bob is you
929120	934820	can also supply a word list. So you can tell Bob, you know what, analyze all the processes that
934820	941320	you have access to and use the, use for, uh, look for these words in this word list. So we're
941320	945920	gonna provide a word list now, and inside that word list were the terms password, YOLO,
945920	951280	secret, find me, and Bob went ahead and looked at ENV and in all the processes inside there.
951280	957580	Now, this is where, uh, return codes also happen. So if Bob has found a keyword in a process
957580	961700	environment that you're looking for, the return code will be greater than zero. That's what I'm
961700	965760	gonna show you now. So now you're gonna use a word list where there's nothing inside. And you
965760	970420	can see Bob didn't find any of the entries inside the word list, inside any of the processes.
970420	975540	And then you'll see the return code now will be zero because Bob didn't find any of those key
975540	982900	terms. So that's all fine and dandy. How do we also do this in a CI environment? So you
982900	987020	definitely want to scan your environment variables in your pre-production or production
987020	991800	environments because you never know what's gonna be lingering there. So in this case, and
991800	996200	these configs are all the same on the, uh, CI environments that you're using. So we're using a
996200	999660	shell script here and we're gonna be running two Bob commands. So we're gonna be doing the
999660	1003400	socket auto-po. So we're gonna try to see if we have any vulnerable sockets and we're gonna be
1003400	1008060	scanning our environment variables. And Bob will go ahead and do that on every git push and
1008060	1015140	every pull request or however you've configured your CI environments. So let me just fast
1015140	1022340	forward this. This is, in true Chris fashion, I made too much content for what I have. So I'm
1022340	1027860	like, let's get to the really cool fun stuff. And of course you can't double up speed with the
1027860	1032860	videos that I make. I'm just challenged in that way. So in every CI environment, Bob is gonna
1032860	1038380	look for these key terms. It is regex as well. So you can say, okay, look for S3 tokens or
1038380	1042920	whatever. It's, it's regex. Um, the world will definitely burn at some point. So we can see
1042920	1048020	Bob has gone ahead and run those two commands. And the test will pass because from the
1048020	1053180	previous tests, we know that there are no exploitable docker sockets. And in the container
1053180	1057180	that we are running, now remember in our, in this CI environment, all our tests are running
1057180	1061600	in containers. That's how we configured it. And now we know great stuff that test passed our
1061600	1066280	containers in pre-production. Do not have exploitable docker sockets. And the environment
1066280	1072220	variables that are there do not have any of the key terms that we specified. But of course,
1072220	1078080	clouds, uh, clouds, yeah. Clouds love to host containers. Um, and of course we've got
1078080	1085900	metadata services. So the 169254 address, it exists in GCP or AWS, Azure. And basically if you
1085900	1089760	can get access to this, you can do a whole bunch of stuff. It depends on the platform. So for
1089760	1094300	example, that call request in AWS, if there's an IAM role associated to the instance, you get
1094300	1099840	the credentials for that. It'll, it changes. It varies on GCP. Um, there's a whole, yeah, that
1099840	1104660	is a whole world and talk right there on what you can do with metadata services. Excuse me.
1104660	1109820	So you really want to find these things. But also, if you think Kubernetes, there's also
1109820	1114620	APIs out there. Metadata service is basically an API. And you want to look for these things.
1114620	1118700	Also you want to find out what is on your network ranges for your containers. For example,
1118700	1124320	EC2 classic, still around. If you use EC2 classic, um, and this is from the documentation,
1124320	1129320	your, all the hosts, every client that uses EC2 classic is all on one big flat network. Yes, I
1129320	1134360	know. What year is this? Um, so if you are running anything on EC2 classic, your host is
1134360	1139000	exposed on that 10 range. So, you know, if you're in container environments or any post
1139000	1143280	exploitation environment, you want to find what APIs or what stuff's available. But if we go
1143280	1148240	back to the container quirks now, you might not have nmap in the container. You might not
1148240	1153240	have wget or cull. You might not have the tools that you need to do the um, foot printing
1153240	1160320	that you want to do. So of course, uh, Bob has a useful feature. So you can tell Bob, go
1160320	1167080	ahead and uh, look for uh, metadata services if you don't have wget or cull, um, and all
1167080	1173400	the interesting stuff. So you just add the um, metadata flag and Bob by default will look
1173400	1179220	for two endpoints, uh, kubernetes control plane endpoints and the 169254. So you can see
1179220	1184040	now in this point, in this container, those two endpoints weren't there. But now we're
1184040	1189920	going to tell Bob, use the word list and see if the container can hit heroku.com. Um, and
1189920	1194040	we're going to specify the endpoint list and then Bob's just going to process that list and
1194040	1200540	see, okay, can I issue a successful HTTP request to that host? And there we go. We see Bob
1200540	1204960	says, we got a response from heroku.com and if we look at the return code, it's one. So you
1204960	1208800	can use this in your CI environments as well. If you want to check what the egress is, you
1208800	1212760	want to see, okay, I know that my, my kubernetes or my control planes are sitting on these
1212760	1218300	IPs. Tell Bob to scan those IPs in your prepod or in your production and Bob will tell you, oh,
1218300	1222800	by the way, I can, I can, I can interact with this endpoint, which I shouldn't. And of
1222800	1228020	course, when you're on a host and you want to break out or just pwn more stuff, it's pretty
1228020	1233660	useful when you don't have wget or curl. So there's also binary hijacking. This is awesome
1233660	1237740	because a lot of orchestration environments explicitly trust the commands that they
1237740	1242780	provide with. So if you run docker exec on a running container, docker exec doesn't go and
1242780	1248080	check, am I going to run the legit ls command on the container? It just runs ls. So if you're
1248080	1251760	in control of that container, you can overwrite the ls command to write your command. And we
1251760	1257420	can do some pretty cool stuff with that. An example is kubectl or kubectl, there's another
1257420	1263640	pronunciation. You learn something new in Vegas every year. So with kubectl, it executes the
1263640	1270320	containers or the, the pods, um, tar command. That was recently exploited and used in an
1270320	1275400	interesting chain by Twistlock, I highly recommend. But because as an attacker, you had
1275400	1279500	access to the tar command on the host, you could mess with kubernetes and basically break
1279500	1285220	out. So, pretty interesting. Important to remember that at some point in a container's
1285220	1289560	lifetime, a binary might be executed. By binary I mean command. So maybe the power off
1289560	1294860	command or the IP adder command might be executed in your container. So what do we do? We
1294860	1300240	hijack all the binaries. So be careful, you can really break stuff here, uh, you're
1300240	1305320	overwriting binaries. Um, so it's not too friendly for production environments, um, so
1305320	1309240	I've been told. So, if you want to do this, what do you do? So these are the manual steps.
1309240	1312620	So you've got to find out if you have read or write permissions to burn or sbin or use
1312620	1316920	sbin in the container. You want to create a malicious executable that does something. So
1316920	1321980	either a webhook to verify execution or you want to fuzz something, you can go ahead and do
1321980	1326640	that. You then want to replace every binary that's in sbin or bin with your malicious
1326640	1334000	executable and then basically you just, you wait and uh, you can loot some hosts. So, in
1334000	1338600	terms of payloads, Bob will do this by default. We use webhooks, why? Because sometimes,
1338600	1341820	you know, if you execute, if you put it in a shell payload and then you set up your
1341820	1346840	handler and then it could be one minute, it could be 24 hours until you get a callback.
1347040	1351540	Webhooks are useful because it will, it will confirm exploits ability. In this case, we're
1351540	1355560	going to say, okay, tell me which command was called and what parameters were sent to it.
1356680	1360800	That's how you would do it in bash. If you want a Linux host on a container, you, if you
1360800	1365480	were to write a bash script, that's what it would look like. Um, so how do we actually do
1365480	1369840	this and what do we get from this? So you could get a callback in one minute or five minute or
1369840	1375140	next week, it really depends. Um, I've, what I've successfully achieved with this kind of
1375140	1380020	attack is getting, uh, tokens provided to call commands. So some cloud platforms will say,
1380020	1384580	okay, this client's running a container, it's been 24 hours, let's back up the content of the
1384580	1388400	container and let's push it to an S3 bucket. And of course, you know, it's not an open S3
1388400	1392000	bucket, they authenticate it as they should. But because they're running the call command
1392000	1397100	inside my container, I've overwritten the call command and actually calling my command and
1397100	1401320	then because they're using a token, they have to give the token to the call command that they're
1401320	1405660	running in my container to back up the contents. So you can find some interesting stuff over
1405660	1410080	there. You can also prevent logic, so often client environments when you hijack binaries, hijack
1410080	1414860	the power off command, a lot of orchestrators say, okay, this person has had two hours of
1414860	1419600	compute, turn off that instance. Okay, cool, but now you've just hijacked the power off
1419600	1423260	command and that orchestrator thinks that they've executed the actual legit power off
1423260	1428440	command, but you've hijacked it, so you might get more compute time. And general blockage, you
1428440	1433860	can really break stuff with this kind of stuff. So hijacking binaries, it's fun. So enough of
1433860	1441920	me talking, let's actually see this in action. So on the right, we're in a container and
1441920	1447380	basically I'm telling Bob, go ahead and use the hijack command and I know that text is really
1447380	1452900	small, I apologize, you can throw stuff at me later about that. But we're telling Bob,
1452900	1459560	hijack all the binaries in the host, in the container, and execute this command. So Bob is
1459560	1463660	going to configure the host such that any command that's been hijacked, it's going to
1463660	1467600	execute a call command and that's going to hit a web end point, which is the logs that you
1467600	1473420	see over here. So I executed the ID command and you'll see that I got a call back over here.
1473420	1478540	I was told, so I'm going to say ID hello, and then my logs on my web server say, okay,
1478540	1482160	someone executed the ID command on the container and they sent the parameters, hello,
1482160	1486980	y'all. So what does it look like if we were to run maybe docker exec on this running
1486980	1492760	container? So that's what we're going to do now. So this could be kubectl copy,
1494060	1498040	execute the talk command, so we're going to run the ID command via docker exec and then
1498040	1502000	you'll see on the left we just got a call back because we've overwritten, we've hijacked the
1502000	1507700	ID command. So that gets a lot of fun, that gets pretty interesting. I enjoy doing that,
1507700	1512420	you'd be surprised as to what you can get. So Bob automates that whole task and it's a lot of
1512420	1518580	fun. But of course, there's more. What about all the CVs and all the lovely stuff that we
1518580	1524000	have in docker? Yes, you did just see shell shock and bash bug and you probably like what
1524000	1527560	year is it? That's actually quite a useful thing to actually look on containers because you'd
1527560	1533260	be surprised how old some infrastructure is and if you, yeah, in infosec you know people
1533260	1536540	don't patch things. So that's a good payload to know, especially in container
1536540	1540160	environments, especially for LXC containers. There's a whole bunch of stuff, that's some
1540160	1547080	really useful CVs, but one of my recent favorite ones is the run C pwnage that came out
1547080	1553360	really cool. Basically similar to hijacking binaries but here you are hijacking the run C
1553360	1556840	binary on the underlying host. That's what the vulnerability allows you to do. So
1556840	1562200	basically from your container you overwrite the run C binary on the underlying host and
1562200	1566740	then you run in the context of that and because it's owned by root you run as root. Now this
1566740	1571700	is slightly destructive, so yeah, I always call this a last resort exploit because you can
1571700	1576320	actually break the underlying run time because you're breaking the run C binary. For
1576320	1579340	docker and LXC it gets a bit tricky, sometimes you need to be a privileged container,
1579340	1583040	sometimes you need root. This is because LXC and docker treat privileged containers very
1583040	1589080	differently. I won't get into that but it's really interesting. And yeah, what you're
1589080	1592400	going to do in this case, and Bob is pretty useful, if you want to verify if a host is
1592400	1596700	exploitable to this because you can't actually trigger your payload being executed. The
1596700	1600540	payload is only executed in this vulnerability when someone runs a command inside your
1600540	1607820	container. So if someone's running a kubectl copy or someone's running a docker exec. So you
1607820	1615700	could wait. So in this case we're going to give a very nice webhook. So we're going to tell
1615700	1623620	Bob, oh I hate cotton mouth, sorry excuse me. And I should probably play, auto play. If only
1623620	1631340	someone invented that by now. So we're in a container in the top and we're going to tell Bob
1631340	1636840	try and exploit CVE blah blah blah blah blah blah blah blah. And the payload that we're
1636840	1643700	going to give is a curl command so we're going to tell if this successfully is exploited we
1643700	1647040	should get a call back on our host. So that will be the terminal on the left. So that's our
1647040	1652880	curl command we're saying execute this. So now we've run the payload. Now you got to wait
1652880	1656360	with this payload. So now to trigger it I'm going to run a docker exec and that's at the
1656360	1662940	bottom terminal on that container. So you can't trigger this. And basically I'm going to run
1662940	1666920	an exec and I'm just going to get a shell. Because you know I want to administer this
1666920	1671540	container that I'm working from. So I'm going to run bin sh and you'll see Bob will exit at the
1671540	1676680	top. So it says finished and now we've got a call back in the bottom left. So now that tells
1676680	1681880	us okay this particular container was vulnerable to that CVE and we now got a call back. So
1681880	1685940	now you could go ahead and get another container on that platform and then you know give
1685940	1691740	your shell payload. So pretty useful. If you want to do that exploit manually there is a bit
1691740	1698720	of work to it. But Bob will take care of that for you. Awesome. Conclusion. Yes and I haven't
1698720	1703680	had my time cut yet because that always happens. So Bob can be used by both pen testers and
1703680	1709520	engineers as you can see. I can use it to get shells um or to verify exploits ability. Uh you
1709520	1714940	can also use it within your SDLC environment so security at scale is really really hard. And
1715560	1720820	quite an important point here is that we are testing for two kinds of vulnerabilities.
1721080	1726600	Immediate, so like getting a shell immediately or we are also getting delayed. So remember
1726600	1731580	the hijacking binaries or the rancy that is delayed. I have ten minutes. Was that ten
1731580	1736560	minutes Jeff? Awesome. This is like, this never happens. I apologize. Your ears must be, I'm
1736560	1742100	going really fast as well. Caffeine, I blame that. And of course it being ten o'clock in the
1742100	1747180	morning. It's like ah get everything out before everyone falls asleep. So you see I digress.
1747180	1751200	Now I need to come back. Yes Chris what were you saying? Feedback, yes that thing. So you
1751200	1755380	gonna be able to get feedback on two kinds of vulnerabilities. So if you hijack all the
1755380	1760980	binaries, you have a web end point, you can get it at some time and also with the rancy stuff.
1761400	1765800	There are a couple other features that I have not touched on today. So there is some stuff
1765800	1769100	that like if you are on a host and you want to push stuff to S3 buckets for data exfil, it's
1769100	1774000	pretty useful. I added that recently to Bob. Um there's also quite a cool way that you can
1774000	1777860	scrape metadata stuff. So if you know if you've ever gotten access to a metadata services
1777860	1783060	that's a real pain to get the actual content. There's a nice trick that you can do on GCP
1783060	1788560	uh legacy metadata services. You just basically connect on port 80 with net cat. Don't send
1788560	1794160	the host header. Enter, enter and blah. All the metadata stuff is yours. So I built that into
1794160	1799060	Bob to do it automatically. So yeah there's a couple other things. It's all on the GitHub
1799060	1804740	repo. So all the documentation is there. Um I haven't gone through all the functionality.
1804800	1810400	But yeah it's all there. You can find it. Uh all the binary releases are there. And yes I
1810400	1814680	thank you for your time. It's early Saturday morning. And yeah I'm going to end it there.
1814680	1815540	Thank you so much.
1815960	1816260	Audience Applause
