1 00:00:00,000 --> 00:00:07,240 She's one of Nany's Google Cloud Platform subject matter experts, which is just a few SME, a couple of TLAs. 2 00:00:08,520 --> 00:00:12,720 And she's really hard at work enhancing and delivering just a few things that's been coming up. 3 00:00:12,720 --> 00:00:14,940 So, round of applause for Shannon. 4 00:00:20,080 --> 00:00:21,580 Alright, hey everybody. 5 00:00:21,720 --> 00:00:26,660 If you cannot hear me at any point in the talk, just put up two hands. 6 00:00:26,660 --> 00:00:27,240 Ready everyone? 7 00:00:27,240 --> 00:00:27,860 Let's practice. 8 00:00:27,860 --> 00:00:28,960 One, two, three. 9 00:00:30,440 --> 00:00:31,720 Thanks, thanks guys. 10 00:00:31,720 --> 00:00:36,300 Okay, so, my name is Shannon McHale. 11 00:00:36,300 --> 00:00:38,320 I am 23 years old. 12 00:00:38,320 --> 00:00:40,460 I'm originally from Long Island, New York. 13 00:00:40,460 --> 00:00:45,940 So, when I talk really fast, throughout these 80 slides, when my accent comes out or from the above, you can do it. 14 00:00:46,100 --> 00:00:48,000 I'm a consultant for Mandiant. 15 00:00:48,000 --> 00:00:50,100 I was actually promoted recently. 16 00:00:50,160 --> 00:00:52,400 And this is my first time at DEF CON ever. 17 00:00:52,400 --> 00:00:53,240 And it's pretty fun. 18 00:00:53,240 --> 00:00:55,340 So, let's have some fun here. 19 00:00:57,840 --> 00:01:03,080 For today's talk, I'm going to be running through a little bit of a background and my motivation of the talk. 20 00:01:03,080 --> 00:01:05,960 I'm going to talk about each default that I have here today. 21 00:01:05,960 --> 00:01:07,100 I think there's like six. 22 00:01:07,340 --> 00:01:08,880 Why the default is bad. 23 00:01:08,880 --> 00:01:10,580 How to be abused by attackers. 24 00:01:10,860 --> 00:01:12,940 How to fix the default at scale. 25 00:01:12,940 --> 00:01:14,260 And then we're going to clap, clap, clap. 26 00:01:14,260 --> 00:01:15,500 And we're going to snip, snip, snip. 27 00:01:15,500 --> 00:01:16,620 Because we are in Vegas. 28 00:01:16,620 --> 00:01:17,320 Let's hear it. 29 00:01:18,680 --> 00:01:20,260 Get some energy. 30 00:01:21,520 --> 00:01:22,320 Yeah. 31 00:01:22,560 --> 00:01:23,360 Alright. 32 00:01:23,360 --> 00:01:27,740 So, the services we're going to look at today are Service Accounts and Qt Engine. 33 00:01:27,740 --> 00:01:30,580 I was going to go through the Storage Accounts and the Cloud Shell. 34 00:01:30,580 --> 00:01:31,920 But, we ran out of time. 35 00:01:31,920 --> 00:01:33,540 So, I'll have to come back next year. 36 00:01:35,700 --> 00:01:36,220 Alright. 37 00:01:36,220 --> 00:01:38,200 So, a little bit of story time. 38 00:01:38,820 --> 00:01:46,340 For the first five months of my full-time career, I studied to get my GCP Cloud Security Engineer certification. 39 00:01:46,720 --> 00:01:49,400 While studying, I would go through a lot of the training. 40 00:01:49,400 --> 00:01:50,580 I would look at the defaults. 41 00:01:50,580 --> 00:01:51,880 And I would go like, Ew. 42 00:01:52,420 --> 00:01:53,300 This is not good. 43 00:01:53,300 --> 00:01:55,280 I'm going to have to change this every single time. 44 00:01:55,280 --> 00:01:56,960 And I also went, Ooh. 45 00:01:56,960 --> 00:01:58,040 This is fun for me. 46 00:01:58,040 --> 00:02:01,840 Every time that I'm on a red team engagement, I can look for this. 47 00:02:02,200 --> 00:02:05,640 So, I thought that it would be a really good talk to end here. 48 00:02:05,900 --> 00:02:10,720 And the motivations behind that were really to help the users protect themselves. 49 00:02:10,720 --> 00:02:16,200 So, as you may know in cloud, it really is on the users to set up a really good structured environment. 50 00:02:16,900 --> 00:02:19,580 I'm not going to be going through a bunch of zero days today. 51 00:02:19,580 --> 00:02:21,420 I'm not really here to wreck GCP. 52 00:02:21,420 --> 00:02:23,040 I'm not going to really like GCP. 53 00:02:23,040 --> 00:02:25,080 That's why I spend all my time doing it. 54 00:02:25,860 --> 00:02:35,580 And as you go through this talk, a lot of the content has already been pointed out by researchers, by Google's publications themselves and their documentation. 55 00:02:36,300 --> 00:02:38,020 And there's going to be... 56 00:02:38,020 --> 00:02:44,000 I'm going to make a quick list of the defaults and how users should change them to protect themselves. 57 00:02:44,000 --> 00:02:56,280 I wanted them to have a quick list to look through to just run through as an engineer or a blue teamer to set up a systematic change across their organization with a policy and to harden their environment. 58 00:02:56,580 --> 00:02:59,660 Overall, though, these are things that attackers would abuse. 59 00:02:59,660 --> 00:03:01,380 I would abuse as a red teamer. 60 00:03:01,380 --> 00:03:05,760 We've seen attackers abuse them at Mandiant from our incident response side of the house. 61 00:03:05,920 --> 00:03:13,640 I'm really hoping the whole thing is easy to set up at the end of the day and that people can reference this talk, which I will re-record at a different time. 62 00:03:13,640 --> 00:03:18,380 And then they will be able to protect themselves. 63 00:03:18,380 --> 00:03:24,980 And also, just to get more people inspired with GCP, because I really like it and I want more people to learn about it and get excited about it, too. 64 00:03:25,980 --> 00:03:29,820 And then this is where my little Kanye West preachy moment comes in. 65 00:03:29,820 --> 00:03:34,960 So I also really think that DEF CON is here. 66 00:03:34,960 --> 00:03:41,940 And this is not just a ZP problem, but I like to think that I'm really passionate about protecting users. 67 00:03:41,940 --> 00:03:52,140 And I like to think that we come to these conferences not to just meet people and have fun and drink, but we come here to point out things so that they get fixed. 68 00:03:52,140 --> 00:03:56,600 Point out vulnerabilities so that they get fixed by the companies that are there. 69 00:03:56,600 --> 00:04:07,760 And I think that it is really good to tell vendors about this so that they get excited and that they also just set it up and fix it for their users. 70 00:04:07,760 --> 00:04:12,720 Kind of like baby-primping the environment for them so that they don't even have to think about it, but they're just safe. 71 00:04:14,540 --> 00:04:17,360 Unfortunately, the Illuminati makes that kind of hard. 72 00:04:18,600 --> 00:04:20,480 So it just needs to work, right? 73 00:04:20,480 --> 00:04:25,500 There's going to be many reasons that people have these settings in their environment. 74 00:04:25,500 --> 00:04:27,880 There's a reason that they are defaults in the first place. 75 00:04:27,880 --> 00:04:30,320 It's because it makes it all run a lot faster. 76 00:04:30,340 --> 00:04:31,780 And that's why they exist. 77 00:04:32,380 --> 00:04:40,060 So yeah, I understand that not everything in today's talk will be easy for everyone to turn off immediately and that they might have a use case for it. 78 00:04:40,060 --> 00:04:44,760 But in general, this is the best practice to do because it really can be leveraged in your environment. 79 00:04:45,180 --> 00:04:47,080 That's the end of my Kanye rant. 80 00:04:48,040 --> 00:04:49,560 Jesus is the best, though. 81 00:04:49,900 --> 00:04:50,880 Back to the story. 82 00:04:50,880 --> 00:04:56,160 I went up to my coworkers, my managers, and I said, like, this is a really good talk. 83 00:04:56,160 --> 00:04:57,180 I'm going to give it at DEF CON. 84 00:04:57,180 --> 00:04:58,280 It's going to be really fun. 85 00:04:58,540 --> 00:05:03,300 And they were kind of like, uh, you doing GCP? 86 00:05:03,500 --> 00:05:05,720 At DEF CON, are you going to call out some GCP stuff? 87 00:05:05,720 --> 00:05:14,340 Because I don't know if you guys have heard or not, but, uh, yeah, kind of risking a couple billion dollars up here. 88 00:05:14,340 --> 00:05:15,320 Yeah, no biggie. 89 00:05:15,320 --> 00:05:20,500 So me and Ian was just kind of like, okay, we're going to just, like, tell Google about this. 90 00:05:20,500 --> 00:05:22,060 We don't actually work for Google yet. 91 00:05:22,060 --> 00:05:25,780 We're a stacker company, so we can do whatever we want at Manium. 92 00:05:25,780 --> 00:05:28,960 But they were definitely like, uh, okay, we're going to tell them. 93 00:05:29,160 --> 00:05:32,940 And then Google gave me all the attention that my parents never did. 94 00:05:32,940 --> 00:05:35,920 So they met with me for a little while. 95 00:05:36,360 --> 00:05:37,620 They were really, really great. 96 00:05:37,620 --> 00:05:43,580 I only happened with a bunch of different researchers throughout DEF CON, Black Hat, both counties, but they really are good. 97 00:05:43,580 --> 00:05:45,480 They really do want things to be fixed. 98 00:05:45,580 --> 00:05:50,780 I got to meet with a lot of people really high up early in my career, which was really rewarding for me. 99 00:05:50,780 --> 00:05:57,340 And I got to ask them a lot of questions and talk problem-solve solutions to them to get the best recommendations. 100 00:05:57,340 --> 00:06:00,960 So a big thank you to Google for actually, like, giving me the time that I'll need. 101 00:06:00,960 --> 00:06:02,460 Because it was really nice. 102 00:06:02,820 --> 00:06:07,920 I also think it's good to point out that they are working on this in different ways. 103 00:06:07,920 --> 00:06:15,660 So GKE has Autopilot, which if you see here, there's just a list of security stuff and a list of, you know, optional stuff. 104 00:06:15,660 --> 00:06:22,420 And if you just went through the security one and you just said, ba-ba-ba-ba-ba, and you implemented all of them, you'd be pretty set up. 105 00:06:22,420 --> 00:06:23,840 So this is an option. 106 00:06:23,840 --> 00:06:24,920 It's something they're working on. 107 00:06:24,920 --> 00:06:29,520 I also would have put GKE in here because there are a lot of stuff that would be fun with. 108 00:06:29,520 --> 00:06:35,180 But overall, just so I don't get fired, for legal reasons, these are my opinions. 109 00:06:35,320 --> 00:06:36,240 They are not Google's. 110 00:06:36,240 --> 00:06:37,660 These are my recommendations. 111 00:06:37,660 --> 00:06:39,100 They are not Google's. 112 00:06:39,800 --> 00:06:40,700 Yeah. 113 00:06:40,940 --> 00:06:43,360 So let's get into it. 114 00:06:43,360 --> 00:06:44,340 Let's do this thing. 115 00:06:44,340 --> 00:06:45,260 Let's go. 116 00:06:46,600 --> 00:06:48,520 So, service accounts. 117 00:06:48,780 --> 00:06:53,880 The number one thing that has been talked about within GCP, actually, is the default service account. 118 00:06:53,880 --> 00:07:03,860 So this service account, every time you create a compute instance or an application in App Engine, this one service account will be created for your whole project. 119 00:07:03,860 --> 00:07:06,200 It's there to communicate with different APIs. 120 00:07:06,640 --> 00:07:09,660 And the default service account will be there. 121 00:07:09,660 --> 00:07:18,060 It will have editor role privileges, which means it will have 5,000 permissions and counting in your environment, which is a heck of a lot. 122 00:07:18,060 --> 00:07:23,480 This was actually presented on about 2018 by Dylan and Allison. 123 00:07:23,480 --> 00:07:25,400 They did a really good talk on it. 124 00:07:25,780 --> 00:07:27,780 And back then it was 2,000 permissions. 125 00:07:27,780 --> 00:07:29,120 Now it's up to 5,000. 126 00:07:29,120 --> 00:07:30,880 So it's only going to keep growing. 127 00:07:31,000 --> 00:07:36,780 And having this service account in your environment is a little bit risky just because it is so privileged. 128 00:07:37,120 --> 00:07:44,040 And we're going to talk about later how someone can actually privilege us to get access to that default service account. 129 00:07:44,320 --> 00:07:53,740 But for those of you who do not spend all your time researching GCP and have seen all this stuff, this has been talked about a lot, so I'm not going to go too into it. 130 00:07:54,220 --> 00:07:58,940 Yeah, these are all the resources that I'll post all of these slides later. 131 00:07:59,060 --> 00:08:01,500 But there's a lot of talks on this. 132 00:08:01,540 --> 00:08:07,320 So it's pretty much like getting AD in a Windows environment. 133 00:08:07,320 --> 00:08:09,000 This would be the equivalent of that. 134 00:08:09,440 --> 00:08:11,140 Google's also talked about this a lot. 135 00:08:11,140 --> 00:08:13,120 They have warnings all over. 136 00:08:13,120 --> 00:08:17,180 They have it in this documentation, in this documentation. 137 00:08:17,320 --> 00:08:19,160 They also have it in IAM. 138 00:08:19,160 --> 00:08:25,140 They have something phenomenal called IAM Recommender where they go, hey, you have a lot of excessive permissions. 139 00:08:25,140 --> 00:08:28,580 If you just want to click this button, we'll get rid of the ones you're not using. 140 00:08:28,580 --> 00:08:30,060 We've been tracking it for 90 days. 141 00:08:30,060 --> 00:08:31,060 We'll let you know. 142 00:08:31,960 --> 00:08:36,340 Yeah, not to put any more beats on that horse, you know, but it's kind of a big deal. 143 00:08:36,340 --> 00:08:38,040 And it's talked about a lot in the industry. 144 00:08:38,040 --> 00:08:41,180 So we won't look at it too, too much. 145 00:08:41,260 --> 00:08:43,280 There are some mitigations to fix this. 146 00:08:43,280 --> 00:08:45,020 You can create a better service account. 147 00:08:45,020 --> 00:08:51,340 You'll have to do this first before getting rid of the editor default service account, or else your whole thing is going to break. 148 00:08:51,340 --> 00:08:54,640 So always do the principle of least privilege. 149 00:08:54,640 --> 00:08:59,340 Again, IAM Recommender is a really good way to see what will work, what will not work. 150 00:08:59,380 --> 00:09:03,660 And then you can set an org policy where it never happens again throughout your organization. 151 00:09:03,800 --> 00:09:06,240 This org policy will just turn it off. 152 00:09:06,240 --> 00:09:08,180 No one can ever put it again. 153 00:09:08,340 --> 00:09:10,720 Like I said, IAM Recommender, great tool to use. 154 00:09:10,720 --> 00:09:12,400 Can't recommend it enough. 155 00:09:14,580 --> 00:09:19,080 Talking about the organization policies, I wanted to just show you what they look like. 156 00:09:19,080 --> 00:09:20,840 So they have the list and the Boolean. 157 00:09:21,020 --> 00:09:31,500 So everything I say today, you can either do a Boolean where it's true or false across your organization, or I wanted to let you know that you can also fit exceptions for where you might still need these things. 158 00:09:31,560 --> 00:09:38,640 So this is a really good thing, just for your knowledge, in case you're thinking, oh my gosh, how am I going to implement this? 159 00:09:40,260 --> 00:09:43,560 So service account key expiration, this is a fun one. 160 00:09:43,700 --> 00:09:47,780 So I went through to see how this would go from a default perspective. 161 00:09:47,860 --> 00:09:53,620 When you create the default service account, or any service account, there is no key automatically there. 162 00:09:53,620 --> 00:10:02,000 So you go in, you add a key, you hit the add key button in the console, really cool. 163 00:10:02,220 --> 00:10:05,180 You decide what type of file you want it to be. 164 00:10:06,100 --> 00:10:09,740 And then you have a default service account key. 165 00:10:09,940 --> 00:10:12,020 Congratulations, very cool for you. 166 00:10:12,020 --> 00:10:13,140 You have a service account key, right? 167 00:10:13,140 --> 00:10:14,500 Easy peasy, one, two, three. 168 00:10:15,920 --> 00:10:16,740 That's it. 169 00:10:16,740 --> 00:10:19,660 And yeah, we'll be there until I'm 8,000 years old. 170 00:10:19,840 --> 00:10:25,360 So that is going to be there forever, and that's kind of the problem that I'm pointing out here. 171 00:10:25,420 --> 00:10:31,960 To change this expiration date, as you saw in the console, there was no option to have it within those steps. 172 00:10:31,960 --> 00:10:34,420 There was no, hey, how long do you want this to be here? 173 00:10:34,420 --> 00:10:37,200 And now that it exists, you actually cannot get rid of it. 174 00:10:37,200 --> 00:10:45,540 You can delete the account, you can delete the key altogether, but you cannot change the expiration date. 175 00:10:46,320 --> 00:10:49,400 Google does have some documentation on this. 176 00:10:49,400 --> 00:10:51,380 I'm sure there is more than just this. 177 00:10:51,400 --> 00:11:02,540 But they even say, yeah, so you can set an organization policy, which will be the theme of the presentation, that sets the keys to expire at a certain time. 178 00:11:02,540 --> 00:11:06,120 So the keys that already exist, again, will not be expired. 179 00:11:06,540 --> 00:11:09,060 They also recommend that this is not done in production. 180 00:11:09,060 --> 00:11:14,900 So you don't actually want to set up an expiration time in production because things could break. 181 00:11:14,900 --> 00:11:23,140 Instead, you should manage the key lifecycle by using tools like Key Rotator, or there are some other funky ways that you can do it. 182 00:11:23,140 --> 00:11:27,080 It's really particular to which services you use and what you're using it for. 183 00:11:27,080 --> 00:11:36,260 So Key Rotator, which is a Python script published by Google, is not a one-fits-all thing, but you should be rotating the key if it does exist. 184 00:11:37,040 --> 00:11:45,700 I do want to point out why this key freaks me out so much before giving you all of the mitigations for it, just so you understand why you should be going and fixing it. 185 00:11:46,160 --> 00:11:48,660 And that really comes in with service account logging. 186 00:11:49,020 --> 00:11:51,940 So I came across this blog from an ex-Googler. 187 00:11:52,020 --> 00:11:53,840 He wrote it in 2020. 188 00:11:53,840 --> 00:12:01,260 I don't know if he was even working for Google at the time, but at some point he was on the Strategic Security Engineer team, I think it's called. 189 00:12:01,820 --> 00:12:03,140 It's a great team. 190 00:12:03,140 --> 00:12:08,160 They produce really phenomenal blogs about how to best secure your infrastructure. 191 00:12:08,160 --> 00:12:10,080 I'll reference them a couple times here. 192 00:12:10,080 --> 00:12:16,060 But they think of really creative ways to do really secure implementations of cloud security architecture. 193 00:12:16,060 --> 00:12:17,180 So they're really great. 194 00:12:17,180 --> 00:12:22,920 He's not at Google anymore, but I thought it would be cool to just read this blog in 2022, two years later. 195 00:12:23,760 --> 00:12:27,820 And lucky enough, it was still something that I could play with. 196 00:12:27,820 --> 00:12:41,320 So when you use service account impersonation with the service account token creator privileges, you are saying, I'm going to impersonate this service account from the CLI. 197 00:12:41,320 --> 00:12:43,760 And the CLI will track who's doing this. 198 00:12:43,760 --> 00:12:48,720 So they will say, okay, Shannon is impersonating the default service account. 199 00:12:48,720 --> 00:12:53,680 And that will be logged there in the first party principal as a principal email. 200 00:12:54,800 --> 00:13:03,340 However, if you do authenticate using the service account key, it will not have that same log. 201 00:13:03,340 --> 00:13:07,180 It will not tell you who the principal email user was. 202 00:13:07,180 --> 00:13:12,740 It will just say that the service account key has been used. 203 00:13:13,000 --> 00:13:18,500 More so, which makes it very difficult to find patient zero in a incident, right? 204 00:13:18,500 --> 00:13:19,920 So you can't track it back. 205 00:13:19,920 --> 00:13:26,840 You would have to go see who created the key to begin with, and then track it back to them, and then see where it went from there, and blah, blah, blah. 206 00:13:26,840 --> 00:13:27,920 So it's a lot. 207 00:13:28,120 --> 00:13:31,320 It's not logged, is the point of that, in that way. 208 00:13:32,520 --> 00:13:37,100 Not to mention, there isn't actually logging when the key is used for authentication. 209 00:13:37,520 --> 00:13:40,660 So once you start running actions, GCloud will see it. 210 00:13:40,660 --> 00:13:43,080 So if you say, I want to list, I want to get, etc. 211 00:13:43,080 --> 00:13:46,320 It will be in the audit logs that the service account is completing these actions. 212 00:13:46,320 --> 00:13:52,220 But when someone actually authenticates with that key to your service account, there is no log for that. 213 00:13:52,480 --> 00:13:59,520 There is, however, a way to turn on, in monitoring, the use of a service account key. 214 00:13:59,520 --> 00:14:02,660 So it's just a dot that says, key has been used. 215 00:14:02,660 --> 00:14:04,700 There's not detailed logging of it. 216 00:14:04,700 --> 00:14:06,380 It's just saying that a key was used. 217 00:14:06,380 --> 00:14:07,440 And you have to set that up. 218 00:14:07,440 --> 00:14:08,720 It's not there by default. 219 00:14:08,720 --> 00:14:16,040 So it freaks me out a lot that you can use this key, which will almost never expire. 220 00:14:16,040 --> 00:14:18,420 It's usually more privileged than you were. 221 00:14:18,640 --> 00:14:23,420 And then you can, yeah, you don't really get logged too much. 222 00:14:23,420 --> 00:14:26,140 Not every single thing is logged when you're there. 223 00:14:26,140 --> 00:14:28,140 It's less attributable, etc. 224 00:14:28,140 --> 00:14:29,900 So, some things you can do. 225 00:14:29,900 --> 00:14:35,200 You can set up an organization policy to disable service account creations altogether. 226 00:14:35,900 --> 00:14:43,140 You can set an expiration time for your keys that are going to exist, not the ones that do exist. 227 00:14:43,140 --> 00:14:45,920 You can get rid of the ones that do exist altogether. 228 00:14:46,060 --> 00:14:51,780 You can set key rotation if you are using the keys in production. 229 00:14:51,780 --> 00:14:53,760 You should set up rotation for those. 230 00:14:53,760 --> 00:14:56,500 Work with your vendors to do that if they require it. 231 00:14:56,500 --> 00:14:58,560 And then you can use short-term access tokens. 232 00:14:58,560 --> 00:15:01,100 So that's how impersonation works in GCP. 233 00:15:02,740 --> 00:15:05,680 You're able to do that with that create service account token. 234 00:15:05,680 --> 00:15:13,860 There's a blog, again by that strategic team at Google, that goes through how you can set up one service account to impersonate the other. 235 00:15:14,000 --> 00:15:19,880 And you would have to impersonate that middle man to get to the other one instead of using the key. 236 00:15:19,880 --> 00:15:24,980 That last one will use the key for you, but at least it attributes to some principle at the end of the day. 237 00:15:26,140 --> 00:15:30,020 And then, of course, always follow the least privileged on service account. 238 00:15:30,940 --> 00:15:34,100 So that's the service account section of my talk. 239 00:15:34,440 --> 00:15:39,940 The compute engine section of my talk, we're now going to go through and make a compute engine. 240 00:15:39,940 --> 00:15:43,960 We're going to keep all the default settings there. 241 00:15:43,960 --> 00:15:46,240 We're going to make a Linux VM. 242 00:15:46,340 --> 00:15:48,060 It's going to be 1, 2, 3. 243 00:15:48,060 --> 00:15:49,140 We're going to use the console. 244 00:15:49,140 --> 00:15:52,000 This is like a developer wanting to test stuff really quick. 245 00:15:52,360 --> 00:15:54,280 Probably not at an enterprise level. 246 00:15:54,280 --> 00:16:01,300 They're going to be doing this one by one because they're going to be using Terraform hopefully or something like that to spin up machines with better setup. 247 00:16:01,800 --> 00:16:04,380 So yeah, just going to do that. 248 00:16:04,380 --> 00:16:05,820 Sorry, I don't have live demos. 249 00:16:05,820 --> 00:16:07,640 I don't take risks like that. 250 00:16:08,540 --> 00:16:09,560 And there we have it. 251 00:16:09,560 --> 00:16:12,100 We have a VM. 252 00:16:12,100 --> 00:16:13,400 It's a Linux VM. 253 00:16:13,540 --> 00:16:18,420 And it happens to have a public IP address. 254 00:16:18,420 --> 00:16:22,080 So that public IP address has nothing in between it and the Internet. 255 00:16:22,080 --> 00:16:23,780 It's very much so open to the Internet. 256 00:16:23,780 --> 00:16:28,120 It's there so that the developers who are using the machine can use the Internet. 257 00:16:28,420 --> 00:16:36,040 However, having the public IP directly accessible does open up your attack surface for attackers to get in. 258 00:16:36,360 --> 00:16:43,160 And I believe it would be safer if Google would implement something that forces a user to turn this on. 259 00:16:43,160 --> 00:16:46,180 So I'm not saying that no one should ever have public IP addresses, etc. 260 00:16:46,220 --> 00:16:48,040 I'm saying that it should be a choice. 261 00:16:48,040 --> 00:16:49,700 It should be something that's thoughtful. 262 00:16:49,700 --> 00:16:53,800 And it should be promoting that security mindset for people. 263 00:16:53,940 --> 00:16:55,400 Also, just a neat fact. 264 00:16:55,400 --> 00:17:00,740 Any internal IP, the first time you make a compute instance, it has the same internal IP. 265 00:17:00,740 --> 00:17:04,480 So that's kind of fun for me as an attacker because I know it might be there once I'm internal. 266 00:17:04,480 --> 00:17:06,500 So I just think GCP is neat. 267 00:17:06,500 --> 00:17:07,440 I like it. 268 00:17:07,820 --> 00:17:09,820 Some indications for this. 269 00:17:09,820 --> 00:17:16,000 There is, of course, an organization policy that prevents the external IP addresses from being made. 270 00:17:16,000 --> 00:17:20,760 This means that someone who does want an external IP address would have to go to their admin, etc. 271 00:17:20,760 --> 00:17:22,620 and say, please let me do this. 272 00:17:22,620 --> 00:17:26,960 And then hopefully the admin will make a good decision as to whether or not they should. 273 00:17:27,740 --> 00:17:39,500 Alternatively, if you want, you can set up Cloud NAT so that the instance-based proxy can be in between and then set up some identity access there. 274 00:17:40,800 --> 00:17:46,740 There's just some sort of boundary between the public one and the outside forces. 275 00:17:47,820 --> 00:17:53,160 Also, when you set up a default Compute Engine instance, you will have GCE firewall rules set up. 276 00:17:53,160 --> 00:17:55,220 There will be four firewall rules set up. 277 00:17:55,220 --> 00:17:56,560 Count 1, 2, 3, 4. 278 00:17:56,560 --> 00:18:03,240 It will be default allow ISCMP, default allow SSH, default allow internal, and default allow RDP. 279 00:18:03,240 --> 00:18:07,960 RDP and SSH will only matter if you're using a Windows host versus a Linux host. 280 00:18:07,960 --> 00:18:09,940 But yeah, it will be there. 281 00:18:09,940 --> 00:18:17,840 So allow SSH on the Linux host that we created will require key authentication, but it is there. 282 00:18:17,840 --> 00:18:24,820 So an attacker would need gcloud access in the first place to use it, which means they would have the IAM credentials to do it. 283 00:18:24,820 --> 00:18:29,780 And then they would also need a SSH key to get in from the outside. 284 00:18:30,940 --> 00:18:36,940 In addition to that, it would be RDP, which does not have the same keys, so there's no MFA on this. 285 00:18:36,940 --> 00:18:41,100 You do have to set a Windows password, so you would have to have Windows users using it. 286 00:18:41,100 --> 00:18:50,920 But if you have a Windows instance, then anyone can phish or do brute force attacks to get into the Windows machine that is there. 287 00:18:52,940 --> 00:18:58,360 Default allow internal, so there's just a lot that are there. 288 00:18:59,740 --> 00:19:17,840 So default allow internal, I don't think this is something that Google should actually change, or maybe it won't implement off of that, but it does allow people in the same VPC network, on your same subnet, to contact your box through any port that exists, 289 00:19:17,840 --> 00:19:25,480 which means it kind of promotes a chatbot for lateral movement or access to administrative services. 290 00:19:25,480 --> 00:19:37,740 So these are the administrative services that Vaniant has seen and used to abuse and get into different administrative services, not necessarily all lateral movement, but just to get access to those services. 291 00:19:38,320 --> 00:19:43,520 They're all remote admin ports, and this would be used for lateral movement, like I said. 292 00:19:43,520 --> 00:19:56,700 So just to set up some safe practices, it might be good to create a rule that would just block these, especially the top five, since we're seeing so many of those be abused by attackers. 293 00:19:56,700 --> 00:20:01,420 We always say that this is something that you should block when we're dealing with clients. 294 00:20:03,280 --> 00:20:09,740 So mitigations for this, configure a better default firewall rule on a per project basis. 295 00:20:09,740 --> 00:20:16,120 You'll have to do this, you'll have to delete the old ones and then add the new ones so that they work really well. 296 00:20:16,120 --> 00:20:23,580 You can also do an org policy then to skip the default network creation, you can set it to true. 297 00:20:23,580 --> 00:20:27,400 You can use Identity-Aware Proxy for TCP forwarding. 298 00:20:27,540 --> 00:20:33,780 And you can also set off that allow, internal, and block, all of those ports, that might be good. 299 00:20:33,780 --> 00:20:38,160 And then of course, add MFA on any of the administrative services where you can. 300 00:20:38,160 --> 00:20:38,460 So the 301 00:20:41,620 --> 00:20:45,700 default service account, once again, was created when we created the compute engine. 302 00:20:45,700 --> 00:20:51,580 So right there in the settings, we could have changed it, but since it was there, we wanted it to stay there. 303 00:20:52,360 --> 00:20:55,380 And we were just not changing anything, all things. 304 00:20:55,380 --> 00:20:58,100 We also needed it to work because I had to set up a different service account. 305 00:20:58,100 --> 00:21:01,940 So it has those 5,000 permissions at the project level. 306 00:21:02,840 --> 00:21:10,940 And from a compute instance, to access a compute instance, you need the IAM service account act as role. 307 00:21:10,940 --> 00:21:15,860 This means when you log on to the compute instance, you are acting as the service account. 308 00:21:15,860 --> 00:21:19,240 You are authenticated as the service account, as seen here. 309 00:21:19,240 --> 00:21:23,600 That top screen shot, that's gcloud offlist, that's telling me who I am right now. 310 00:21:23,600 --> 00:21:26,960 And it happens to be the default service account, just because I logged in. 311 00:21:26,960 --> 00:21:30,620 I didn't do anything else, I just accessed the box, and there I am. 312 00:21:30,900 --> 00:21:35,040 Other than that, you can also now contact the metadata. 313 00:21:35,040 --> 00:21:42,180 And the metadata actually has limited permissions versus the acting as the service account. 314 00:21:42,180 --> 00:21:51,340 So this is kind of cool, because when I learned about the default service account, I thought, oh no, anyone on the compute instance can automatically escalate and get all 5,000 of those permissions. 315 00:21:51,340 --> 00:21:52,820 But that's not actually true. 316 00:21:52,820 --> 00:22:05,020 You can actually scope down the permissions that you have on the compute instance with these access scopes that are listed there, instead of just giving them full editor roles. 317 00:22:05,020 --> 00:22:17,920 So this curl shows the permissions that I would have if I were to curl down the access token from the metadata and use it to impersonate the service account elsewhere. 318 00:22:18,640 --> 00:22:24,780 So what I decided to do, as I said here, you get permission denied. 319 00:22:24,780 --> 00:22:35,180 So even when I was acting as the service account and I tried to create keys, I wasn't allowed to, because of these scopes defined for the VM, and these are the default scopes that Google gives you. 320 00:22:36,360 --> 00:22:42,720 So the next thing I did was curl down that access token, and I wanted to see what I could do with specifically that. 321 00:22:42,880 --> 00:22:44,640 And here's where it gets interesting. 322 00:22:44,640 --> 00:22:52,280 So I decided to make a S3 bucket, not an S3 bucket, a storage bucket. 323 00:22:52,280 --> 00:22:56,180 And I set up this storage bucket. 324 00:22:56,180 --> 00:22:59,540 It had this Welcome to Good Burger. 325 00:22:59,540 --> 00:23:04,320 I put a picture in it, and I, as the editor, had access to it. 326 00:23:04,920 --> 00:23:15,300 So from the console, with the act as permissions, I was able to list the storage buckets that existed and find their name. 327 00:23:15,300 --> 00:23:21,580 And I was also able to list any of the items in it, so list objects. 328 00:23:22,780 --> 00:23:27,740 And then I was not able to copy into it, so access was denied for that. 329 00:23:27,960 --> 00:23:43,360 So I decided to go outside of my scope and take that access key that I had retrieved while on the VM and see if I can use that outside of my organization on an attacker box to pull down what objects were in the bucket. 330 00:23:43,360 --> 00:23:51,300 Now this wouldn't have been possible if I wasn't on the VM specifically, because you do need to know the name of the bucket to pull stuff down. 331 00:23:52,780 --> 00:24:02,300 So without the name of the bucket using the act as, I would not have been able to use the access token to list the names of the buckets. 332 00:24:02,300 --> 00:24:08,760 So you need both, but most likely you have that act as if you're able to access the metadata server in the first place. 333 00:24:08,760 --> 00:24:17,520 So I decided to pull down what was on the bucket, which as you can see there is an incorrectly spelled Danny DeVito picture. 334 00:24:18,200 --> 00:24:19,100 There he is! 335 00:24:19,100 --> 00:24:19,820 Got him! 336 00:24:19,820 --> 00:24:20,300 Woohoo! 337 00:24:20,300 --> 00:24:21,260 Hey Danny! 338 00:24:21,300 --> 00:24:26,800 So I pulled him down, and now that I have access to this, so why would an attacker do this? 339 00:24:26,800 --> 00:24:30,880 Obviously Danny DeVito is very valuable to our culture, to our society, yes. 340 00:24:30,880 --> 00:24:37,140 But an attacker would be doing this to pull down anything that's stored in the bucket. 341 00:24:37,140 --> 00:24:42,160 So that could be locks, financial information, anything that you put up there. 342 00:24:42,160 --> 00:24:47,500 And now that it's all offline and I have access to it, I am able to edit it. 343 00:24:47,500 --> 00:24:50,740 So I'm able to make him Dekon DeVito. 344 00:24:51,180 --> 00:24:51,740 Woohoo! 345 00:24:51,740 --> 00:24:53,120 Our new favorite game. 346 00:24:53,540 --> 00:24:54,440 And that's about it. 347 00:24:54,440 --> 00:24:56,580 So some mitigations for that. 348 00:24:56,640 --> 00:25:06,000 Again, you can see slide 25 when I post these slides and the recording to see what you can do to mitigate the default service account privileges. 349 00:25:06,520 --> 00:25:13,740 And make sure that you understand that anyone on the VM can access that VM service account and act as them. 350 00:25:13,740 --> 00:25:17,480 So you want to set the limited permissions on the service account. 351 00:25:17,480 --> 00:25:22,760 Enable the cloud platform access policy only when it's least privileged. 352 00:25:22,760 --> 00:25:24,040 So this is really interesting. 353 00:25:24,040 --> 00:25:39,740 Once you do the cloud platform access policy, instead of going in and setting up those individual policies that were listed, they will then have all of the permissions of the service account by using the cloud platform policy. 354 00:25:39,760 --> 00:25:43,420 And this is going to be used to get the full editor service account privileges. 355 00:25:43,420 --> 00:25:50,220 So if you are going to be doing this, you want to make sure that you have already set the least privileged service account possible. 356 00:25:50,660 --> 00:25:58,280 So scope down those permissions on your compute instance using those access scopes if you're going to use Compute Engine at any time. 357 00:25:59,500 --> 00:26:15,300 So in summary of the defaults to disable and limit the service account's default service account, the key expiration time, the logging of the authentication versus an impersonation, and then in Compute Engine, you're going to want to get rid of those public IP addresses. 358 00:26:15,440 --> 00:26:19,340 You're going to want to make sure RDP and SSH are not open to the internet. 359 00:26:19,340 --> 00:26:20,260 That would be cool. 360 00:26:20,260 --> 00:26:27,400 And then you want to make sure that your default service account and their access scopes are the least privileged as possible. 361 00:26:28,920 --> 00:26:29,880 And that's it. 362 00:26:29,880 --> 00:26:34,900 So if anyone wants to come pack cloud with me, I'm looking for GCP mentors. 363 00:26:34,900 --> 00:26:37,860 Not a lot of people do it, but it is a really cool cloud. 364 00:26:37,860 --> 00:26:39,920 You should all come work for Mannion. 365 00:26:39,920 --> 00:26:40,980 We do it with me. 366 00:26:40,980 --> 00:26:42,480 It'll be fun, you know? 367 00:26:42,480 --> 00:26:43,420 It'll be fun. 368 00:26:43,560 --> 00:26:46,560 So yeah, if you're interested in that, check out my Twitter. 369 00:26:46,780 --> 00:26:49,960 I've got some referral links up there if you're looking to red team cloud. 370 00:26:49,960 --> 00:26:51,120 But that's about it. 371 00:26:51,120 --> 00:26:52,580 Thank you so much for your time. 372 00:26:52,660 --> 00:26:53,820 Any questions? 373 00:27:12,470 --> 00:27:17,390 Have I seen any data-like compromises in my data link? 374 00:27:17,390 --> 00:27:18,410 No, I have not.