1 00:00:00,000 --> 00:00:12,000 So now, this is an interesting timing for a talk, because I want to introduce an old friend of ours who is... 2 00:00:12,520 --> 00:00:23,180 This is the first time we're going to have a talk, but then immediately you're going to have to hop over to the next room for a workshop. 3 00:00:23,180 --> 00:00:27,240 So this is like the prelude to your workshop, isn't it? 4 00:00:27,240 --> 00:00:29,720 Without much ado, Jay Beal, everyone. 5 00:00:34,180 --> 00:00:35,260 Hi, hi. 6 00:00:35,860 --> 00:00:36,640 Hi, hi. 7 00:00:36,680 --> 00:00:40,780 I'm going to try really hard to stay within range of the mic. 8 00:00:42,300 --> 00:00:44,240 And let's see how I can do with that. 9 00:00:44,240 --> 00:00:46,280 I'm not really good at staying in one place. 10 00:00:46,280 --> 00:00:47,840 I kind of like to walk around. 11 00:00:48,900 --> 00:00:52,540 If you've seen me at many DEF CONs in the past, I like to dance. 12 00:00:52,660 --> 00:00:57,460 So anyway, with that said, I'm going to talk to you about attacking and defending Kubernetes. 13 00:00:58,100 --> 00:01:04,320 It's a topic that's become incredibly important to me and dear to me and interesting to me. 14 00:01:04,420 --> 00:01:09,000 So I have a bio slide, but we all know bio slides are just big seas of text. 15 00:01:09,100 --> 00:01:16,000 So I have a graphical bio slide, which basically says, this is stuff I've done or stuff I'm interested in. 16 00:01:17,260 --> 00:01:22,460 I really enjoy... this is stuff kind of going back way back to the... 17 00:01:22,460 --> 00:01:28,860 back in the day writing at Security Focus and doing CIS work and giving some early, early DEF CON talks. 18 00:01:28,860 --> 00:01:40,980 And nowadays teaching a class at Black Hat and enjoying a heck of a lot of work at Engardians as a CTO who likes to still be a very technical CTO. 19 00:01:41,040 --> 00:01:44,800 So anyway, let's get on with what you came for. 20 00:01:44,800 --> 00:01:45,760 So what are we going to see today? 21 00:01:45,760 --> 00:01:48,780 We're going to talk about Kubernetes. 22 00:01:49,000 --> 00:01:51,420 I'm going to do a bunch of demos. 23 00:01:52,080 --> 00:01:54,220 We'll do a little bit of choose-your-own-adventure. 24 00:01:54,220 --> 00:01:59,580 If all my... if the tech works, the choose-your-own-adventure part is entirely new. 25 00:01:59,580 --> 00:02:02,360 So the nice thing is cutting edge fresh. 26 00:02:02,360 --> 00:02:04,480 The downside is, uh-oh. 27 00:02:05,240 --> 00:02:07,700 So hopefully this is... hopefully this goes really well. 28 00:02:07,700 --> 00:02:09,700 So I'm going to talk about what Kubernetes is. 29 00:02:09,700 --> 00:02:14,380 I'm going to talk about how you... what you attack and how you attack it. 30 00:02:14,380 --> 00:02:16,040 And then a little bit about how you defend. 31 00:02:16,040 --> 00:02:17,400 We're going to do some demos. 32 00:02:17,940 --> 00:02:18,940 Let's just start. 33 00:02:18,940 --> 00:02:24,780 So the first thing I do any time I talk about Kubernetes is talk about what the heck this thing is for. 34 00:02:25,380 --> 00:02:30,000 And because... and I want to make sure I'm coming through on the mic. 35 00:02:30,100 --> 00:02:31,820 Am I coming through on the mic in the back of the room? 36 00:02:31,820 --> 00:02:32,420 Perfect. 37 00:02:32,660 --> 00:02:35,120 Okay, so what the heck this thing is for? 38 00:02:35,460 --> 00:02:39,520 And , you know, people are like, I know that this is hot. 39 00:02:39,520 --> 00:02:40,820 I know that I should use it. 40 00:02:40,820 --> 00:02:43,460 That's kind of the same way we all felt about Docker. 41 00:02:43,640 --> 00:02:48,500 So, you know, why do we use this or what's made it so big? 42 00:02:48,500 --> 00:02:56,420 And basically the Kubernetes came out of... in a lot of ways it came out of what Google is doing with the Borg, right? 43 00:02:56,420 --> 00:03:01,820 It's an open source project that initially got released by Google and now has many, many, many contributors. 44 00:03:02,320 --> 00:03:05,080 But Kubernetes basically came out of this need. 45 00:03:05,240 --> 00:03:10,960 We know that Google... we know that Google had just... has a ton of computers and a ton of workloads. 46 00:03:11,060 --> 00:03:17,500 To be clear, you know, it's not exactly the most transparent company all the time, but they have some public statements they've made. 47 00:03:17,500 --> 00:03:23,060 One is back in 2014, they were launching 2 billion containers per week. 48 00:03:23,060 --> 00:03:27,100 If that were evenly distributed, it'd be 3,300 containers per second. 49 00:03:27,240 --> 00:03:28,240 What's a container? 50 00:03:28,240 --> 00:03:29,220 It's like a workload. 51 00:03:29,220 --> 00:03:31,740 It's a program that's going to run for a little while and do something. 52 00:03:31,740 --> 00:03:33,600 We don't know how long that while is. 53 00:03:33,620 --> 00:03:43,100 But if you're launching 3,300 a second, you can't have a human being decide which virtual machine or which host, you know, each program, each workload is going to go on. 54 00:03:43,100 --> 00:03:46,040 So you end up needing a tool for that. 55 00:03:46,040 --> 00:03:48,060 Now, what else? 56 00:03:48,420 --> 00:03:50,080 Well, they did this. 57 00:03:50,080 --> 00:03:54,860 They were launching all of those workloads onto 2.5 million servers. 58 00:03:54,860 --> 00:03:57,200 At least that was their number back in 2016. 59 00:03:57,280 --> 00:04:01,660 And in 2016, hard drive failure rates were just right below 2%. 60 00:04:01,660 --> 00:04:07,220 So if every server had just one drive, and that's a big, you know, hand-waving thing. 61 00:04:07,220 --> 00:04:14,720 But if every server had one drive, that meant they had 133 drive failures a day, or one every nine minutes. 62 00:04:14,720 --> 00:04:18,500 So now you've got a resiliency problem, right? 63 00:04:18,500 --> 00:04:30,660 Like, you wanted to guarantee, you know, you wanted to guarantee so many nines of uptime, and yet your physical machines are going to, you know, entire physical machines are going to die on some regular basis. 64 00:04:30,660 --> 00:04:35,120 Like, say, RAID, notwithstanding, one every nine minutes. 65 00:04:35,120 --> 00:04:50,160 So what features would you want if you wanted to be able to stage a ton of workloads over a ton of servers, figure out how to use the servers at the greatest, as close to their capacity as you could, so you weren't buying lots of extra machines. 66 00:04:50,260 --> 00:04:58,940 And you wanted to make sure that as programs crashed and as hard drives failed and so on, that you still had availability. 67 00:04:59,720 --> 00:05:05,780 So you end up with what Kubernetes is, which is basically a software-defined data center. 68 00:05:06,040 --> 00:05:08,720 And we do that by container orchestration. 69 00:05:08,720 --> 00:05:09,940 So what do you get? 70 00:05:09,940 --> 00:05:12,160 So basically, this is your feature set. 71 00:05:12,160 --> 00:05:13,240 This is what you end up saying. 72 00:05:13,240 --> 00:05:22,140 You end up saying, well, sometimes I have a lot of people checking their email on Gmail or searching right now for the thing that just happened in the news. 73 00:05:22,180 --> 00:05:23,680 And sometimes I don't have as many. 74 00:05:23,680 --> 00:05:25,240 So I'd like a whole lot of scaling. 75 00:05:25,240 --> 00:05:26,680 I'd like that horizontal scaling. 76 00:05:27,540 --> 00:05:29,480 I have four copies of that workload. 77 00:05:29,480 --> 00:05:31,240 No wait, I have 400. 78 00:05:31,240 --> 00:05:32,900 No wait, I have 50. 79 00:05:32,960 --> 00:05:33,760 And so on. 80 00:05:33,760 --> 00:05:40,200 And you get automatic bin packing, which is that, like, which workload should go on which machine so we can keep all the machines as full as we can. 81 00:05:40,240 --> 00:05:42,700 And you get self-healing, like that hard drive crash thing. 82 00:05:42,900 --> 00:05:44,780 And you get a whole bunch of other cool features. 83 00:05:44,780 --> 00:05:55,620 You get, like, automated rollouts and rollbacks where you can basically deploy multiple versions at once and see if one of them ends up producing more sales or more of whatever it is you're trying to produce. 84 00:05:55,740 --> 00:06:01,280 Or see if one's buggy and then be able to basically route all the traffic to the one that isn't and so on. 85 00:06:01,320 --> 00:06:06,460 You get the other kinds of things you would need if you're going to do microservices. 86 00:06:06,600 --> 00:06:09,960 So you get service discovery and you get load balancing. 87 00:06:09,980 --> 00:06:14,200 And then you get orchestration of your storage and you get secrets and configuration management. 88 00:06:14,200 --> 00:06:16,640 So that's kind of, that's what the purpose was. 89 00:06:16,640 --> 00:06:18,160 I'm going to do a little bit more theory. 90 00:06:18,160 --> 00:06:22,280 So just kind of, like, what's a pod, what's a container? 91 00:06:22,280 --> 00:06:26,720 So, right, we, when we're talking about Kubernetes, we're talking about containers. 92 00:06:27,220 --> 00:06:29,260 But we say pods a lot. 93 00:06:29,260 --> 00:06:32,320 And basically pods are the smallest unit of compute in Kubernetes. 94 00:06:32,320 --> 00:06:36,340 So all the containers in a pod are sharing an IP address. 95 00:06:36,340 --> 00:06:43,400 The only reason you put multiple containers in a pod is if you want them to absolutely positively land on the same host. 96 00:06:43,400 --> 00:06:47,880 Like they have need for very, very quick network access or what have you. 97 00:06:48,020 --> 00:06:50,540 Maybe they need the same local storage. 98 00:06:51,500 --> 00:06:55,580 An odd thing about pods is all the containers in a pod share an IP address. 99 00:06:56,440 --> 00:06:58,980 Okay, so then you've got Kubernetes nodes. 100 00:06:59,020 --> 00:07:02,020 Simply put, a node is any system you're going to run Kubernetes on. 101 00:07:02,020 --> 00:07:07,580 A node is any of the systems in your cluster, whether those are virtual machines or physical hardware. 102 00:07:07,580 --> 00:07:15,860 The nodes run a, well, first and foremost, the nodes, to be a node, you have to have a container runtime. 103 00:07:15,860 --> 00:07:18,480 So you have to have something like Docker or RunC or what have you. 104 00:07:18,480 --> 00:07:26,460 Something that's going to basically take instructions from Kubernetes about creating containers and create them. 105 00:07:26,460 --> 00:07:28,800 And maybe destroy them and so on. 106 00:07:28,800 --> 00:07:31,280 You also need a kubelet. 107 00:07:31,280 --> 00:07:36,440 And a kubelet, Kubernetes kubelet, a kubelet is just this thing that runs in every Kubernetes node. 108 00:07:36,440 --> 00:07:43,040 And it ties the container runtime or the node into the rest of Kubernetes. 109 00:07:43,040 --> 00:07:45,680 It talks to the API servers and so on. 110 00:07:45,880 --> 00:07:47,540 Then you've got a kubeproxy. 111 00:07:47,540 --> 00:07:51,780 And that thing manipulates IP tables rules to create cool networking. 112 00:07:51,780 --> 00:07:54,040 It also serves as an actual proxy. 113 00:07:54,980 --> 00:07:58,180 So, yeah, we'll get into that a little bit more. 114 00:07:58,400 --> 00:08:00,340 And then services. 115 00:08:01,000 --> 00:08:10,540 Services are big because in Kubernetes, and services give me a great occasion to kind of describe how you talk about the names of things in Kubernetes. 116 00:08:10,540 --> 00:08:15,620 When we're doing the attack demos, we're going to be talking about this pod and this pod and this pod. 117 00:08:15,620 --> 00:08:20,660 But for the most part in Kubernetes, you don't ever think about which pod names you want. 118 00:08:20,660 --> 00:08:27,160 The whole idea is that the individual pods, the containers, they're very, very much supposed to be cattle. 119 00:08:27,160 --> 00:08:28,560 They're not supposed to have names. 120 00:08:28,560 --> 00:08:30,000 They're supposed to be interchangeable. 121 00:08:30,000 --> 00:08:32,960 I'm supposed to be able to trash them, start new ones up. 122 00:08:32,960 --> 00:08:36,360 I have to... I'm going for... I'm going for that. 123 00:08:36,580 --> 00:08:38,620 So, what does that mean? 124 00:08:38,620 --> 00:08:40,800 I mean, if I want to talk to a pod, what do I do? 125 00:08:40,800 --> 00:08:41,620 You don't. 126 00:08:41,640 --> 00:08:43,800 I mean, you might, but rarely. 127 00:08:43,800 --> 00:08:45,740 Mostly, you talk to a service. 128 00:08:45,860 --> 00:08:48,640 And a service is mapped to multiple pods. 129 00:08:48,640 --> 00:08:50,600 Think of it as an internal load balancer. 130 00:08:51,300 --> 00:08:56,580 Now , if you've got, like, why do I say that would get me into something cool? 131 00:08:56,580 --> 00:08:57,980 That gets me into labels. 132 00:08:57,980 --> 00:09:00,920 And basically, you have a load balancer. 133 00:09:00,920 --> 00:09:04,760 You can't say this load balancer should be pointed at these five pod names, right? 134 00:09:04,760 --> 00:09:06,420 First, you're going to have a whole lot more. 135 00:09:06,420 --> 00:09:07,260 They're going to get added. 136 00:09:07,260 --> 00:09:09,740 Second, those pods are going to die at any moment. 137 00:09:09,740 --> 00:09:11,660 Third, you're trying to go really, really fast. 138 00:09:11,660 --> 00:09:16,380 Remember, you know, 3,300 containers per second being launched, right? 139 00:09:16,440 --> 00:09:18,080 So, what do you do? 140 00:09:18,080 --> 00:09:20,360 You end up basically labeling everything. 141 00:09:20,360 --> 00:09:21,680 So, you label all the pods. 142 00:09:21,680 --> 00:09:22,560 You give them labels. 143 00:09:22,560 --> 00:09:25,300 And those labels are basically... sometimes they're by convention. 144 00:09:25,300 --> 00:09:26,960 Sometimes they're whatever you chose. 145 00:09:26,960 --> 00:09:28,560 But you label the pods. 146 00:09:28,560 --> 00:09:29,860 And then you create a service. 147 00:09:29,860 --> 00:09:34,960 And you say, everything that... you know, this service is going to be a name, an IP address, or port. 148 00:09:34,960 --> 00:09:45,620 And everything that goes to that name and port, or IP address and port, is going to be sent to one of the pods that have the set of labels the service specifies. 149 00:09:45,860 --> 00:09:47,740 It does kind of open an interesting question. 150 00:09:47,740 --> 00:09:59,220 Like, if you are allowed to stage pods onto a cluster, could you start intercepting other people's traffic by just giving yourself the same labels that their services are looking to land things on? 151 00:09:59,400 --> 00:10:00,140 Hmm. 152 00:10:00,140 --> 00:10:00,900 Okay. 153 00:10:00,900 --> 00:10:01,860 Interesting. 154 00:10:02,800 --> 00:10:04,280 Last thing we talk about. 155 00:10:04,280 --> 00:10:09,100 Last big, big, you know, kind of simple glossary concept we need is namespaces. 156 00:10:09,160 --> 00:10:12,340 The namespaces are just a logical grouping for things. 157 00:10:12,340 --> 00:10:13,940 So, we'll see those. 158 00:10:14,460 --> 00:10:24,480 They're often used to separate projects, or to separate teams, to separate an individual, you know, maybe to separate, well, anything you choose. 159 00:10:24,480 --> 00:10:26,880 So, there's some way of chopping things up. 160 00:10:26,880 --> 00:10:42,420 And it's important to say a Kubernetes namespace is not the same as a Docker or Linux namespace, so much so that when I teach classes on this, one of the other folks from Guardians, Jared Fredis, asked if we could please call Kubernetes namespaces, space names, 161 00:10:42,420 --> 00:10:45,720 since Docker and Linux, you know, already have namespaces. 162 00:10:45,720 --> 00:10:48,220 So , it was, you know, don't overload the term. 163 00:10:48,460 --> 00:10:50,440 So, here's a quick glossary slide. 164 00:10:50,580 --> 00:10:55,040 I'm going to say a tiny bit more on theory, and then we'll have some fun. 165 00:10:55,380 --> 00:10:59,880 So, Kubernetes basically works in this declarative model. 166 00:10:59,880 --> 00:11:05,260 You don't generally say, you're going to see me generally, like, hey, do this thing right now. 167 00:11:05,260 --> 00:11:08,120 But you don't generally tell Kubernetes to do a thing right now. 168 00:11:08,120 --> 00:11:14,920 You don't say, hey, take this, you know, take this container image, start a container on that node over there with it, right? 169 00:11:14,920 --> 00:11:19,800 You tend to say, you know, it's very delegating and hands-off, right? 170 00:11:19,800 --> 00:11:24,680 So, the idea is you say, Kubernetes, I have this program. 171 00:11:24,680 --> 00:11:26,240 I've created an image. 172 00:11:26,240 --> 00:11:28,060 Maybe I've placed that image on Docker Hub. 173 00:11:28,060 --> 00:11:30,580 Maybe I've put it on some other container registry. 174 00:11:30,580 --> 00:11:36,900 And I'd like you to now, like, download that image, like, have some nodes, download that image. 175 00:11:36,900 --> 00:11:40,120 I'd like at least, say, five to be running it. 176 00:11:40,120 --> 00:11:42,240 Like, if you need more, scale up. 177 00:11:42,420 --> 00:11:45,220 But, you know, I want five, no less than three. 178 00:11:45,220 --> 00:11:48,260 Like, let's, you know, just do me a favor and get that running. 179 00:11:48,260 --> 00:11:49,460 And Kubernetes says, sure. 180 00:11:49,460 --> 00:11:54,300 And it's got a bunch of, like, control loops that basically first make that the state of the world. 181 00:11:54,300 --> 00:11:55,800 So, you describe the state of the world you want. 182 00:11:55,800 --> 00:12:02,120 It basically spends its whole life trying to keep the state of the world where you've said it has to be. 183 00:12:02,120 --> 00:12:03,500 And then it basically loops. 184 00:12:03,500 --> 00:12:05,180 And it says, ah, a machine fell down. 185 00:12:05,180 --> 00:12:07,440 I guess I'll have to reassign those workloads. 186 00:12:07,760 --> 00:12:11,160 Or, ah, looks like something's not responding. 187 00:12:11,160 --> 00:12:15,000 I'll have to, you know, maybe I'll kill that off and I'll start something else. 188 00:12:15,080 --> 00:12:17,420 So, you describe the state of the world. 189 00:12:17,680 --> 00:12:20,500 I think this is basically my last theory. 190 00:12:20,500 --> 00:12:22,800 And I hope I haven't given you too much. 191 00:12:22,800 --> 00:12:25,820 So, the kind of target components. 192 00:12:25,820 --> 00:12:27,460 There are a bunch of components you'll target. 193 00:12:27,460 --> 00:12:33,320 The big ones that you hear about are especially on the first two slides here. 194 00:12:33,320 --> 00:12:35,480 So, you'll target the API server. 195 00:12:35,480 --> 00:12:44,620 The thing that everybody's basically doing all of these HTTPS and, God forbid, HTTP requests against and asking to do things. 196 00:12:44,940 --> 00:12:51,740 And the kubelet, which we said bridged each node into the system. 197 00:12:51,740 --> 00:12:53,240 The container runtime. 198 00:12:53,380 --> 00:12:58,860 You can often think of Docker, and I'll often say Docker, but there are multiple container runtimes. 199 00:12:59,300 --> 00:13:06,720 And that container runtime is the thing that pulls the container images from the registry, you know, like Docker Hub or what have you, and instructs the kernel to start up a container. 200 00:13:07,320 --> 00:13:10,480 You have an etcd server that maintains all the state. 201 00:13:10,480 --> 00:13:15,620 And if you ever get access to that thing, yeah, there's not really a lot of chopped up authorization. 202 00:13:15,620 --> 00:13:23,400 So, if you get access to it, you kind of own all the, you own all of the persistent idea of what the system is. 203 00:13:23,400 --> 00:13:25,240 And so, that's very good for you. 204 00:13:25,380 --> 00:13:26,860 A Kubernetes dashboard. 205 00:13:27,180 --> 00:13:38,480 That was the thing that got, as I recall, that was the thing that got Tesla in trouble, where their dashboard was available to the internet and, I think, was allowing anonymous access to do anything. 206 00:13:38,640 --> 00:13:42,460 But that's a web interface, as I, I think it's being deprecated. 207 00:13:43,440 --> 00:13:48,140 There's metrics components and different kinds of cluster services that will give you good information. 208 00:13:48,740 --> 00:13:50,900 Those, those are your usual targets. 209 00:13:51,100 --> 00:13:59,660 Just to throw in two more, two more components that people, that it's really helpful just, you know, if you're operating Kubernetes, defending it or attacking it are useful to know. 210 00:13:59,660 --> 00:14:01,260 One is the controller manager. 211 00:14:01,260 --> 00:14:06,960 And the controller manager, it makes it sound like it's, like the controller manager would have lots of separate controller programs. 212 00:14:07,040 --> 00:14:11,860 And it kind of does, but they're all just compiled into one big, you know, they're just compiled into one big program. 213 00:14:11,860 --> 00:14:14,520 So the controller manager has all of the controllers. 214 00:14:14,520 --> 00:14:19,500 The controllers are the things that basically do those loops and say, is everything the way it was supposed to be? 215 00:14:19,500 --> 00:14:21,060 Is everything the way it was supposed to be? 216 00:14:21,060 --> 00:14:22,360 Ah, something's different. 217 00:14:22,360 --> 00:14:23,980 I'm supposed to have five copies of this. 218 00:14:23,980 --> 00:14:24,720 I've got four. 219 00:14:24,720 --> 00:14:31,440 I'll go talk to the next one, the scheduler, and say, excuse me, scheduler, can you find somewhere to, can you find somewhere to put this? 220 00:14:31,600 --> 00:14:34,560 Can you find a node we can put things on? 221 00:14:34,640 --> 00:14:38,060 We tend to target these components only through the API server. 222 00:14:39,520 --> 00:14:45,520 So attacks on Kubernetes, this is where we start to finally get to attack and defense. 223 00:14:47,400 --> 00:14:52,920 Attacks on Kubernetes, they start from, they start from the perspective of compromised pod. 224 00:14:52,920 --> 00:14:58,200 So you can attack, you can attack a Kubernetes cluster from across the network. 225 00:14:58,200 --> 00:15:05,760 And it's even less effective than attacking most companies, you know, across the Internet has been, right, lately. 226 00:15:05,760 --> 00:15:08,000 It's, it's, we've gotten pretty good at perimeters. 227 00:15:08,000 --> 00:15:12,160 Kubernetes is pretty darn good at perimeters because for the most part, it doesn't allow any traffic. 228 00:15:12,160 --> 00:15:20,080 There's nothing, there's no traffic being allowed in unless it's had, unless it's had some kind of ingress defined for it. 229 00:15:20,080 --> 00:15:30,280 So , so for the most part, you attack a Kubernetes cluster from the perspective that you are in a workload, that you're in a container and that container is compromised or otherwise under your control. 230 00:15:30,480 --> 00:15:37,040 So what are the, you know, what are the, what are the, what are the ways the attacker might end up with that kind of control? 231 00:15:37,040 --> 00:15:42,680 Because, yeah, as you'll see in some, in our demos, this is the, this is the vector I like to, I like to show. 232 00:15:42,680 --> 00:15:50,380 It's the, the attacker found a vulnerable thing that you were hosting in Kubernetes, got remote code execution, and now they're in a container. 233 00:15:50,380 --> 00:15:58,440 And from that container, they may have the ability to do much more far ranging things, because we're in an orchestration system, a very automatic one. 234 00:15:58,440 --> 00:16:13,220 They may be able to do far more wide ranging things than if they just busted that, you know, some web server or some, or something that was in a, that was in a cloud environment or in a data, or in a, or in an on-prem data center. 235 00:16:13,700 --> 00:16:16,340 So, how else might the attacker have gotten in? 236 00:16:16,340 --> 00:16:18,280 The attacker might have just phished somebody. 237 00:16:19,140 --> 00:16:35,620 Brad Giesemann, who I'll, whose name I probably just butchered, and whose Twitter handle I'll have at the end of these slides, has a great slide in one of his presentations about how kube control apply, and that a URL is the new curl URL into shell. 238 00:16:35,620 --> 00:16:49,740 Right, if you, one of the great ways to phish somebody would be if you put up a how-to article on Stack Overflow or what have you, and the, you know, part of that article was, oh, just apply my, you know, apply my YAML from this URL. 239 00:16:49,980 --> 00:16:54,840 You can get anyone to apply the YAML from the URL, then you've got places for your crypto mining to go. 240 00:16:56,340 --> 00:17:01,180 So, and our attacker could just be some internal threat actor who's looking to escalate their privileges. 241 00:17:01,180 --> 00:17:07,320 I often, you'll, you'll often hear me use the word user and attacker interchangeably. 242 00:17:07,340 --> 00:17:10,720 On the defense side, that's not really because I think all my users are hostile. 243 00:17:10,720 --> 00:17:12,580 I just don't know which ones of them might be. 244 00:17:12,580 --> 00:17:14,000 I don't know who's being coerced. 245 00:17:14,000 --> 00:17:16,380 I don't know who's, you know, getting curious. 246 00:17:16,420 --> 00:17:19,080 I don't know who's actually got an axe to grind. 247 00:17:19,180 --> 00:17:22,140 And I think we all know least privilege is a good idea at this point. 248 00:17:22,400 --> 00:17:28,880 So, okay, so, so if an attacker's going to be in a pod, what are they going to do with that? 249 00:17:28,880 --> 00:17:31,360 I'm going to give you a few, I'm going to give you a few things. 250 00:17:31,360 --> 00:17:32,780 There's even more, I'm sure. 251 00:17:32,780 --> 00:17:34,560 So this is kind of the general way. 252 00:17:34,560 --> 00:17:41,080 So they could use just the network access that they get provided by the pod to access other services. 253 00:17:41,240 --> 00:17:49,500 And I'll say very, very, very often, especially in the microservice model, a Kubernetes cluster has a bunch of things that are all supposed to talk to each other. 254 00:17:49,540 --> 00:17:57,160 And it's actually, it can be a little difficult or at least take some work to sit down and say, okay, what should and what shouldn't. 255 00:17:57,160 --> 00:18:15,080 So once you're in the cluster, you have access to a whole bunch of things, many of which might not be intended to be communicated with by anyone on the Internet or anyone that the service that you've pwned is trying to serve. 256 00:18:15,080 --> 00:18:16,340 So what else? 257 00:18:16,340 --> 00:18:20,180 So the attacker could attack other containers that are in their same pod. 258 00:18:20,440 --> 00:18:25,600 Multiple containers in a pod, they share, well, I told you, they share an IP address. 259 00:18:25,600 --> 00:18:26,980 They share a local host. 260 00:18:27,160 --> 00:18:32,580 So it's a cool little Linux namespace thing, which we won't get into unless somebody asks me later on. 261 00:18:33,380 --> 00:18:34,240 What else? 262 00:18:34,240 --> 00:18:46,600 So the attacker could make requests to the API server or to a kubelet and ask those to maybe run commands in another pod, maybe even interactively, to start a new pod that has privilege. 263 00:18:46,600 --> 00:18:48,260 And that privilege could be all kinds. 264 00:18:48,260 --> 00:18:56,420 It could be a privileged pod, which means it'll start on the host and have access to system devices and be able to, among other things, maybe mount the hard drive of the node. 265 00:18:56,420 --> 00:19:03,300 But there's just all kinds of privilege you can get out of starting new pods, and I'll show you that. 266 00:19:03,300 --> 00:19:18,320 They might gather secrets that Kubernetes provides to pods because Kubernetes has a whole thing where it needs to provide configurations to pods because you're really supposed to make those pods come up with a static image. 267 00:19:18,320 --> 00:19:26,760 So the idea is the pod starts with a static, totally replaceable image and pulls whatever information it needs from elsewhere. 268 00:19:27,280 --> 00:19:30,120 You might connect to the Kubernetes dashboard to perform actions. 269 00:19:30,120 --> 00:19:32,340 Maybe it wasn't accessible from outside the cluster. 270 00:19:32,340 --> 00:19:34,520 God hope, or gosh hope. 271 00:19:35,140 --> 00:19:36,500 What else? 272 00:19:36,500 --> 00:19:40,880 The attacker might find a way to interact with the etcd server and change the cluster state. 273 00:19:40,880 --> 00:19:48,820 A nice way if there are network access control rules, network policies in place that are getting in your way. 274 00:19:48,820 --> 00:19:54,140 If you can talk to the thing that stores them, yeah, you could potentially change them. 275 00:19:54,940 --> 00:20:08,280 And the other one, the one that's really fun to me for anything that's either in a cloud provider or even in an on-prem cloud, is that the attacker might interact with the cloud service provider. 276 00:20:08,380 --> 00:20:18,000 And because many workloads will, one way or another, and I'll show this to you too, will have privilege on the cloud provider. 277 00:20:18,060 --> 00:20:20,920 So, I'm going to show you a bunch of demos. 278 00:20:21,320 --> 00:20:23,320 And these demos are real. 279 00:20:23,320 --> 00:20:27,240 They're often things that we do in classes I teach. 280 00:20:27,240 --> 00:20:32,760 They're also, I'm going to tell you later on, we have an open source project and it's an intentionally vulnerable Kubernetes cluster. 281 00:20:32,760 --> 00:20:35,420 Call it, like, damn vulnerable Kubernetes cluster. 282 00:20:35,420 --> 00:20:37,380 This one's called BustaKube. 283 00:20:38,260 --> 00:20:43,460 We've got an Easter egg BustaMove video that you can find if you go to the BustaKube.com website. 284 00:20:44,240 --> 00:20:54,400 But, so, some of the things I'm showing you are basically available as scenarios that you can play in this open source, free, damn vulnerable Kubernetes cluster. 285 00:20:54,440 --> 00:20:59,220 So, I've done a thing where I've made my videos part of the slide. 286 00:20:59,300 --> 00:21:02,220 And so now I'm going to see if that actually works. 287 00:21:03,200 --> 00:21:04,580 Please work. 288 00:21:06,480 --> 00:21:10,060 And if it doesn't, we'll have to use YouTube one way or another. 289 00:21:10,200 --> 00:21:12,060 Or something else. 290 00:21:14,060 --> 00:21:15,020 Okay. 291 00:21:20,050 --> 00:21:21,850 Color me very embarrassed. 292 00:21:22,390 --> 00:21:24,470 Let's just see if this one's the one. 293 00:21:27,900 --> 00:21:29,860 You should always test your demos. 294 00:21:30,720 --> 00:21:32,580 Even when you record them. 295 00:21:32,700 --> 00:21:37,840 So , I tell you what, we're going to find another way to do it. 296 00:21:38,380 --> 00:21:44,740 And I am going to, let's see, I'm going to unplug from the projector for a second. 297 00:21:44,740 --> 00:21:49,100 Because that means I'm going to go and look at my own file system and I'd like to not share it. 298 00:22:20,880 --> 00:22:22,100 And here we go. 299 00:22:28,060 --> 00:22:30,360 Just embed the videos in the slides, they said. 300 00:22:30,460 --> 00:22:32,100 It'll be fun, they said. 301 00:22:34,640 --> 00:22:40,160 Anybody old enough to have played Warcraft and you click on the guy and he's like, what? 302 00:22:40,160 --> 00:22:42,100 And you click on him again and he says something else. 303 00:22:42,100 --> 00:22:44,960 And he says, you know, join the army, he said. 304 00:22:44,960 --> 00:22:46,640 See the world, he said. 305 00:22:46,640 --> 00:22:50,080 Okay, so here's our demo. 306 00:22:53,340 --> 00:22:57,420 And hopefully entering, oh, well that's not a demo. 307 00:23:02,500 --> 00:23:04,280 Is that a demo? 308 00:23:05,200 --> 00:23:07,600 That's not a demo either. 309 00:23:15,340 --> 00:23:17,200 Anybody seen my screen? 310 00:23:17,360 --> 00:23:18,660 There we go. 311 00:23:18,800 --> 00:23:22,040 Let's just hit this on mirror and call it a day. 312 00:23:23,340 --> 00:23:24,380 Okay. 313 00:23:26,580 --> 00:23:27,540 Cool. 314 00:23:28,900 --> 00:23:29,540 So... 315 00:23:30,360 --> 00:23:31,760 That's not the right... 316 00:23:35,540 --> 00:23:39,520 Don't mind me, I'm clearly a noob. 317 00:23:41,780 --> 00:23:43,860 I may need alcohol. 318 00:23:45,480 --> 00:23:51,200 So this is one of the BustaCube scenarios. 319 00:23:51,200 --> 00:23:54,380 So you go up and you see a WordPress site. 320 00:23:54,380 --> 00:24:00,040 And the WordPress site, I will tell you, is hosted in Kubernetes. 321 00:24:01,840 --> 00:24:06,640 And you fire up maybe Durbuster to go looking for hidden content. 322 00:24:07,320 --> 00:24:11,840 And Durbuster takes a little bit of time, but we can run it. 323 00:24:11,840 --> 00:24:13,680 And let's go a little faster. 324 00:24:13,680 --> 00:24:16,020 And what we find is backdoor.php. 325 00:24:16,180 --> 00:24:19,940 And so when we surf to backdoor.php, this is what happens. 326 00:24:19,940 --> 00:24:27,600 I get this thing where basically this WordPress instance, like so many other WordPress instances, has been pre-compromised for your convenience. 327 00:24:29,300 --> 00:24:33,900 So I type ID and it says your www data. 328 00:24:34,140 --> 00:24:38,700 And hopefully I shut down Durbuster because it always chews a ton of resources. 329 00:24:39,000 --> 00:24:40,400 Something we always say in class. 330 00:24:40,400 --> 00:24:41,840 My laptop's running slow. 331 00:24:41,840 --> 00:24:43,160 Have you turned off Durbuster? 332 00:24:43,160 --> 00:24:44,100 No! 333 00:24:44,140 --> 00:24:46,340 It's 500 requests a second. 334 00:24:46,340 --> 00:24:48,640 Well, that'll do something. 335 00:24:48,640 --> 00:24:58,420 So I'm going to stand up a quick little web server in Kali because I found that reverse shell. 336 00:24:58,420 --> 00:25:00,500 So I'm going to stand up a little web server. 337 00:25:00,500 --> 00:25:12,520 And my purpose of the web server is to be able to hand a meterpreter or if I wanted a whatever, some other kind of reverse shell. 338 00:25:12,520 --> 00:25:14,500 But I'm going to go for a meterpreter. 339 00:25:15,840 --> 00:25:26,060 And so I just put in here like, hey, could you please pull this meterpreter binary I've created from my web server and while you're at it, make it executable. 340 00:25:26,060 --> 00:25:27,800 And while you're at it, run it. 341 00:25:28,120 --> 00:25:31,280 And I like to fast forward my videos because who doesn't? 342 00:25:31,620 --> 00:25:35,080 And you go look at the web server and Mrs. 343 00:25:35,080 --> 00:25:38,560 Bin has been pulled the meterpreter binary but also a copy of kubectl. 344 00:25:38,560 --> 00:25:46,900 The command line utility that you use to do damage, I mean, to administer or use a Kubernetes cluster. 345 00:25:48,060 --> 00:25:50,300 So I'm going to pull kubectl. 346 00:25:50,680 --> 00:25:54,840 And the other thing I'm going to do is just make sure that it's landed here. 347 00:25:54,840 --> 00:25:55,820 So here's Mrs. 348 00:25:55,820 --> 00:25:57,500 Bin, my meterpreter binary. 349 00:25:57,620 --> 00:25:59,320 Here's kubectl. 350 00:25:59,500 --> 00:26:00,500 Cool. 351 00:26:06,090 --> 00:26:12,910 And now if recordedj will type a little faster, we'll run the meterpreter binary. 352 00:26:13,890 --> 00:26:22,550 And I'm going to go over to my Metasploit console and actually be like, oh, wait, I have an incoming meterpreter that needs to connect to the console. 353 00:26:22,550 --> 00:26:23,910 I should probably start the console. 354 00:26:24,890 --> 00:26:26,750 This ordering is just great, huh? 355 00:26:27,550 --> 00:26:29,270 But that's often how you work. 356 00:26:29,370 --> 00:26:31,550 So I'll interact with that session. 357 00:26:34,430 --> 00:26:36,570 And I'm now in a pod. 358 00:26:36,570 --> 00:26:37,690 I know, it doesn't look like it. 359 00:26:37,690 --> 00:26:42,410 It looks like an ordinary Metasploit, you know, pwned Metasploit instance. 360 00:26:43,950 --> 00:26:46,890 So, but I see my copy of kubectl, I'm happy. 361 00:26:46,890 --> 00:26:50,750 And when I run mount, I get a tremendous number of file systems. 362 00:26:50,750 --> 00:26:53,470 I'm not looking at one hard disk or what have you. 363 00:26:53,650 --> 00:26:58,550 And a bunch of them have been put there by Docker and by Kubernetes. 364 00:26:58,550 --> 00:27:04,650 And so the one that's really interesting to me is this one that says run secrets Kubernetes service count IO service account. 365 00:27:04,650 --> 00:27:11,010 As soon as I see that directory mounted, I know that I'm going to have some level of access to the API server and I'm happy. 366 00:27:11,330 --> 00:27:16,730 So I'm going to go and first I'm just going to go and collect my flag. 367 00:27:16,730 --> 00:27:19,650 I built this scenario as it captured the flag. 368 00:27:19,650 --> 00:27:21,710 So let's look at our little flag. 369 00:27:22,510 --> 00:27:24,610 And it says, hey, you've found the server's backdoor. 370 00:27:24,610 --> 00:27:26,790 You might notice this isn't your usual Linux system. 371 00:27:26,790 --> 00:27:27,610 You're in a cluster, my friend. 372 00:27:27,610 --> 00:27:29,010 It's time to bust a cube. 373 00:27:29,010 --> 00:27:30,830 This container doesn't have any more flags. 374 00:27:30,830 --> 00:27:32,510 Can you find your way to another pod? 375 00:27:32,510 --> 00:27:33,350 Hint, hint. 376 00:27:33,650 --> 00:27:39,710 So cool thing in Kubernetes is, like I said, one of the things you can do is see if you can move to another workload. 377 00:27:39,810 --> 00:27:41,190 So you're in a container. 378 00:27:41,190 --> 00:27:42,710 Can you move to another one? 379 00:27:42,710 --> 00:27:45,310 So I'm going to see what my service count can do. 380 00:27:45,310 --> 00:27:51,090 I'm going to go and look in that directory and that run secrets Kubernetes IO service count directory. 381 00:27:51,090 --> 00:27:54,530 If recorded J, we'll type just a little bit faster. 382 00:27:57,270 --> 00:28:00,910 And I look at that namespace and it says you're in the marketing namespace. 383 00:28:00,910 --> 00:28:03,010 So that directory has a token. 384 00:28:03,070 --> 00:28:05,930 It has the certificate authorities public cert. 385 00:28:06,330 --> 00:28:10,070 And it has a description of what namespace you're in. 386 00:28:10,070 --> 00:28:12,710 And that namespace, like I said, is kind of a way of organizing. 387 00:28:12,710 --> 00:28:14,310 So we're in the marketing namespace. 388 00:28:14,310 --> 00:28:15,670 We'll come back to that later. 389 00:28:15,670 --> 00:28:20,270 And then I'm also going to go and look at the environment variables that get pushed into every pod. 390 00:28:20,270 --> 00:28:24,970 And my environment variables will tell me where to find the Kubernetes API server. 391 00:28:25,090 --> 00:28:30,290 So there's this assumption in Kubernetes that every workload will need to ask Kubernetes to do things. 392 00:28:30,530 --> 00:28:33,370 I don't know if that's really the greatest assumption. 393 00:28:33,370 --> 00:28:36,850 But I think let's just call it not the strongest of defaults. 394 00:28:37,050 --> 00:28:40,990 So I've got the API server's IP address and port. 395 00:28:44,580 --> 00:28:45,980 And I'll clear my screen. 396 00:28:45,980 --> 00:28:53,100 And I'm going to set up a quick little kubectl where I'm saying alias kubectl to the path to kubectl. 397 00:28:53,100 --> 00:28:56,820 The token pasted in from this long path to the token. 398 00:28:56,820 --> 00:28:58,460 The certificate authority path. 399 00:28:58,580 --> 00:28:59,940 The namespace. 400 00:28:59,940 --> 00:29:01,740 And the server that I just got. 401 00:29:01,880 --> 00:29:05,160 And so every time I type kubectl, all that stuff will be passed in. 402 00:29:07,660 --> 00:29:11,000 So let's just kind of skip and let's see what did I do. 403 00:29:11,060 --> 00:29:13,860 So I said let's do a quick get pods. 404 00:29:13,860 --> 00:29:18,780 And get pods is honestly my go-to just to figure out if my setup is working. 405 00:29:19,000 --> 00:29:20,600 And so it says, oh, there's two pods. 406 00:29:20,600 --> 00:29:21,780 You're the WordPress one. 407 00:29:21,780 --> 00:29:24,080 And I ran host name and it says that's the one you're in. 408 00:29:24,120 --> 00:29:26,160 And then the WordPress MySQL one. 409 00:29:26,740 --> 00:29:27,820 And that's another one. 410 00:29:27,820 --> 00:29:29,180 So let me see if I can move over to it. 411 00:29:29,180 --> 00:29:30,620 Because that was what the hint said. 412 00:29:30,860 --> 00:29:32,900 So I'll do kubectl exec it. 413 00:29:32,900 --> 00:29:35,000 Looks a whole lot like docker exec it. 414 00:29:36,580 --> 00:29:38,920 And what program I'd like to add to that container. 415 00:29:38,920 --> 00:29:39,980 I'm going to add a shell. 416 00:29:40,100 --> 00:29:43,240 I get this kind of error, but I'm in the container. 417 00:29:43,240 --> 00:29:44,660 I've just moved over. 418 00:29:44,660 --> 00:29:46,660 And I've probably moved over to a different host. 419 00:29:46,660 --> 00:29:48,700 Like I'm probably somewhere else in the data center now. 420 00:29:49,460 --> 00:29:51,200 So there's another flag. 421 00:29:51,420 --> 00:29:52,980 And we'll go get our flag. 422 00:29:58,450 --> 00:30:00,730 And I can't clear my screen because my terminal is not set. 423 00:30:00,730 --> 00:30:04,450 So I set it to vt100 because that was one of my first back in the DBS days. 424 00:30:04,830 --> 00:30:06,870 Because I'm exceedingly old. 425 00:30:07,530 --> 00:30:10,050 And it says, hey, you found your way to another container. 426 00:30:10,050 --> 00:30:12,170 Actually, you're on a whole new virtual machine. 427 00:30:12,890 --> 00:30:16,490 Moving from one container to another in a Kubernetes system often means switching nodes. 428 00:30:16,490 --> 00:30:20,070 Your end goal is to get to the developer's non-containerized host. 429 00:30:20,070 --> 00:30:27,710 So it's to get not just to own the cluster potentially, but to get to a machine that's not in the cluster. 430 00:30:27,730 --> 00:30:29,810 So to get there, you're going to want to see if you can hop tenants. 431 00:30:29,810 --> 00:30:32,470 Tenants are usually separated by namespaces. 432 00:30:32,890 --> 00:30:34,930 So let's see what we can do. 433 00:30:36,910 --> 00:30:39,630 I know I'm fast-forwarding through my stuff, but... 434 00:30:39,630 --> 00:30:44,150 So I'm in the other... I'm in that MySQL one. 435 00:30:44,150 --> 00:30:45,290 I try to get pods. 436 00:30:45,290 --> 00:30:48,330 And the problem I'm running into is, hey, you're not allowed to get pods. 437 00:30:48,590 --> 00:30:51,270 So the cool thing is, I'm in a different service account. 438 00:30:51,270 --> 00:30:53,890 I was in the marketing WordPress service account. 439 00:30:53,890 --> 00:30:55,150 It's allowed to get pods. 440 00:30:55,310 --> 00:30:57,470 The marketing MySQL one can't. 441 00:30:58,070 --> 00:31:03,190 So over time, I might want to go around and pick up all these service accounts and hold on to them. 442 00:31:03,190 --> 00:31:04,370 Remember, it was just tokens. 443 00:31:04,370 --> 00:31:11,710 So if I can store all the tokens, I can end up building privilege wider than just what one thing had. 444 00:31:11,710 --> 00:31:15,130 So I did get nodes, and I found out the IP address for a node. 445 00:31:15,410 --> 00:31:18,230 Here's a name, but this node has an IP address. 446 00:31:20,130 --> 00:31:24,770 This one is running in a cloud provider. 447 00:31:25,090 --> 00:31:26,350 And there's a cool thing. 448 00:31:26,350 --> 00:31:28,730 So you can talk to the kubelet. 449 00:31:28,770 --> 00:31:33,570 And this is, thank gosh, finally not a default, but some clusters will have it. 450 00:31:33,570 --> 00:31:38,670 You can talk to the kubelet on, it's got a couple ports, 10.2.50. 451 00:31:38,670 --> 00:31:40,950 I'm going to go and say, can you give me a list of running pods? 452 00:31:40,970 --> 00:31:44,650 And it gives me JSON, because everything in Kubernetes is JSON and YAML. 453 00:31:44,950 --> 00:31:49,610 So I'll take that, and I'll run that again. 454 00:31:49,650 --> 00:31:52,350 And I apologize for this big block here. 455 00:31:52,350 --> 00:31:55,670 So I'll run that again, and I'll add some JQ, JSON query. 456 00:31:55,730 --> 00:31:57,250 Really good tool to learn. 457 00:31:57,250 --> 00:32:03,150 And I'm going to say, give me all the pods, kind of better formatted, give me their name and their namespace. 458 00:32:03,550 --> 00:32:10,130 And what I'm looking for is to see if there's a pod that's in another namespace besides the marketing one. 459 00:32:10,130 --> 00:32:11,490 And I quickly find one. 460 00:32:11,490 --> 00:32:12,790 There's a devpod. 461 00:32:22,030 --> 00:32:24,090 And that devpod... 462 00:32:24,090 --> 00:32:29,710 So Kubernetes loves to tell you about anything you want, and that's really, really nice as an attacker, especially if you can script it. 463 00:32:30,030 --> 00:32:32,910 So I've got devsync, I've got devweb. 464 00:32:32,910 --> 00:32:35,950 These are two containers that are running in the same pod. 465 00:32:35,950 --> 00:32:38,470 I've got the image they came from, so they're up on Docker Hub. 466 00:32:38,470 --> 00:32:40,110 You could pull them yourself if you wanted. 467 00:32:42,190 --> 00:32:46,210 And as an attacker, that's often what you're doing, is basically saying, well, what workloads are running? 468 00:32:46,210 --> 00:32:50,330 And can I go look in container images and see if there are any secrets or anything that would be really helpful to me? 469 00:32:50,410 --> 00:32:54,830 It's very, very nice of the defenders to hand you descriptions of their workloads. 470 00:32:56,410 --> 00:32:57,750 So I'm going to look at that. 471 00:32:57,750 --> 00:32:59,810 I'm going to run another command, and this is... 472 00:32:59,810 --> 00:33:00,810 I did running pods. 473 00:33:00,810 --> 00:33:05,310 I'm going to tell the kubelet, hey, would you mind just executing a command for me? 474 00:33:05,310 --> 00:33:10,230 So I'm going to pass it run, and then the namespace, the pod, and the container name. 475 00:33:10,430 --> 00:33:13,470 And I'll do command equals id. 476 00:33:13,850 --> 00:33:16,090 And I get an error code that says basically no. 477 00:33:16,090 --> 00:33:19,530 Either there's no shell in there, or I'm not allowed. 478 00:33:19,530 --> 00:33:22,110 I will tell you that there's no shell in there. 479 00:33:22,630 --> 00:33:25,730 But remember, there were two containers in that pod. 480 00:33:25,730 --> 00:33:32,690 So I saw devsync and devweb, and that's a really common thing you see outside of containerized environments. 481 00:33:32,690 --> 00:33:40,250 Like you have a web server, and you have something that's there to pull it content in from wherever that content's being created or stored. 482 00:33:40,370 --> 00:33:46,270 So I was hoping I could get to devsync, because it'll have the credentials for pulling content. 483 00:33:46,270 --> 00:33:47,710 It'll have an SSH key. 484 00:33:47,790 --> 00:33:50,290 I couldn't, so let me try devweb. 485 00:33:55,690 --> 00:33:57,350 So devweb I can run commands in. 486 00:33:57,350 --> 00:33:58,110 I ran id. 487 00:33:58,110 --> 00:34:00,630 It says, yeah, that thing's even running as root. 488 00:34:00,630 --> 00:34:01,650 Very nice. 489 00:34:05,420 --> 00:34:06,940 And so let's try a different command. 490 00:34:06,980 --> 00:34:08,380 Let's look at the file system. 491 00:34:08,380 --> 00:34:09,560 Oh, look, another flag. 492 00:34:11,280 --> 00:34:12,500 I like flags. 493 00:34:14,200 --> 00:34:20,620 I love doing CTFs, and I love doing CTFs actually, like, first doing them as an attacker, and then going and basically doing them as a defender. 494 00:34:20,620 --> 00:34:25,820 How much of the attack can I break with proactive stuff? 495 00:34:25,820 --> 00:34:29,360 With stuff that you could have thought of before you knew that you had the vulnerability? 496 00:34:29,640 --> 00:34:32,240 So this thing says, hey, you're not in the marketing department anymore. 497 00:34:32,240 --> 00:34:34,220 You're in the development department's namespace. 498 00:34:34,320 --> 00:34:37,900 So can you go take over the development department's non-containerized machines? 499 00:34:37,900 --> 00:34:46,280 And they're big fans of The Matrix, so it's named Mainframe, named for the machine's mainframe that may or may not have been in the second and third movie, depending on your religious beliefs. 500 00:34:46,280 --> 00:34:56,000 There are many people I know who acknowledge the truth as they believe it, that there were no second and third Matrix movies. 501 00:34:57,080 --> 00:34:59,320 Only quests for more money. 502 00:34:59,700 --> 00:35:00,700 So here we go. 503 00:35:00,700 --> 00:35:04,940 So we've got... we're trying to do a get pods. 504 00:35:04,940 --> 00:35:18,040 So I'm in one pod asking the kubelet on another host if it minds running commands in another pod, and I'm asking that pod to run kube control commands. 505 00:35:18,420 --> 00:35:24,240 I find out, okay, dev app isn't allowed to list pods, but it's kind of cool. 506 00:35:24,240 --> 00:35:26,280 I now know that I've got a third service account. 507 00:35:26,280 --> 00:35:28,940 I've got the dev dev app one. 508 00:35:28,940 --> 00:35:30,660 So I'll try get secrets. 509 00:35:30,940 --> 00:35:32,540 Let's see what secrets are available. 510 00:35:32,540 --> 00:35:33,280 Oh, nice. 511 00:35:33,280 --> 00:35:36,220 There's a mainframe login and an SSH key. 512 00:35:36,520 --> 00:35:42,960 Well, the two pods in there, the two containers in there are going to likely have access to the same secret. 513 00:35:43,800 --> 00:35:45,520 They've been placed in the same place. 514 00:35:45,520 --> 00:35:48,520 They don't necessarily need it in dev web, but what the hell. 515 00:35:49,000 --> 00:35:51,420 Let's go and ask for a copy of that secret. 516 00:35:54,260 --> 00:35:58,620 And I promise the next demo is hackers themed and choose your own adventure. 517 00:35:58,620 --> 00:36:00,360 So we're going to have some fun. 518 00:36:02,440 --> 00:36:04,340 So here's our SSH key. 519 00:36:04,340 --> 00:36:05,960 And you're like, that doesn't look like an SSH key. 520 00:36:05,960 --> 00:36:07,480 And that's because it's a secret. 521 00:36:07,720 --> 00:36:10,200 It's opaquely encoded. 522 00:36:10,260 --> 00:36:11,900 It's base 64 encoded. 523 00:36:11,900 --> 00:36:14,100 So we can decode it. 524 00:36:15,080 --> 00:36:17,660 And boom, there's our SSH private key. 525 00:36:18,060 --> 00:36:21,640 And we can do the same thing with the other secret here. 526 00:36:21,640 --> 00:36:24,440 So we can find out basically what is it used for. 527 00:36:24,440 --> 00:36:33,140 So I'm just going to fast forward a little bit and tell you that it's a user and a host in AWS. 528 00:36:33,580 --> 00:36:35,420 But not part of the cluster. 529 00:36:35,660 --> 00:36:38,600 So now we could SSH into that. 530 00:36:38,620 --> 00:36:40,980 And we're in the developer's mainframe. 531 00:36:41,000 --> 00:36:43,240 And it says, hey, you made it to the machine mainframe. 532 00:36:43,240 --> 00:36:46,940 Can you, for extra credit, can you get credentials to take over the whole cloud environment? 533 00:36:47,740 --> 00:36:49,260 And we can do that. 534 00:36:49,260 --> 00:36:54,380 But I'm going to set the rest of that aside because we do that in another demo. 535 00:36:54,760 --> 00:36:57,020 So let's see. 536 00:36:58,300 --> 00:37:00,480 Let me go back to the slides for a second. 537 00:37:03,260 --> 00:37:07,360 And here was our... and I'm sure that I'll be... 538 00:37:07,360 --> 00:37:15,460 because of the vagaries of having the videos in a separate program, I'm sure I'm going to be doing a little bit of going back and forth and having the whole screen do this. 539 00:37:15,460 --> 00:37:17,100 So here's our attack path. 540 00:37:17,100 --> 00:37:19,380 We got an interpreter in the WordPress container. 541 00:37:19,480 --> 00:37:22,120 We moved in the MySQL container with the kubectl exec. 542 00:37:22,220 --> 00:37:32,280 We used the MySQL container's totally unfettered network access inside the cluster to reach a kubelet that we wouldn't have been able to reach from outside the cluster on the master node. 543 00:37:32,280 --> 00:37:36,740 And that kubelet let us basically take a look at... 544 00:37:37,840 --> 00:37:41,680 run commands in another container in another namespace. 545 00:37:41,720 --> 00:37:47,400 And from that other container in that other namespace, we figured out there were secrets. 546 00:37:47,400 --> 00:37:48,440 There was an SSH key. 547 00:37:48,440 --> 00:37:49,740 So we got that SSH key. 548 00:37:49,740 --> 00:37:52,960 We authenticated to the high-value developer machine. 549 00:37:53,180 --> 00:37:57,240 And later on, we ended up getting to take control of the AWS account. 550 00:37:57,240 --> 00:38:01,780 And we're going to skip that right now because we're going to do that in a much more fun way. 551 00:38:02,760 --> 00:38:05,800 So we're going to play Hacker's Choose Your Own Adventure. 552 00:38:06,540 --> 00:38:09,340 And I'm going to drink some water for a second because whoa. 553 00:38:12,120 --> 00:38:12,640 So... 554 00:38:14,400 --> 00:38:15,960 I like the movie Hackers. 555 00:38:15,960 --> 00:38:17,780 It's a fun movie. 556 00:38:18,120 --> 00:38:19,740 It is an oldie but goodie. 557 00:38:19,740 --> 00:38:21,720 It is thoroughly realistic. 558 00:38:21,720 --> 00:38:32,260 We all know that whenever we're hacking, we see strange translucent 3D models of buildings, and we fly through a city, and it's really cool. 559 00:38:32,260 --> 00:38:38,100 And all of that was clearly done with the technology that had Apple IIs and floppy disks. 560 00:38:39,580 --> 00:38:42,660 So, I mean, I remember 3D rendering back then. 561 00:38:42,660 --> 00:38:43,260 I wasn't doing it. 562 00:38:43,260 --> 00:38:44,620 I was watching people do it. 563 00:38:44,620 --> 00:38:46,880 And yeah, no, none of that. 564 00:38:47,160 --> 00:38:48,540 So here we go. 565 00:38:48,540 --> 00:38:50,100 So we're going to start here. 566 00:38:50,560 --> 00:38:53,940 And again, this is where I have embedded video. 567 00:38:54,580 --> 00:38:57,840 So we will, unless I click on that and it works. 568 00:38:58,440 --> 00:38:59,520 Let's see. 569 00:39:00,340 --> 00:39:01,840 Oh, hey, look at that. 570 00:39:03,100 --> 00:39:06,060 Now, can we full screen that? 571 00:39:07,980 --> 00:39:09,720 Is there a way? 572 00:39:10,060 --> 00:39:13,380 No, so we're going back to oldie but goodie. 573 00:39:14,000 --> 00:39:15,680 And here we are. 574 00:39:15,680 --> 00:39:19,080 So first, this is going to look a little familiar. 575 00:39:19,560 --> 00:39:23,220 So we've got a, we've got, what's that? 576 00:39:24,380 --> 00:39:28,500 Oh, well, you're on the slide and I'm on the video. 577 00:39:28,500 --> 00:39:30,340 Okay, boom. 578 00:39:32,960 --> 00:39:34,760 And switch. 579 00:39:35,340 --> 00:39:36,620 Come on. 580 00:39:37,460 --> 00:39:39,620 I'm going to Windows computers soon. 581 00:39:41,540 --> 00:39:44,140 And that's a lot for me to say, trust me. 582 00:39:44,140 --> 00:39:46,380 So anyway, here we go. 583 00:39:46,840 --> 00:39:50,760 So we've got the, we've got the Gibson control room. 584 00:39:50,760 --> 00:40:05,340 We have Penn from Penn and Tower, who's apparently a techno weenie, according to Ben from Short Circuit, who somehow was playing an Indian and talking about Mr. 585 00:40:05,340 --> 00:40:06,380 Johnny Five. 586 00:40:06,440 --> 00:40:07,320 But Mr. 587 00:40:07,320 --> 00:40:09,100 Johnny Five here was the plague. 588 00:40:09,620 --> 00:40:14,720 And , and we have this nice little form that's called the Gibson control room. 589 00:40:14,720 --> 00:40:18,260 And the Gibson control room clearly lets you like leave a message. 590 00:40:18,260 --> 00:40:24,140 So it's based on a, it's based on a actual, on a Kubernetes documentation vulnerable app. 591 00:40:24,140 --> 00:40:27,660 They didn't mean for it to be vulnerable, but it's only a little vulnerable. 592 00:40:27,660 --> 00:40:29,700 So I've added a vulnerability to that. 593 00:40:29,780 --> 00:40:39,720 So the, so what we've got is I look at the source on that page and I find that the form is basically being provided by some JavaScript. 594 00:40:39,720 --> 00:40:54,060 So if I go look at that JavaScript, what happens when you submit the form is you're, you're referencing guestbook.php, you're sending to guestbook.php, you're saying, hey, command set, key messages, value this. 595 00:40:54,420 --> 00:40:55,340 Okay, really? 596 00:40:55,340 --> 00:41:00,900 You're going to let me, you're going to let me decide what, what key I'm going to set? 597 00:41:00,900 --> 00:41:04,960 You're not just going to have me set whatever key, you know, was meant to be set by this form? 598 00:41:05,000 --> 00:41:06,560 So that was their bug. 599 00:41:07,760 --> 00:41:13,920 And what I've added to it is I have something that actually runs code out of a different Redis key in this, you know, back in Redis database. 600 00:41:14,180 --> 00:41:16,500 So we go and take the Gibson control room. 601 00:41:16,760 --> 00:41:22,540 And if we were to type a message, you know, it shows up, this is the intended, this is the intended purpose. 602 00:41:22,880 --> 00:41:31,700 But instead, we're going to paste that same thing that happens when you submit the form, except instead of the message key, we're going to try a different key. 603 00:41:31,700 --> 00:41:34,440 Or we'll try a, let's see how it works. 604 00:41:34,440 --> 00:41:35,620 We're going to hit foo. 605 00:41:37,640 --> 00:41:40,660 And we'll put in just some key, some random key. 606 00:41:40,660 --> 00:41:41,520 Oh, cool. 607 00:41:41,520 --> 00:41:44,340 Okay, so JavaScript's probably updating that key. 608 00:41:44,600 --> 00:41:47,220 Let's try going to status PHP. 609 00:41:47,220 --> 00:41:51,300 So I'm asking you to imagine that we did a DurrBuster or looked at robots.txt. 610 00:41:51,300 --> 00:41:52,860 We found a status PHP. 611 00:41:52,860 --> 00:41:56,080 I'm not doing it because, well, I'd like to spend our time on Kubernetes. 612 00:41:56,220 --> 00:41:58,040 So I go to the status PHP page. 613 00:41:58,040 --> 00:41:59,440 It says, hey, no command to run. 614 00:41:59,440 --> 00:42:05,740 I'm going to set the Redis key, the Redis command key to this so that you can reload the page and that will get run. 615 00:42:05,840 --> 00:42:11,040 So if I reload the page, I get the output of, you know, I get the output of crawling that web server. 616 00:42:11,040 --> 00:42:17,460 It says all services are operational here at, what was it, Ellington Mineral or Ellington Mineral? 617 00:42:17,460 --> 00:42:18,520 Ellington, I think. 618 00:42:19,620 --> 00:42:23,300 So, well, as long as there's a command key, let's go and set it. 619 00:42:23,300 --> 00:42:33,160 And I've set my command key now to environments, to run environments, like we did before, to find a Kubernetes cluster, to find the Kubernetes API server. 620 00:42:33,160 --> 00:42:34,400 And here we go. 621 00:42:34,400 --> 00:42:42,880 So we know that once we're in a workload, if we reach out to 10.96.01, we'll get to the Kubernetes API server. 622 00:42:42,880 --> 00:42:45,540 So I'm going to go a little further, kind of similar to last time. 623 00:42:45,540 --> 00:42:47,180 I'm going to curl in. 624 00:42:47,180 --> 00:42:53,260 I'm going to tell this thing, excuse me, would you just pull in a reterpreter binary I created and connect back to me? 625 00:42:53,620 --> 00:42:55,920 So I have it pull it in. 626 00:42:55,920 --> 00:42:57,500 I set that key. 627 00:42:57,500 --> 00:42:59,820 And now when I run status, the page hangs. 628 00:42:59,840 --> 00:43:05,260 I love when pages hang when I've just given them binaries because it generally means the binary is running successfully. 629 00:43:05,600 --> 00:43:11,780 So if I go over to my terminal where I've got a Metasploit handler waiting this time, I find there's a session waiting for me. 630 00:43:11,780 --> 00:43:24,460 And the first thing I'm going to do before I start interacting with a shell there is I'm going to upload a copy of kubectl, which I've stored on this Kali system in this directory. 631 00:43:24,460 --> 00:43:28,280 So I put kubectl and I'm going to upload some YAML, which we'll get to later. 632 00:43:30,500 --> 00:43:34,680 So I've uploaded some YAML, which we may or may not get to later, depending on your choices. 633 00:43:34,680 --> 00:43:37,720 And I've asked for a shell, hit PWD. 634 00:43:38,460 --> 00:43:40,960 Looks like my video is cut off by one character. 635 00:43:40,960 --> 00:43:41,580 I hit ID. 636 00:43:41,580 --> 00:43:43,700 It says you're wwwdata user. 637 00:43:45,280 --> 00:43:47,120 I try SSHing. 638 00:43:47,840 --> 00:43:52,500 Well, I don't know what I tried because that was the end of that part. 639 00:43:52,500 --> 00:43:56,740 And now we're going to do this part so that we're a little bit gentler. 640 00:43:57,140 --> 00:44:00,920 I'm going to ask you, so do you want to try... 641 00:44:00,920 --> 00:44:05,960 The YAML files that I put up were ones that would mount a volume on the... 642 00:44:05,960 --> 00:44:07,940 that would try to mount a volume on the host. 643 00:44:07,940 --> 00:44:10,300 Like they'd try to mount the host's own directory. 644 00:44:10,300 --> 00:44:14,700 The old, you know, Docker, you know, start a container mounting the host. 645 00:44:14,700 --> 00:44:21,680 So do you want us to start the host mounting pod and see if we can take over a node? 646 00:44:21,720 --> 00:44:23,960 Or do you want us to exec into another pod? 647 00:44:26,450 --> 00:44:30,690 I heard the host mount first, so we'll try that. 648 00:44:30,690 --> 00:44:32,850 So let's see. 649 00:44:38,520 --> 00:44:39,540 Boom. 650 00:44:39,760 --> 00:44:40,740 And boom. 651 00:44:40,740 --> 00:44:42,020 Here we are. 652 00:44:42,600 --> 00:44:44,320 Run that front end. 653 00:44:45,340 --> 00:44:49,680 And we'll set kubectl executable so we can run it. 654 00:44:49,960 --> 00:44:53,160 We'll go and set up our kubectl. 655 00:44:53,460 --> 00:44:55,800 We'll try to run kubectl apply. 656 00:44:55,800 --> 00:44:58,720 Realize, wait, we've got to set all those parameters we set before. 657 00:44:58,780 --> 00:45:00,300 Sometimes you get lucky. 658 00:45:00,300 --> 00:45:09,580 And so I'm going to take that same directory, that same run secrets kubernetes.io service account that's being mounted into the pod. 659 00:45:09,860 --> 00:45:16,040 I'll set a variable called dir to that, export dir to that, just to make this a little bit easier to type, a little more manageable. 660 00:45:16,940 --> 00:45:21,580 So if I look at the dir, got the cacert, namespace, token, just like before. 661 00:45:22,440 --> 00:45:24,500 Let's go and run. 662 00:45:24,680 --> 00:45:28,220 Alias kubectl is going to mean that, same way we did before. 663 00:45:33,150 --> 00:45:36,130 So server's out on 1096.01. 664 00:45:36,130 --> 00:45:38,190 That was what we found from that environment variable. 665 00:45:38,430 --> 00:45:42,110 And now let's look at our alias. 666 00:45:42,110 --> 00:45:44,290 That's that token being pasted in. 667 00:45:44,290 --> 00:45:46,090 So kubectl get pods. 668 00:45:46,170 --> 00:45:47,790 Cool, we've got front ends. 669 00:45:47,790 --> 00:45:49,030 We've got front end pods. 670 00:45:49,030 --> 00:45:50,530 We've got a Redis master. 671 00:45:50,750 --> 00:45:54,130 We've got an Apache status, that thing we saw before. 672 00:45:54,130 --> 00:45:55,610 We're in the front end. 673 00:45:55,930 --> 00:45:58,730 So let's try launching a pod. 674 00:45:58,730 --> 00:46:01,550 kubectl apply. 675 00:46:02,670 --> 00:46:04,170 I like it as kubectl attack. 676 00:46:04,460 --> 00:46:05,670 Attack pod. 677 00:46:05,670 --> 00:46:11,990 And it says, sorry, your service count, front end, isn't allowed to create resources. 678 00:46:12,290 --> 00:46:13,790 Wah, wah. 679 00:46:15,210 --> 00:46:15,870 So... 680 00:46:16,550 --> 00:46:19,850 And this is where I get to my slide. 681 00:46:21,590 --> 00:46:24,450 So we'll do that real quick. 682 00:46:27,360 --> 00:46:30,040 I was considering for this one... 683 00:46:30,040 --> 00:46:31,260 Oh, damn it. 684 00:46:31,260 --> 00:46:33,480 Let's just keep the screen mirrored. 685 00:46:33,640 --> 00:46:40,200 So I was considering for this one doing a spandex quote from the movie. 686 00:46:40,200 --> 00:46:44,280 And I decided that wasn't a sentiment I wanted to voice. 687 00:46:45,640 --> 00:46:46,160 So... 688 00:46:47,100 --> 00:46:50,840 I see that I'm going to make sure that I'm moving on time. 689 00:46:50,840 --> 00:46:53,620 So at this point, we'll go back to our original... 690 00:46:53,920 --> 00:46:55,760 We'll go back to the other thing we could do. 691 00:46:55,760 --> 00:46:58,040 So our two options, where do we want to launch a pod? 692 00:46:58,040 --> 00:46:59,320 Or exec in a back end? 693 00:46:59,460 --> 00:47:01,380 So let's exec in a back end. 694 00:47:02,300 --> 00:47:04,600 Or let's try execing into another pod. 695 00:47:04,980 --> 00:47:08,360 So we'll go like we did in our other demo. 696 00:47:08,360 --> 00:47:09,980 We'll try execing into a pod. 697 00:47:11,840 --> 00:47:13,800 Keep wishing we had a better terminal. 698 00:47:17,440 --> 00:47:18,460 kubectl get pods. 699 00:47:18,460 --> 00:47:21,260 I see that there's a Redis, that Redis setup. 700 00:47:21,260 --> 00:47:24,040 Remember I was pushing Redis keys. 701 00:47:24,040 --> 00:47:28,080 I might try to investigate the Redis and see what else. 702 00:47:28,080 --> 00:47:30,680 Now that I've got more direct access to it. 703 00:47:30,900 --> 00:47:35,120 Because Redis is very often, well almost always, unauthenticated. 704 00:47:35,920 --> 00:47:38,140 But let's go into the Redis pod. 705 00:47:38,140 --> 00:47:39,440 So I'm rooted in there. 706 00:47:39,440 --> 00:47:40,680 I'm Redis master. 707 00:47:40,680 --> 00:47:43,080 I'll grab a copy of the meterpreter binary I've been using. 708 00:47:43,080 --> 00:47:46,460 Just because that's a very convenient way of putting files into something. 709 00:47:46,780 --> 00:47:48,620 And I'll background that. 710 00:47:48,620 --> 00:47:51,420 And I'm going to switch over. 711 00:47:51,420 --> 00:47:56,600 Now that I've got the Redis master, that pod running my meterpreter. 712 00:47:56,600 --> 00:48:00,820 So I'm going to switch over and catch that session. 713 00:48:02,520 --> 00:48:09,920 And so in that session, I'll go and upload the same kubectl that I did before. 714 00:48:09,940 --> 00:48:13,020 I'll also upload that attack pod that I just used before. 715 00:48:13,020 --> 00:48:16,140 And I'll also add something called attack daemon set. 716 00:48:16,460 --> 00:48:18,300 Just in case we need it. 717 00:48:18,300 --> 00:48:24,950 So now we get another choice. 718 00:48:24,950 --> 00:48:26,370 So you're in the back end. 719 00:48:26,370 --> 00:48:28,470 Do you want to try host mounting pods? 720 00:48:28,470 --> 00:48:31,250 Or do you want to check out the cloud APIs? 721 00:48:33,030 --> 00:48:34,250 Cloud APIs. 722 00:48:34,550 --> 00:48:35,310 Cool. 723 00:48:35,410 --> 00:48:37,570 Okay, so here we are. 724 00:48:41,020 --> 00:48:43,680 And I'm going to show you this in two ways. 725 00:48:45,360 --> 00:48:48,120 And can I get a rough time check? 726 00:48:48,120 --> 00:48:49,800 How much time will you let me be late? 727 00:48:49,800 --> 00:48:51,960 Oh, less than five. 728 00:48:51,960 --> 00:48:56,360 Okay, so this is where I normally kick on the speed control. 729 00:48:56,660 --> 00:48:58,280 So, okay, so we're in a pod. 730 00:48:58,280 --> 00:48:59,940 We're in that Redis master pod. 731 00:49:00,220 --> 00:49:03,280 And we say, hey, I'd like to talk to the metadata API. 732 00:49:03,280 --> 00:49:07,780 So every cloud provider gives you 169254, 169254. 733 00:49:07,780 --> 00:49:09,020 That part's common. 734 00:49:09,100 --> 00:49:12,460 What the calls are that you make against it, they document wonderfully. 735 00:49:12,520 --> 00:49:14,040 And you read the documentation. 736 00:49:14,080 --> 00:49:16,400 So this is on GCP. 737 00:49:17,000 --> 00:49:21,400 So I'm going to go and say, can you tell me what the project ID is? 738 00:49:21,400 --> 00:49:24,180 I need that project ID to do API calls. 739 00:49:24,320 --> 00:49:37,800 But then the more interesting one is usually where you say, would you mind, in addition to the project ID, which I'm going to set into a variable, would you mind telling me what service accounts are assigned to the machine I'm on? 740 00:49:37,800 --> 00:49:39,560 So the machine this pod's running on. 741 00:49:39,560 --> 00:49:42,340 And there are two, but default is mapped to that other one. 742 00:49:42,340 --> 00:49:44,680 So I'm just going to use default because it's easier typing. 743 00:49:45,820 --> 00:49:54,520 And I'm going to go and say, okay, for that service account, would you do me a favor and just give me a bearer token that I can use to act as that service account? 744 00:49:54,900 --> 00:49:56,060 And it says, sure. 745 00:49:56,760 --> 00:49:57,920 Here's your token. 746 00:49:57,920 --> 00:50:02,600 It expires in like a half an hour or an hour, but I've got a token. 747 00:50:02,600 --> 00:50:04,440 So I'll set a variable to that. 748 00:50:05,220 --> 00:50:11,500 And now what I'm going to do is say, let's go and I've set that token to that. 749 00:50:11,540 --> 00:50:13,200 And I need to refresh that token. 750 00:50:13,200 --> 00:50:17,260 So most of my commands will pull that token over and over, every command. 751 00:50:17,260 --> 00:50:22,100 So I'm going to use that token, type out authorization bearer token where the token's provided. 752 00:50:22,100 --> 00:50:28,160 Say I'll take JSON and now I'll say, hey, for this project, I'd like a list of buckets. 753 00:50:28,160 --> 00:50:30,060 And it says, oh, there's only one. 754 00:50:30,320 --> 00:50:32,400 Okay, well, what's in that bucket? 755 00:50:32,700 --> 00:50:35,820 And so I basically say, give me a list of objects. 756 00:50:37,060 --> 00:50:41,420 And the way I do that is it's like slash B for a list of buckets. 757 00:50:41,420 --> 00:50:45,440 Then it's the slash B, that bucket slash O for a list of objects. 758 00:50:45,440 --> 00:50:48,240 And then for those objects, I can run through them. 759 00:50:48,660 --> 00:50:53,700 Now, on this one, I don't find anything that's all that useful. 760 00:50:53,700 --> 00:50:57,660 I don't find, I find, I don't find what I find in some cloud environments. 761 00:50:57,660 --> 00:51:00,620 I'm going to show you in another demo somehow. 762 00:51:01,640 --> 00:51:04,300 And, but I do find a kubenv. 763 00:51:04,460 --> 00:51:10,960 So I can pull in a metadata instance for this cluster that was set by the installer. 764 00:51:10,960 --> 00:51:18,320 And when I do that, what I get out of it is, among other things, a couple service count tokens for the cluster. 765 00:51:18,320 --> 00:51:23,880 And that ends up leading, which I won't now show you, but that ends up leading to win. 766 00:51:23,960 --> 00:51:33,880 And so just for the end of our, for the end of that, that then leads to our crash and burn. 767 00:51:35,440 --> 00:51:42,020 So if, if Ming will let me have one more minute, I will show you a cooler version of that. 768 00:51:42,020 --> 00:51:47,380 We have a tool that we're, that we keep soft-releasing, but never kind of like putting up on Twitter. 769 00:51:47,380 --> 00:52:02,980 So it's called Paradis and Paradis will, if I, if I actually just, I'm just nervous. 770 00:52:02,980 --> 00:52:06,280 So it's in here, but somehow I'm, 771 00:52:12,160 --> 00:52:15,240 let's do this. 772 00:52:16,540 --> 00:52:22,680 So Paradis is basically a remote access Trojan for, for Kubernetes. 773 00:52:22,680 --> 00:52:25,540 You run this and it does all kinds of things. 774 00:52:25,820 --> 00:52:36,460 And I'm going to start this from the beginning, but it is under two minutes and then I will get the heck off the stage and tell you that you should ask me for stickers. 775 00:52:36,700 --> 00:52:38,180 So it's got a bunch of things. 776 00:52:38,180 --> 00:52:43,100 One of those I had said, okay, 13, go get the IM credentials from GCP. 777 00:52:43,240 --> 00:52:45,620 The same thing we just did, get the cloud service account. 778 00:52:45,620 --> 00:52:50,840 And then, come on Jay, type faster, highlight faster. 779 00:52:50,840 --> 00:52:53,260 So that's for that same one I just got. 780 00:52:53,540 --> 00:53:03,280 And now let's take that and let's pull, let's go looking in GCS in the storage buckets for service count tokens. 781 00:53:03,280 --> 00:53:15,020 Oh look, this installer, this one was COPS and left, left service count tokens there for all the components, including a cluster admin, which would be perfectly useful. 782 00:53:15,020 --> 00:53:33,260 And so that's the, like, basically, that's probably roughly what happened to Capital One recently, where it was talk to the metadata API, get your cloud account, use that to go rating for information or access. 783 00:53:33,940 --> 00:53:39,220 So anyway, so now once I've done that, Paradis will basically store every account it gets. 784 00:53:39,220 --> 00:53:42,100 And then you basically say, okay, I'm going to switch contexts. 785 00:53:42,100 --> 00:53:45,760 And you go and you go through and you collect all of the service count tokens. 786 00:53:45,760 --> 00:53:50,000 And then you basically have this big old store, that's your loot, and it keeps it in memory. 787 00:53:50,860 --> 00:53:54,140 And you run around and basically get more access and get more access. 788 00:53:54,140 --> 00:54:00,400 We've even got a, this video will be up on YouTube, but we've even got something that basically takes over the nodes. 789 00:54:00,480 --> 00:54:10,220 If it's allowed to mount a host path volume, it'll go and add a cron job that will send a netcat shell back to your, back to the IP address of your choice. 790 00:54:10,220 --> 00:54:17,420 So once we have this cluster admin, we're allowed to, we can go and do everything which included like, hey, now show me all the secrets. 791 00:54:17,420 --> 00:54:22,060 And all the secrets includes all of the tokens, all the service counts for every component. 792 00:54:23,220 --> 00:54:27,980 And Paradis will not just grab, will not just list these and get them, but it'll also store them and let you use them. 793 00:54:28,040 --> 00:54:29,960 So it's a fun little pen test tool. 794 00:54:30,780 --> 00:54:34,320 And it's up on GitHub, we'd love some help, we'd love some help producing it. 795 00:54:34,320 --> 00:54:37,980 So it's an NGuardians tool, we do a ton of Kubernetes work in NGuardians. 796 00:54:37,980 --> 00:54:41,680 And I will now get off the stage and take questions all the way out in the hallway. 797 00:54:41,860 --> 00:54:43,920 So if you see me, please ask me for a sticker. 798 00:54:47,140 --> 00:54:48,100 Thank you.