1 00:00:02,280 --> 00:00:04,640 all right 2 00:00:04,640 --> 00:00:08,400 so first talk of the day very exciting 3 00:00:08,400 --> 00:00:11,799 uh our first talk is by Ian Dylan Ian's 4 00:00:11,799 --> 00:00:13,440 a staff security engineer at the New 5 00:00:13,440 --> 00:00:15,480 York Times 6 00:00:15,480 --> 00:00:18,000 uh where he finally landed in Cloud 7 00:00:18,000 --> 00:00:19,840 security uh after having wandered in the 8 00:00:19,840 --> 00:00:22,439 desert for years as a software engineer 9 00:00:22,439 --> 00:00:24,960 DBA and Cloud engineer before coming to 10 00:00:24,960 --> 00:00:28,000 his senses uh in this presentation Ian 11 00:00:28,000 --> 00:00:30,080 will explain the common causes of GCR 12 00:00:30,080 --> 00:00:31,880 misconfigurations and how other gcp 13 00:00:31,880 --> 00:00:34,640 service defaults can widen that exposure 14 00:00:34,640 --> 00:00:36,719 the title of the talk is call me fish 15 00:00:36,719 --> 00:00:39,200 mail hunting sensitive Docker images and 16 00:00:39,200 --> 00:00:41,320 Google container registry leaks which 17 00:00:41,320 --> 00:00:43,559 I'm hoping for many sea shanties and 18 00:00:43,559 --> 00:00:45,520 whale puns I hear the best we're going 19 00:00:45,520 --> 00:00:47,680 to get might just be lots of cursing so 20 00:00:47,680 --> 00:00:49,360 you know Sailor 21 00:00:49,360 --> 00:00:53,280 Talk please welcome Ian thank 22 00:00:53,280 --> 00:00:54,960 you 23 00:00:54,960 --> 00:00:58,320 hey does this sound good oh God that's 24 00:00:58,320 --> 00:01:03,480 my own voice um so quick background on 25 00:01:03,480 --> 00:01:06,640 this talk back in April of 26 00:01:06,640 --> 00:01:10,560 2023 um a user misconfigured a gcp 27 00:01:10,560 --> 00:01:13,240 project to publicly expose a number of 28 00:01:13,240 --> 00:01:16,400 Docker images in GCR our own tooling and 29 00:01:16,400 --> 00:01:19,040 observability caught it super fast we 30 00:01:19,040 --> 00:01:22,880 were able to fix it crisis averted um 31 00:01:22,880 --> 00:01:23,920 but during 32 00:01:23,920 --> 00:01:27,079 remediation we kind of walked the user 33 00:01:27,079 --> 00:01:29,400 through like show me what you did right 34 00:01:29,400 --> 00:01:32,360 and then we oh dear God that was 35 00:01:32,360 --> 00:01:34,960 ridiculously easy it's obvious why you 36 00:01:34,960 --> 00:01:38,119 got confused and it's just like this 37 00:01:38,119 --> 00:01:40,640 lurking foot gun in 38 00:01:40,640 --> 00:01:43,320 GCR um and then we were like well you 39 00:01:43,320 --> 00:01:46,040 know we're not the only P people that 40 00:01:46,040 --> 00:01:48,719 this happens to right like screwing up 41 00:01:48,719 --> 00:01:51,520 doesn't discriminate so certainly 42 00:01:51,520 --> 00:01:54,399 there's tens of thousands of projects 43 00:01:54,399 --> 00:01:56,520 this misconfiguration has to be sitting 44 00:01:56,520 --> 00:02:00,079 out in on a ton of projects right could 45 00:02:00,079 --> 00:02:02,960 we find them if we did find them what 46 00:02:02,960 --> 00:02:06,840 would the images be um looking at the 47 00:02:06,840 --> 00:02:08,440 images would they be particularly 48 00:02:08,440 --> 00:02:10,080 interesting would they be particularly 49 00:02:10,080 --> 00:02:14,319 juicy um and you also have to consider 50 00:02:14,319 --> 00:02:17,680 that the images found through this 51 00:02:17,680 --> 00:02:19,959 mechanism the users thought they would 52 00:02:19,959 --> 00:02:22,840 be private so you're kind of like paing 53 00:02:22,840 --> 00:02:25,239 through someone's sock drawer right this 54 00:02:25,239 --> 00:02:27,319 isn't the images they built for public 55 00:02:27,319 --> 00:02:29,080 consumption this is the images they 56 00:02:29,080 --> 00:02:30,879 built for their own internal 57 00:02:30,879 --> 00:02:33,200 workloads um so when we talk about 58 00:02:33,200 --> 00:02:35,080 observations and best 59 00:02:35,080 --> 00:02:38,360 practices what we're talking about is 60 00:02:38,360 --> 00:02:41,360 patterns that we caught in the wild that 61 00:02:41,360 --> 00:02:43,720 happened with enough frequency that they 62 00:02:43,720 --> 00:02:46,319 could become a bullet point right we saw 63 00:02:46,319 --> 00:02:48,800 this so often that I can just say this 64 00:02:48,800 --> 00:02:51,319 is a habit a surprising number of people 65 00:02:51,319 --> 00:02:55,238 have right you might be doing it 66 00:02:57,000 --> 00:02:59,959 too so yeah my name is Ian Dylan 67 00:02:59,959 --> 00:03:02,599 security engineer at the New York Times 68 00:03:02,599 --> 00:03:04,879 if for some godforsaken reason you want 69 00:03:04,879 --> 00:03:06,799 to find me on the internet I'm on 70 00:03:06,799 --> 00:03:09,920 Twitter and Blu sky at amen breakpoint I 71 00:03:09,920 --> 00:03:13,280 don't post you can't DM on Blue Sky so 72 00:03:13,280 --> 00:03:17,159 you know it's just a profile that's 73 00:03:17,840 --> 00:03:20,440 empty here's the rough plan for the 74 00:03:20,440 --> 00:03:22,120 presentation it's basically in three 75 00:03:22,120 --> 00:03:24,280 parts the first part we're going to talk 76 00:03:24,280 --> 00:03:27,760 about Google container registry like why 77 00:03:27,760 --> 00:03:31,599 are we talking about gcp and not ECR or 78 00:03:31,599 --> 00:03:33,879 whatever the hell AER has right we're 79 00:03:33,879 --> 00:03:36,040 talking specifically about uh Google 80 00:03:36,040 --> 00:03:37,959 container registry we're going to talk 81 00:03:37,959 --> 00:03:40,840 about design language confusion in their 82 00:03:40,840 --> 00:03:42,680 console and then we're going to talk 83 00:03:42,680 --> 00:03:48,159 about how other gcp services use GCR in 84 00:03:48,159 --> 00:03:51,519 ways that you maybe aren't fully expect 85 00:03:51,519 --> 00:03:53,640 or fully aware when you sign up for 86 00:03:53,640 --> 00:03:55,079 these 87 00:03:55,079 --> 00:03:57,799 Services we're going to talk about gcps 88 00:03:57,799 --> 00:04:00,079 deprecation of GCR and some other recent 89 00:04:00,079 --> 00:04:02,519 changes around GCR and then we're going 90 00:04:02,519 --> 00:04:04,239 to talk about common issues we saw and 91 00:04:04,239 --> 00:04:07,799 best practices I should say very early 92 00:04:07,799 --> 00:04:12,439 may we submitted a Google vrp report on 93 00:04:12,439 --> 00:04:17,160 this so uh it was an abuse report not an 94 00:04:17,160 --> 00:04:18,759 exploit report which Google kind of 95 00:04:18,759 --> 00:04:21,160 treats a little differently um abuse 96 00:04:21,160 --> 00:04:22,960 reports go through like the trust and 97 00:04:22,960 --> 00:04:26,120 safety team and are 98 00:04:26,120 --> 00:04:29,080 treated as like lower bounties and stuff 99 00:04:29,080 --> 00:04:31,880 it's just like a whole separate category 100 00:04:31,880 --> 00:04:34,919 uh so this our report got triaged as an 101 00:04:34,919 --> 00:04:39,320 abuse report and finally got finished in 102 00:04:39,320 --> 00:04:42,840 mid July so from like early May to Mid 103 00:04:42,840 --> 00:04:46,120 July we had an open vrp Report with 104 00:04:46,120 --> 00:04:49,600 Google about GCR exposure how it's easy 105 00:04:49,600 --> 00:04:52,880 to find um there's some Recon 106 00:04:52,880 --> 00:04:55,919 methodologies that help you find them 107 00:04:55,919 --> 00:04:57,639 and some other stuff that you can get 108 00:04:57,639 --> 00:05:00,280 around um quotas and stuff like that so 109 00:05:00,280 --> 00:05:04,120 this could be like the leaks exist and 110 00:05:04,120 --> 00:05:06,680 hunting them can be weaponized due to 111 00:05:06,680 --> 00:05:09,320 the way GCR is configured and the way uh 112 00:05:09,320 --> 00:05:11,199 GCR 113 00:05:11,199 --> 00:05:14,680 works so the best way to kind of explain 114 00:05:14,680 --> 00:05:17,039 how the misconfiguration works is we're 115 00:05:17,039 --> 00:05:19,800 going to make a new gcp project for our 116 00:05:19,800 --> 00:05:23,160 new company that we're all in uh because 117 00:05:23,160 --> 00:05:24,919 when it goes wrong I want us all to feel 118 00:05:24,919 --> 00:05:28,479 it um and my mom gave me 20 bucks in VC 119 00:05:28,479 --> 00:05:31,240 money 120 00:05:31,240 --> 00:05:33,240 so when you make a new gcp project 121 00:05:33,240 --> 00:05:35,440 there's two user supplied pieces there's 122 00:05:35,440 --> 00:05:37,600 the project name which can be anything 123 00:05:37,600 --> 00:05:39,479 you want it's a display name 124 00:05:39,479 --> 00:05:42,240 right the it doesn't have to be globally 125 00:05:42,240 --> 00:05:46,000 unique gcp project IDs however do need 126 00:05:46,000 --> 00:05:48,759 to be globally unique they also have to 127 00:05:48,759 --> 00:05:52,240 be DNS safe which means a toz 0 through 128 00:05:52,240 --> 00:05:54,160 9 and a 129 00:05:54,160 --> 00:05:57,720 hyphen when you start this give me a new 130 00:05:57,720 --> 00:05:59,560 project console you get like horse 131 00:05:59,560 --> 00:06:02,720 battery staple 1 2 3 4 5 right we're not 132 00:06:02,720 --> 00:06:05,600 going to do that cuz I don't like the 133 00:06:05,600 --> 00:06:07,840 Aesthetics of a bunch of numbers I'll 134 00:06:07,840 --> 00:06:11,000 forget them I don't know what entropy is 135 00:06:11,000 --> 00:06:15,319 right so we are waleco doio welcome to 136 00:06:15,319 --> 00:06:20,080 the company we've got a week's worth of 137 00:06:20,440 --> 00:06:22,440 Runway well actually we're on the free 138 00:06:22,440 --> 00:06:26,479 tier so we got 3 months or where am I um 139 00:06:26,479 --> 00:06:29,120 so the first thing you do is you go to 140 00:06:29,120 --> 00:06:32,000 the enable apis you type in Docker this 141 00:06:32,000 --> 00:06:35,160 is the first result the second result is 142 00:06:35,160 --> 00:06:36,880 Google artifact registry the thing that 143 00:06:36,880 --> 00:06:40,080 is replacing Google container 144 00:06:40,080 --> 00:06:45,080 registry what's missing from this screen 145 00:06:45,080 --> 00:06:47,000 is that after you enable 146 00:06:47,000 --> 00:06:50,880 it you get told it's deprecated so GCR 147 00:06:50,880 --> 00:06:55,000 is deprecated as of May 148 00:06:55,000 --> 00:06:58,360 20124 deprecated and we'll get to what 149 00:06:58,360 --> 00:07:00,840 deprecation means for 150 00:07:00,840 --> 00:07:03,479 GCR so we've got an empty 151 00:07:03,479 --> 00:07:05,360 registry the first thing we're going to 152 00:07:05,360 --> 00:07:07,440 do is make the community edition of our 153 00:07:07,440 --> 00:07:11,000 Flagship product whale say the C is for 154 00:07:11,000 --> 00:07:12,039 Community 155 00:07:12,039 --> 00:07:16,080 Edition it runs you can push it line 14 156 00:07:16,080 --> 00:07:18,240 we're pushing up to our repository or 157 00:07:18,240 --> 00:07:19,680 our 158 00:07:19,680 --> 00:07:23,879 registry uh kind of pay attention to 159 00:07:23,879 --> 00:07:27,160 what the registry URL is right it's the 160 00:07:27,160 --> 00:07:30,680 region slash your project 161 00:07:30,680 --> 00:07:32,599 id/ your 162 00:07:32,599 --> 00:07:35,520 image this company needs money though so 163 00:07:35,520 --> 00:07:36,639 we're going to make an Enterprise 164 00:07:36,639 --> 00:07:39,400 Edition and our Enterprise Edition 165 00:07:39,400 --> 00:07:41,039 charges for 166 00:07:41,039 --> 00:07:45,080 SSO so that's- ENT for Enterprise same 167 00:07:45,080 --> 00:07:48,199 thing it runs you can push it we're 168 00:07:48,199 --> 00:07:50,240 pushing it to the same registry well 169 00:07:50,240 --> 00:07:55,159 cod. on the US GCR registry 170 00:07:55,159 --> 00:07:58,360 host and if we go look at the console 171 00:07:58,360 --> 00:08:01,560 you get kind of what a is expected right 172 00:08:01,560 --> 00:08:03,120 two private 173 00:08:03,120 --> 00:08:05,680 images what good is a community addition 174 00:08:05,680 --> 00:08:07,360 that's private though 175 00:08:07,360 --> 00:08:12,639 right so but before we do that GCR is a 176 00:08:12,639 --> 00:08:16,120 Docker compliant registry API it has to 177 00:08:16,120 --> 00:08:17,520 be right because you can dock or push 178 00:08:17,520 --> 00:08:19,520 you can Docker pull which means you can 179 00:08:19,520 --> 00:08:20,759 just curl it you can make 180 00:08:20,759 --> 00:08:24,960 unauthenticated request to GCR if you do 181 00:08:24,960 --> 00:08:27,280 that here's what you get for whale Co 182 00:08:27,280 --> 00:08:30,360 right now denied everything's priv 183 00:08:30,360 --> 00:08:32,958 working as expected but we need to make 184 00:08:32,958 --> 00:08:35,719 whal 185 00:08:35,719 --> 00:08:39,080 public so we go back to the console we 186 00:08:39,080 --> 00:08:41,719 do everything in the console by the way 187 00:08:41,719 --> 00:08:44,880 right we're ciser for 188 00:08:44,880 --> 00:08:49,399 nerds so we click whale Sayce so far so 189 00:08:49,399 --> 00:08:52,480 good there's the image we pushed then we 190 00:08:52,480 --> 00:08:53,800 click 191 00:08:53,800 --> 00:08:55,760 settings and you can see way down here 192 00:08:55,760 --> 00:08:58,200 there's this public access and it says 193 00:08:58,200 --> 00:09:00,320 private we click 194 00:09:00,320 --> 00:09:05,120 it we get a little list pop up we click 195 00:09:05,120 --> 00:09:06,839 public 196 00:09:06,839 --> 00:09:09,040 bam it's 197 00:09:09,040 --> 00:09:13,599 public what was missing in that user 198 00:09:13,640 --> 00:09:16,720 flow consequen no the consequences are 199 00:09:16,720 --> 00:09:19,160 coming what was missing was the 200 00:09:19,160 --> 00:09:22,399 confirmation yeah there was no informed 201 00:09:22,399 --> 00:09:26,160 confirmation about what exactly a do you 202 00:09:26,160 --> 00:09:29,680 want to do this and B is this what you 203 00:09:29,680 --> 00:09:32,240 want to do right you should be able to 204 00:09:32,240 --> 00:09:35,040 tell the user what's going on there so 205 00:09:35,040 --> 00:09:36,920 let's go back to our curl statement our 206 00:09:36,920 --> 00:09:40,880 external exterior actor does curl again 207 00:09:40,880 --> 00:09:44,200 oh no our Flagship Enterprise project is 208 00:09:44,200 --> 00:09:46,480 now 209 00:09:46,480 --> 00:09:49,839 public so the gotcha this is the whole 210 00:09:49,839 --> 00:09:51,320 UI confusion in 211 00:09:51,320 --> 00:09:54,040 GCR anytime no matter how far you've 212 00:09:54,040 --> 00:09:56,440 drilled down in your image tree or 213 00:09:56,440 --> 00:09:59,320 whatever if you click settings you're 214 00:09:59,320 --> 00:10:02,279 changing the visibility for the entire 215 00:10:02,279 --> 00:10:05,320 registry not just that one image and the 216 00:10:05,320 --> 00:10:08,720 thing is if you go and read the docs it 217 00:10:08,720 --> 00:10:12,040 tells you this no one reads no one reads 218 00:10:12,040 --> 00:10:13,880 the docks right it's the last thing 219 00:10:13,880 --> 00:10:18,160 anyone's going to do um so this is the 220 00:10:18,160 --> 00:10:21,959 root of all these GCR leaks the other 221 00:10:21,959 --> 00:10:25,000 problem with this is it can happen at 222 00:10:25,000 --> 00:10:27,880 any point in time if some point in the 223 00:10:27,880 --> 00:10:29,480 past you made the registry public 224 00:10:29,480 --> 00:10:32,320 because you wanted to make it public but 225 00:10:32,320 --> 00:10:33,640 then another team starts using your 226 00:10:33,640 --> 00:10:35,560 project and starts pushing 227 00:10:35,560 --> 00:10:38,519 images those images are public as well 228 00:10:38,519 --> 00:10:40,399 they might not realize it right there's 229 00:10:40,399 --> 00:10:42,920 nothing in Docker push that tells you 230 00:10:42,920 --> 00:10:45,480 that you're pushing to a public 231 00:10:45,480 --> 00:10:48,200 registry now if you go and look at GCR 232 00:10:48,200 --> 00:10:50,399 it doesn't lie to you right it tells you 233 00:10:50,399 --> 00:10:51,160 it's 234 00:10:51,160 --> 00:10:54,000 public no big surprise there but you 235 00:10:54,000 --> 00:10:56,079 know um in reporting this to a couple 236 00:10:56,079 --> 00:10:58,160 companies they said oh we never went and 237 00:10:58,160 --> 00:10:59,839 looked at the console like why the why 238 00:10:59,839 --> 00:11:02,320 would we look at the console when we 239 00:11:02,320 --> 00:11:05,720 just push and it's there right we don't 240 00:11:05,720 --> 00:11:07,000 there's nothing you need to do in the 241 00:11:07,000 --> 00:11:09,040 console to introduce a new image 242 00:11:09,040 --> 00:11:11,120 repository in your registry so they 243 00:11:11,120 --> 00:11:14,440 don't they just don't realize 244 00:11:14,560 --> 00:11:16,800 it so we've gotten a lot of feedback 245 00:11:16,800 --> 00:11:19,720 from our whs say company or customers 246 00:11:19,720 --> 00:11:21,760 and it turns out that they don't like 247 00:11:21,760 --> 00:11:24,880 running 64 gigs of RAM machines for 248 00:11:24,880 --> 00:11:27,639 whale say so we're going to Pivot and 249 00:11:27,639 --> 00:11:29,519 we're going to become a SAS company now 250 00:11:29,519 --> 00:11:32,240 we're going to host whale safer 251 00:11:32,240 --> 00:11:35,360 people so we need to adopt some gcp 252 00:11:35,360 --> 00:11:38,839 services to host it for us 253 00:11:39,639 --> 00:11:42,480 right first thing we're going to adopt 254 00:11:42,480 --> 00:11:44,680 is Google app engine does every anyone 255 00:11:44,680 --> 00:11:46,399 use Google app 256 00:11:46,399 --> 00:11:49,120 engine it's actually got a ton of users 257 00:11:49,120 --> 00:11:50,480 it's been around for like 15 years at 258 00:11:50,480 --> 00:11:52,360 this point still under active 259 00:11:52,360 --> 00:11:54,000 development they're still releasing 260 00:11:54,000 --> 00:11:54,959 updated 261 00:11:54,959 --> 00:11:58,480 runtimes um so we got whala GAE line one 262 00:11:58,480 --> 00:12:01,800 we're just typing gcloud app deploy 263 00:12:01,800 --> 00:12:03,399 these are all 264 00:12:03,399 --> 00:12:05,360 defaults right this is just the default 265 00:12:05,360 --> 00:12:07,399 configuration for the default service in 266 00:12:07,399 --> 00:12:10,639 whco iio it spins for a while it does 267 00:12:10,639 --> 00:12:13,480 some crap line 25 I can curl my new 268 00:12:13,480 --> 00:12:17,519 service it works all good the one thing 269 00:12:17,519 --> 00:12:20,920 to really recognize or realize in this 270 00:12:20,920 --> 00:12:24,480 directory wh say G AE there is no Docker 271 00:12:24,480 --> 00:12:28,079 file right this is just a bunch of node 272 00:12:28,079 --> 00:12:30,880 no Docker files 273 00:12:31,720 --> 00:12:34,880 however it turns out that Google app 274 00:12:34,880 --> 00:12:37,279 engine isn't sexy doesn't look good on 275 00:12:37,279 --> 00:12:40,199 LinkedIn and if I need a job once whals 276 00:12:40,199 --> 00:12:41,720 say crashes and burns I got to pick 277 00:12:41,720 --> 00:12:44,440 something else so we're going to go to 278 00:12:44,440 --> 00:12:46,880 Google Cloud functions same story all 279 00:12:46,880 --> 00:12:50,199 defaults this is Google Cloud functions 280 00:12:50,199 --> 00:12:52,920 first gen there's a second gen that 281 00:12:52,920 --> 00:12:54,120 behaves a little different but second 282 00:12:54,120 --> 00:12:56,880 gen still not the 283 00:12:57,279 --> 00:13:01,320 default hit all the defaults deploy it 284 00:13:01,320 --> 00:13:03,480 twiddle your thumbs it works you can 285 00:13:03,480 --> 00:13:04,480 curl 286 00:13:04,480 --> 00:13:07,639 it so what do you think it's actually 287 00:13:07,639 --> 00:13:10,160 happening in the background of these 288 00:13:10,160 --> 00:13:13,800 default deployments for app engine and 289 00:13:13,800 --> 00:13:16,959 GCF they both depend on 290 00:13:16,959 --> 00:13:20,839 GCR and they both build Docker 291 00:13:20,839 --> 00:13:24,279 images and they both happily push to 292 00:13:24,279 --> 00:13:27,639 public GCR Registries so it means those 293 00:13:27,639 --> 00:13:29,279 two deployments I made 294 00:13:29,279 --> 00:13:31,760 are immediately leaking through my 295 00:13:31,760 --> 00:13:34,600 public GCR 296 00:13:34,800 --> 00:13:37,160 registry I look at the app engine 297 00:13:37,160 --> 00:13:39,079 console doesn't say anything I look at 298 00:13:39,079 --> 00:13:42,560 the GCR GCF console doesn't say anything 299 00:13:42,560 --> 00:13:44,079 the other cool part about app engine and 300 00:13:44,079 --> 00:13:46,639 GCF images you get a new one for every 301 00:13:46,639 --> 00:13:50,040 deployment so your leak includes the 302 00:13:50,040 --> 00:13:53,720 entire change history of your app engine 303 00:13:53,720 --> 00:13:55,720 deployments like you can find app engine 304 00:13:55,720 --> 00:13:57,759 deployments going back to like 2019 305 00:13:57,759 --> 00:14:00,759 right 306 00:14:00,839 --> 00:14:04,480 so that's like the GCR story super easy 307 00:14:04,480 --> 00:14:06,320 to blow your own foot off because the UI 308 00:14:06,320 --> 00:14:09,120 doesn't really explain what's happening 309 00:14:09,120 --> 00:14:12,160 and then compounded I guess you blow 310 00:14:12,160 --> 00:14:14,519 your other foot off when you choose GAE 311 00:14:14,519 --> 00:14:18,120 or GCF and you inadvertently link leak 312 00:14:18,120 --> 00:14:20,680 images that you had every pretty good 313 00:14:20,680 --> 00:14:23,479 reason to think was 314 00:14:25,560 --> 00:14:28,079 private so here's an interesting thing 315 00:14:28,079 --> 00:14:32,360 about the Rel ship between GCR and GCS 316 00:14:32,360 --> 00:14:36,040 Google can Google Cloud Storage they're 317 00:14:36,040 --> 00:14:37,279 buckets 318 00:14:37,279 --> 00:14:42,839 right GCR in actuality is a 319 00:14:43,560 --> 00:14:47,560 bucket my registry is us. artifacts. 320 00:14:47,560 --> 00:14:51,120 whale cod. appspot.com that got made 321 00:14:51,120 --> 00:14:54,959 automatically for me when I enabled GCR 322 00:14:54,959 --> 00:14:57,040 and pushed to us. 323 00:14:57,040 --> 00:15:01,440 gc. it tells me it's public but as a 324 00:15:01,440 --> 00:15:04,839 user what the hell is this bucket like 325 00:15:04,839 --> 00:15:06,399 if you go to stack Overflow and search 326 00:15:06,399 --> 00:15:07,839 for these kind of bucket names you find 327 00:15:07,839 --> 00:15:10,800 all these questions about like why is 328 00:15:10,800 --> 00:15:13,600 this bucket 50 gig what am I what is 329 00:15:13,600 --> 00:15:15,360 this why am I paying for it can I delete 330 00:15:15,360 --> 00:15:18,959 it there's no clear indication that this 331 00:15:18,959 --> 00:15:22,320 bucket is associated with GCR right I 332 00:15:22,320 --> 00:15:24,839 didn't make it maybe it's supposed to be 333 00:15:24,839 --> 00:15:27,040 public I don't 334 00:15:27,040 --> 00:15:29,240 know here's the other interesting thing 335 00:15:29,240 --> 00:15:31,480 about 336 00:15:31,480 --> 00:15:35,839 GCS say you are an awkward looking guy 337 00:15:35,839 --> 00:15:37,920 who is trying to find a bunch of open 338 00:15:37,920 --> 00:15:40,079 GCR Registries 339 00:15:40,079 --> 00:15:43,639 right GCR has request quotas you can 340 00:15:43,639 --> 00:15:45,759 make like 50,000 requests every 10 341 00:15:45,759 --> 00:15:49,120 minutes or a million total requests a 342 00:15:49,120 --> 00:15:52,440 day it's hard to do Mass scans under 343 00:15:52,440 --> 00:15:53,720 that limit 344 00:15:53,720 --> 00:15:58,079 right GCS however has no such quota you 345 00:15:58,079 --> 00:15:59,959 can beat the crap out of GCS it's 346 00:15:59,959 --> 00:16:01,480 designed that 347 00:16:01,480 --> 00:16:05,079 way the buckets that back GCR Registries 348 00:16:05,079 --> 00:16:07,399 are deterministically 349 00:16:07,399 --> 00:16:11,000 named so when you need to find an open 350 00:16:11,000 --> 00:16:14,319 GCR registry what you can actually find 351 00:16:14,319 --> 00:16:16,759 is the public bucket that backs it and 352 00:16:16,759 --> 00:16:18,800 then you know that the GCR registry is 353 00:16:18,800 --> 00:16:22,560 public so those GCR abuse quotas don't 354 00:16:22,560 --> 00:16:26,680 come into play you just get to abuse 355 00:16:27,519 --> 00:16:32,759 GCS so that's the um abuse mitigation 356 00:16:32,759 --> 00:16:35,279 side step just go just go abuse GCS 357 00:16:35,279 --> 00:16:38,040 you're supposed to 358 00:16:38,959 --> 00:16:41,560 right so let's talk about container 359 00:16:41,560 --> 00:16:44,000 registry 360 00:16:44,000 --> 00:16:48,120 deprecation in May 2023 the banner and 361 00:16:48,120 --> 00:16:51,680 GCR changed from please migrate to 362 00:16:51,680 --> 00:16:55,839 artifact registry to GCR is deprecated 363 00:16:55,839 --> 00:17:00,880 you need to migrate because in May 2024 364 00:17:00,880 --> 00:17:02,480 GCR is 365 00:17:02,480 --> 00:17:04,000 deprecated 366 00:17:04,000 --> 00:17:07,599 but if you read closely it says 367 00:17:07,599 --> 00:17:10,039 container registry will remain available 368 00:17:10,039 --> 00:17:12,199 in projects where either of the 369 00:17:12,199 --> 00:17:15,280 following actions occurred before May 15 370 00:17:15,280 --> 00:17:17,839 2024 you've enabled it and you've pushed 371 00:17:17,839 --> 00:17:20,559 an image so what deprecation actually 372 00:17:20,559 --> 00:17:24,679 means is in May 2024 you may not start 373 00:17:24,679 --> 00:17:28,079 using GCR if you have been using GCR you 374 00:17:28,079 --> 00:17:31,120 make continue to do so so this drop dead 375 00:17:31,120 --> 00:17:34,720 date is when you there are no new GCR 376 00:17:34,720 --> 00:17:37,600 users after May 377 00:17:40,160 --> 00:17:43,120 2024 so another interesting thing is 378 00:17:43,120 --> 00:17:45,640 since our vrp report there's been a few 379 00:17:45,640 --> 00:17:48,960 changes to GCR 380 00:17:52,000 --> 00:17:54,400 right 381 00:17:54,400 --> 00:17:57,440 first the GCR console now looks like 382 00:17:57,440 --> 00:18:00,120 this for public images you get the nice 383 00:18:00,120 --> 00:18:01,679 warning triangle the same thing you do 384 00:18:01,679 --> 00:18:03,000 in your 385 00:18:03,000 --> 00:18:06,159 buckets this change was made within the 386 00:18:06,159 --> 00:18:09,240 last two weeks those slides that you saw 387 00:18:09,240 --> 00:18:11,720 from the console those are from July 388 00:18:11,720 --> 00:18:17,960 17th so I took this screenshot on Friday 389 00:18:17,960 --> 00:18:21,159 so this change happened since July 17th 390 00:18:21,159 --> 00:18:22,840 they also did a container registry 391 00:18:22,840 --> 00:18:24,960 change back in June there used to be an 392 00:18:24,960 --> 00:18:28,760 endpoint in GCR that tipped whether not 393 00:18:28,760 --> 00:18:31,840 a project existed given just the project 394 00:18:31,840 --> 00:18:34,440 ID which is pretty useful Recon 395 00:18:34,440 --> 00:18:36,080 information if you're trying to save 396 00:18:36,080 --> 00:18:40,120 yourself a bunch of spam HTTP requests 397 00:18:40,120 --> 00:18:41,640 and it would tell you if a project ID 398 00:18:41,640 --> 00:18:44,440 existed whether or not it was using GCR 399 00:18:44,440 --> 00:18:46,080 so you could use it for a whole bunch of 400 00:18:46,080 --> 00:18:48,440 different Recons so they changed that 401 00:18:48,440 --> 00:18:51,360 that was uh June 402 00:18:51,360 --> 00:18:55,159 29th there was one big change however 403 00:18:55,159 --> 00:18:57,240 remember where I was like I go here I 404 00:18:57,240 --> 00:18:59,280 click here I click this it says public I 405 00:18:59,280 --> 00:19:00,799 click it blah blah blah blah blah all 406 00:19:00,799 --> 00:19:03,320 that's a lie now because this 407 00:19:03,320 --> 00:19:05,400 Friday August 408 00:19:05,400 --> 00:19:08,840 11th you may no longer change a registry 409 00:19:08,840 --> 00:19:11,440 to public from the console you have to 410 00:19:11,440 --> 00:19:15,280 do it from the CLI which is amazing news 411 00:19:15,280 --> 00:19:17,360 like that's all I really you know that's 412 00:19:17,360 --> 00:19:20,760 all I wanted um what's kind of funny 413 00:19:20,760 --> 00:19:22,880 about this is 414 00:19:22,880 --> 00:19:26,799 um if you do want to make a registry 415 00:19:26,799 --> 00:19:29,480 public you have to do it by the CLI 416 00:19:29,480 --> 00:19:32,200 uh the command to do it is to change the 417 00:19:32,200 --> 00:19:34,960 access control on the bucket so then it 418 00:19:34,960 --> 00:19:37,799 becomes very clear that GCR is in fact 419 00:19:37,799 --> 00:19:40,559 just a bucket right so this was a great 420 00:19:40,559 --> 00:19:44,799 change but I I'm glad I looked like I I 421 00:19:44,799 --> 00:19:46,320 was looking at I went to go look at the 422 00:19:46,320 --> 00:19:47,960 chains log to make sure my slides were 423 00:19:47,960 --> 00:19:49,919 still correct and they did this on 424 00:19:49,919 --> 00:19:51,679 Friday 425 00:19:51,679 --> 00:19:56,320 so thank you gcp listening yeah I'm glad 426 00:19:56,320 --> 00:19:58,080 like the report spurned some action I 427 00:19:58,080 --> 00:20:01,919 made a change in the world um so that's 428 00:20:01,919 --> 00:20:05,520 kind of it for the gcp side so for the 429 00:20:05,520 --> 00:20:08,760 images we found in the wild we found 430 00:20:08,760 --> 00:20:12,159 images across huge swaps of Industries 431 00:20:12,159 --> 00:20:16,520 right crypto exchanges um logistics 432 00:20:16,520 --> 00:20:19,559 companies that handle buttloads of money 433 00:20:19,559 --> 00:20:21,320 for their customers they're not Banks 434 00:20:21,320 --> 00:20:24,520 but they do International transfers um 435 00:20:24,520 --> 00:20:27,240 tons of little app startups healthc care 436 00:20:27,240 --> 00:20:29,360 information like 437 00:20:29,360 --> 00:20:32,159 again messing up doesn't discriminate 438 00:20:32,159 --> 00:20:34,320 right all these companies made this 439 00:20:34,320 --> 00:20:38,640 really simple mistake and it hurt right 440 00:20:38,640 --> 00:20:42,039 so what are kind of like the 441 00:20:42,039 --> 00:20:43,799 observations and patterns we saw about 442 00:20:43,799 --> 00:20:47,480 bad behaviors and then best practices 443 00:20:47,480 --> 00:20:50,640 you can adopt to mitigate this 444 00:20:50,640 --> 00:20:54,400 stuff the worst thing we immediately oh 445 00:20:54,400 --> 00:20:56,320 well besides the information disclosure 446 00:20:56,320 --> 00:20:59,720 of I got your source code right I stole 447 00:20:59,720 --> 00:21:01,840 a runtime artifact that depending upon 448 00:21:01,840 --> 00:21:03,919 the language might be compiled might be 449 00:21:03,919 --> 00:21:05,840 stripped or might just be a bunch of 450 00:21:05,840 --> 00:21:08,000 python right who knows I can but I can 451 00:21:08,000 --> 00:21:11,559 read it um so the first you know bad 452 00:21:11,559 --> 00:21:14,159 behavior is obviously static Secrets 453 00:21:14,159 --> 00:21:17,120 these tended to be uh API keys for 454 00:21:17,120 --> 00:21:20,960 external SAS Benders think srid twilio 455 00:21:20,960 --> 00:21:24,400 slack you know service tokens for other 456 00:21:24,400 --> 00:21:27,799 company apis we also saw a lot of Stripe 457 00:21:27,799 --> 00:21:30,039 Right if a company handled money and 458 00:21:30,039 --> 00:21:31,400 they weren't doing their own internal 459 00:21:31,400 --> 00:21:33,200 kind of banking stuff we saw strip Keys 460 00:21:33,200 --> 00:21:34,600 lots of 461 00:21:34,600 --> 00:21:37,760 them the other thing we saw and I'm kind 462 00:21:37,760 --> 00:21:39,240 of considering separately is static 463 00:21:39,240 --> 00:21:42,120 secrets with no environment segmentation 464 00:21:42,120 --> 00:21:45,640 meaning um I got an image from my 465 00:21:45,640 --> 00:21:49,080 company ddev right but inside of that 466 00:21:49,080 --> 00:21:53,080 image is was secrets for Dev test prod 467 00:21:53,080 --> 00:21:55,320 so you got one image with secrets for 468 00:21:55,320 --> 00:21:58,360 every environment so I stole from a 469 00:21:58,360 --> 00:22:00,840 lower environment and with one get 470 00:22:00,840 --> 00:22:03,840 request escalated to prod 471 00:22:03,840 --> 00:22:06,640 right spring boot projects were 472 00:22:06,640 --> 00:22:10,320 notorious for this if I saw a jar file 473 00:22:10,320 --> 00:22:12,440 that I had I was like oh there's three 474 00:22:12,440 --> 00:22:14,200 property files in here and I was right 475 00:22:14,200 --> 00:22:18,000 like 80% of the time and the reason I 476 00:22:18,000 --> 00:22:20,919 think is a the framework provides that 477 00:22:20,919 --> 00:22:22,880 to you the property files across 478 00:22:22,880 --> 00:22:23,960 multiple environments it's just 479 00:22:23,960 --> 00:22:25,679 something that's kind of built in the 480 00:22:25,679 --> 00:22:27,720 other thing is the build artifact is a 481 00:22:27,720 --> 00:22:29,640 jar are and I think there's an out of 482 00:22:29,640 --> 00:22:31,880 sight out of mind kind of thing that if 483 00:22:31,880 --> 00:22:33,320 the properties files isn't just sitting 484 00:22:33,320 --> 00:22:36,440 on disc you kind of forget exists um but 485 00:22:36,440 --> 00:22:38,279 a jar file is a ZIP file right you just 486 00:22:38,279 --> 00:22:41,159 unzip it it's all in 487 00:22:41,159 --> 00:22:44,840 there the other thing we saw was a ton a 488 00:22:44,840 --> 00:22:48,799 ton of static Google service account 489 00:22:48,799 --> 00:22:52,960 Keys which gives you kind of two things 490 00:22:52,960 --> 00:22:56,960 one gcp provides runtime identity for 491 00:22:56,960 --> 00:22:59,080 just about every workload inside a gcp 492 00:22:59,080 --> 00:23:00,880 right you can just attach a service 493 00:23:00,880 --> 00:23:03,200 account to your service and it should 494 00:23:03,200 --> 00:23:04,279 just 495 00:23:04,279 --> 00:23:06,279 work but if people are putting static 496 00:23:06,279 --> 00:23:07,880 credentials in it it means they don't 497 00:23:07,880 --> 00:23:10,480 understand runtime identity like it's 498 00:23:10,480 --> 00:23:14,440 confusing or they're trying to bridge or 499 00:23:14,440 --> 00:23:16,640 normalize the software development life 500 00:23:16,640 --> 00:23:19,559 cycle and make their local runtime 501 00:23:19,559 --> 00:23:21,919 behave like their Cloud runtime and the 502 00:23:21,919 --> 00:23:24,080 simplest way to do that just static 503 00:23:24,080 --> 00:23:26,440 service account credentials 504 00:23:26,440 --> 00:23:29,080 right another really common pattern we 505 00:23:29,080 --> 00:23:32,000 saw was environment 506 00:23:32,000 --> 00:23:34,480 variables um everyone knows like the 12 507 00:23:34,480 --> 00:23:36,600 Factor app 508 00:23:36,600 --> 00:23:40,559 Manifesto It's got this advice that's 509 00:23:40,559 --> 00:23:43,640 worn pretty thin at this point where you 510 00:23:43,640 --> 00:23:46,120 inject secrets into the runtime inside 511 00:23:46,120 --> 00:23:49,960 of process or process environment 512 00:23:49,960 --> 00:23:53,440 variables maybe not great advice anymore 513 00:23:53,440 --> 00:23:56,840 but what's left unsaid or unexplained in 514 00:23:56,840 --> 00:23:59,960 the 12 Factor app Manifesto is the point 515 00:23:59,960 --> 00:24:02,039 in time that you put those secrets in 516 00:24:02,039 --> 00:24:05,480 your environment is as late as possible 517 00:24:05,480 --> 00:24:07,440 your orchestration should do it the 518 00:24:07,440 --> 00:24:09,799 thing that is launching your application 519 00:24:09,799 --> 00:24:11,440 should be managing those process 520 00:24:11,440 --> 00:24:14,840 environments we saw a ton of node apps 521 00:24:14,840 --> 00:24:18,200 with some variation of this 522 00:24:18,200 --> 00:24:21,919 code and if you just Google n multiple 523 00:24:21,919 --> 00:24:24,240 environments you'll see a ton of medium 524 00:24:24,240 --> 00:24:27,919 articles where good advice goes to die 525 00:24:27,919 --> 00:24:31,520 kind of stuff saying this do this right 526 00:24:31,520 --> 00:24:33,000 and so you'd crack an image open there 527 00:24:33,000 --> 00:24:34,679 would be 528 00:24:34,679 --> 00:24:40,840 env. test. env. prod. EnV 529 00:24:40,840 --> 00:24:44,559 dodev but the node code would be saying 530 00:24:44,559 --> 00:24:48,679 process. m.y secret so they are doing 531 00:24:48,679 --> 00:24:50,679 this weird cargo culting thing of I'm 532 00:24:50,679 --> 00:24:51,799 reading a secret out of the 533 00:24:51,799 --> 00:24:53,320 environmental 534 00:24:53,320 --> 00:24:55,480 variable but the environmental variable 535 00:24:55,480 --> 00:24:57,960 got shimmed by reading a static Secret 536 00:24:57,960 --> 00:25:01,600 off dis so it's like doing the thing but 537 00:25:01,600 --> 00:25:06,439 missing the point we saw this a 538 00:25:06,480 --> 00:25:09,039 lot and just talking about environmental 539 00:25:09,039 --> 00:25:12,480 variables right in Google app engine 540 00:25:12,480 --> 00:25:15,679 you're manifest down here on line 13 541 00:25:15,679 --> 00:25:17,080 your manifest can include an 542 00:25:17,080 --> 00:25:19,080 environmental variable 543 00:25:19,080 --> 00:25:21,640 right uh for a long time in GAE this was 544 00:25:21,640 --> 00:25:22,880 the only way to do 545 00:25:22,880 --> 00:25:26,120 it was before Google secret 546 00:25:26,120 --> 00:25:28,360 manager you'll find the a lot of 547 00:25:28,360 --> 00:25:30,320 conversations where people are like I 548 00:25:30,320 --> 00:25:32,600 can't put this crap into get right you 549 00:25:32,600 --> 00:25:35,240 don't commit secrets and so they had 550 00:25:35,240 --> 00:25:36,600 this all this weird like string 551 00:25:36,600 --> 00:25:40,080 substitution patterns during CI to fix 552 00:25:40,080 --> 00:25:41,640 this file 553 00:25:41,640 --> 00:25:44,480 right so we've got a secret called my 554 00:25:44,480 --> 00:25:48,320 secret we type G deploy it grinds it 555 00:25:48,320 --> 00:25:50,840 deploys now remember our registry is 556 00:25:50,840 --> 00:25:54,360 still leaking right so um a 557 00:25:54,360 --> 00:25:56,840 well-intentioned security researcher 558 00:25:56,840 --> 00:25:59,520 grabs your image 559 00:25:59,520 --> 00:26:02,840 cracks it open and there's your app. 560 00:26:02,840 --> 00:26:06,919 yaml with your secret no access to the 561 00:26:06,919 --> 00:26:09,320 runtime the file got written into the 562 00:26:09,320 --> 00:26:12,320 image it got baked 563 00:26:12,320 --> 00:26:15,120 right by default by app 564 00:26:15,120 --> 00:26:19,640 engine um which leads to the absolute 565 00:26:19,640 --> 00:26:25,080 killer thing we saw and we saw it a 566 00:26:25,159 --> 00:26:28,480 lot that is build context 567 00:26:28,480 --> 00:26:32,399 leaks so this Doc is from June of this 568 00:26:32,399 --> 00:26:35,760 year it's from the fine folks at cisa 569 00:26:35,760 --> 00:26:37,120 and our mandatory friends at the 570 00:26:37,120 --> 00:26:38,320 National Security 571 00:26:38,320 --> 00:26:44,159 Agency and it's defending cidc cicd 572 00:26:44,159 --> 00:26:46,480 environments what there was like four 573 00:26:46,480 --> 00:26:48,679 different at least four different talks 574 00:26:48,679 --> 00:26:52,039 at this Defcon talking about cicd right 575 00:26:52,039 --> 00:26:54,559 it's obviously super sensitive it's a 576 00:26:54,559 --> 00:26:56,360 very dangerous point at the software 577 00:26:56,360 --> 00:26:57,880 development life cycle and Dey 578 00:26:57,880 --> 00:27:00,640 employment um all the context in there 579 00:27:00,640 --> 00:27:03,320 is very sensitive any credentials in 580 00:27:03,320 --> 00:27:06,799 play are probably very privileged right 581 00:27:06,799 --> 00:27:09,000 so they call it out they say insure 582 00:27:09,000 --> 00:27:11,559 secrets are never left embedded in 583 00:27:11,559 --> 00:27:12,960 software where they can be reverse 584 00:27:12,960 --> 00:27:15,480 engineered 585 00:27:15,880 --> 00:27:21,640 out it is so so easy to do this and to 586 00:27:21,640 --> 00:27:23,919 demonstrate we're going to take the 587 00:27:23,919 --> 00:27:27,000 naive let's Google our problem way 588 00:27:27,000 --> 00:27:28,559 approach right so we're going to make a 589 00:27:28,559 --> 00:27:30,679 whal say 590 00:27:30,679 --> 00:27:34,720 service this is our Docker file okay 591 00:27:34,720 --> 00:27:36,960 pretty Bas in fact this Docker file 592 00:27:36,960 --> 00:27:40,399 comes from npmjs.com 593 00:27:58,440 --> 00:28:00,279 this is kind of like an amalgamation of 594 00:28:00,279 --> 00:28:03,159 the first page of results again from all 595 00:28:03,159 --> 00:28:05,679 the worst advice on medium that Google 596 00:28:05,679 --> 00:28:07,679 bubbled to the 597 00:28:07,679 --> 00:28:10,840 top but this is kind of like a pretty 598 00:28:10,840 --> 00:28:13,600 standard build flow for a Docker image 599 00:28:13,600 --> 00:28:18,080 right line 10 check it out line 11 600 00:28:18,080 --> 00:28:20,679 authenticate to Google using our static 601 00:28:20,679 --> 00:28:23,640 credentials that I have in a 602 00:28:23,640 --> 00:28:25,600 secret set up 603 00:28:25,600 --> 00:28:28,960 gcloud set up Docker off build it push 604 00:28:28,960 --> 00:28:32,360 it pretty standard stuff right every if 605 00:28:32,360 --> 00:28:34,640 you build containers your pipelines look 606 00:28:34,640 --> 00:28:36,320 pretty much like 607 00:28:36,320 --> 00:28:39,679 this so we run this I push to GitHub 608 00:28:39,679 --> 00:28:43,360 GitHub actions runs it pushes 609 00:28:43,360 --> 00:28:45,720 okay if our well-meaning security 610 00:28:45,720 --> 00:28:49,640 researcher curls the tags for that image 611 00:28:49,640 --> 00:28:51,480 we can see that it got 612 00:28:51,480 --> 00:28:54,120 pushed so let's pull it down and crack 613 00:28:54,120 --> 00:28:55,799 it 614 00:28:55,799 --> 00:28:58,960 open Line 13 615 00:28:58,960 --> 00:29:01,720 those are our GitHub 616 00:29:02,120 --> 00:29:05,360 credentials no matter how good the 617 00:29:05,360 --> 00:29:07,880 hygiene was for that application no 618 00:29:07,880 --> 00:29:10,039 matter how right sized that service 619 00:29:10,039 --> 00:29:12,559 account was what you just baked in was 620 00:29:12,559 --> 00:29:15,720 your cicd credentials your static cicd 621 00:29:15,720 --> 00:29:17,320 credentials 622 00:29:17,320 --> 00:29:19,360 right look at all the other crap that 623 00:29:19,360 --> 00:29:21,960 got baked in 624 00:29:21,960 --> 00:29:24,080 dog if it doesn't contain your full 625 00:29:24,080 --> 00:29:25,960 history at least it tells me where your 626 00:29:25,960 --> 00:29:28,840 git server is right I can start doing 627 00:29:28,840 --> 00:29:31,720 attribution of this image back to a 628 00:29:31,720 --> 00:29:34,519 server or back to a GitHub org or back 629 00:29:34,519 --> 00:29:36,960 to a GitHub Enterprise that you are 630 00:29:36,960 --> 00:29:40,399 running yourself or gitlab or blah blah 631 00:29:40,399 --> 00:29:42,440 blah blah blah kit config can also 632 00:29:42,440 --> 00:29:44,640 contain the credentials that CH checked 633 00:29:44,640 --> 00:29:47,600 out the repo which means I can pivot 634 00:29:47,600 --> 00:29:51,760 from an image into your git right so I 635 00:29:51,760 --> 00:29:53,159 can get full history of all the projects 636 00:29:53,159 --> 00:29:54,760 that this key had access 637 00:29:54,760 --> 00:29:58,000 to readme files UIL Scripts terraform 638 00:29:58,000 --> 00:30:01,720 files like with one pull if you don't 639 00:30:01,720 --> 00:30:04,200 pivot immediately to static credentials 640 00:30:04,200 --> 00:30:06,480 you get an insane amount of Recon 641 00:30:06,480 --> 00:30:10,159 information right all from a single copy 642 00:30:10,159 --> 00:30:13,799 dot dot dot right the other interesting 643 00:30:13,799 --> 00:30:17,399 thing about here this is is that Docker 644 00:30:17,399 --> 00:30:21,640 images are an amazingly good forensic 645 00:30:21,640 --> 00:30:24,679 platform I am doing this all on my local 646 00:30:24,679 --> 00:30:27,679 laptop right I can install any tool I 647 00:30:27,679 --> 00:30:30,760 want if I if I screw it up somehow I 648 00:30:30,760 --> 00:30:33,880 type rm- oh crap I just exit and start 649 00:30:33,880 --> 00:30:35,919 it over like I have an immutable image I 650 00:30:35,919 --> 00:30:39,600 can just always start over also I pulled 651 00:30:39,600 --> 00:30:40,600 this 652 00:30:40,600 --> 00:30:43,080 image there's probably not an audit 653 00:30:43,080 --> 00:30:44,559 trail of that 654 00:30:44,559 --> 00:30:47,720 occurring right by default GCR that 655 00:30:47,720 --> 00:30:50,039 bucket that backs GCR has no auditing 656 00:30:50,039 --> 00:30:53,120 configured so this is I get to take 657 00:30:53,120 --> 00:30:55,480 something there's no audit log and then 658 00:30:55,480 --> 00:30:56,919 I get to Paw through it to my heart's 659 00:30:56,919 --> 00:30:58,200 content 660 00:30:58,200 --> 00:31:02,039 right think about having the complete G 661 00:31:02,039 --> 00:31:06,200 history of any project that again that 662 00:31:06,200 --> 00:31:08,360 the developer thought was going to be 663 00:31:08,360 --> 00:31:10,960 private all those commits that are said 664 00:31:10,960 --> 00:31:13,960 LOL whoops I can rewind time and find 665 00:31:13,960 --> 00:31:15,279 those keys that you accidentally 666 00:31:15,279 --> 00:31:17,360 committed and then didn't rotate because 667 00:31:17,360 --> 00:31:19,440 Who the hell's going to see this 668 00:31:19,440 --> 00:31:23,360 whatever happened a 669 00:31:23,440 --> 00:31:25,159 lot 670 00:31:25,159 --> 00:31:28,279 so and and and this what what's the 671 00:31:28,279 --> 00:31:31,639 really striking and bad behavior here is 672 00:31:31,639 --> 00:31:34,799 static credentials for cicd 673 00:31:34,799 --> 00:31:39,279 systems just shouldn't be doing it full 674 00:31:39,279 --> 00:31:42,600 stop and they call it out in Cloud 675 00:31:42,600 --> 00:31:44,320 environments take advantage of cloud 676 00:31:44,320 --> 00:31:46,320 provided temporary and ephemeral 677 00:31:46,320 --> 00:31:47,639 credentials that are available to 678 00:31:47,639 --> 00:31:49,440 compute 679 00:31:49,440 --> 00:31:53,480 Services Google has what's it called 680 00:31:53,480 --> 00:31:57,760 Google workload identity Federation 681 00:31:57,760 --> 00:32:00,320 which means you can exchange an external 682 00:32:00,320 --> 00:32:03,399 token for short-lived sa credentials and 683 00:32:03,399 --> 00:32:06,639 that token can be an ADW Sig it can be 684 00:32:06,639 --> 00:32:08,360 an oidc 685 00:32:08,360 --> 00:32:11,200 token go read the docs it can support a 686 00:32:11,200 --> 00:32:14,000 ton of stuff but it requires a ton of 687 00:32:14,000 --> 00:32:15,960 preconfiguration and it requires a bunch 688 00:32:15,960 --> 00:32:17,519 of preconfiguration that you can also 689 00:32:17,519 --> 00:32:22,200 screw up which people do a lot when they 690 00:32:22,200 --> 00:32:25,080 have to validate oidc claims um because 691 00:32:25,080 --> 00:32:27,159 you got to know how oidc works right how 692 00:32:27,159 --> 00:32:30,120 JWT signatures work so it's no real 693 00:32:30,120 --> 00:32:32,799 surprise people are like screw this I 694 00:32:32,799 --> 00:32:35,000 can just export a service account Json 695 00:32:35,000 --> 00:32:37,679 file and it'll 696 00:32:38,159 --> 00:32:42,480 work so kind of like final takeaways 697 00:32:42,480 --> 00:32:44,679 right when you go 698 00:32:44,679 --> 00:32:49,279 back and you get back to work on Tuesday 699 00:32:49,279 --> 00:32:53,240 when you feel better um what what can 700 00:32:53,240 --> 00:32:55,559 you do like what can you troll around in 701 00:32:55,559 --> 00:32:58,440 your org and see bad and be able to be 702 00:32:58,440 --> 00:33:00,840 like oh this smells 703 00:33:00,840 --> 00:33:05,360 right number one copy dot dot don't be 704 00:33:05,360 --> 00:33:08,720 doing it it it's really bad because it 705 00:33:08,720 --> 00:33:10,880 means you're not aware or you have to 706 00:33:10,880 --> 00:33:13,919 constantly be aware of what is in build 707 00:33:13,919 --> 00:33:16,159 context which can be surprising when 708 00:33:16,159 --> 00:33:18,080 you're running CI and it's just over 709 00:33:18,080 --> 00:33:20,799 there right you can't run LS in the 710 00:33:20,799 --> 00:33:21,960 middle of your pipeline and see what's 711 00:33:21,960 --> 00:33:23,960 in the working 712 00:33:23,960 --> 00:33:27,080 directory and what's especially like 713 00:33:27,080 --> 00:33:29,200 nefarious about the build context leaks 714 00:33:29,200 --> 00:33:32,600 in this is you've baked the whole build 715 00:33:32,600 --> 00:33:35,399 context into your image but your image 716 00:33:35,399 --> 00:33:38,720 works so why would you ever look the 717 00:33:38,720 --> 00:33:41,519 only time anyone pulls an image locally 718 00:33:41,519 --> 00:33:43,639 and cracks it open is when the thing is 719 00:33:43,639 --> 00:33:46,279 broken right I should say that whalsay 720 00:33:46,279 --> 00:33:47,840 service that leaked the credential it 721 00:33:47,840 --> 00:33:49,960 works just fine like there would be no 722 00:33:49,960 --> 00:33:51,799 reason for me to pull it and look inside 723 00:33:51,799 --> 00:33:53,639 of it right it 724 00:33:53,639 --> 00:33:57,480 worked adopt Docker ignore right 725 00:33:57,480 --> 00:33:59,720 Docker ignores a little iffy because 726 00:33:59,720 --> 00:34:01,840 it's an explicit block list so you have 727 00:34:01,840 --> 00:34:04,360 to know the sensitive things that are in 728 00:34:04,360 --> 00:34:08,599 context to block them right block lists 729 00:34:08,599 --> 00:34:10,679 are a lot harder to maintain than allow 730 00:34:10,679 --> 00:34:13,399 lists because you can always sneak past 731 00:34:13,399 --> 00:34:15,320 block 732 00:34:15,320 --> 00:34:19,239 list line five maybe consider Docker 733 00:34:19,239 --> 00:34:21,639 multi-stage builds you'll end up with 734 00:34:21,639 --> 00:34:24,239 smaller images you have to be much more 735 00:34:24,239 --> 00:34:25,918 explicit about the things that you're 736 00:34:25,918 --> 00:34:28,760 are copying into the final build this is 737 00:34:28,760 --> 00:34:31,040 really dependent on your technology like 738 00:34:31,040 --> 00:34:32,960 this works better for some technologies 739 00:34:32,960 --> 00:34:36,719 than others um and it's also a practice 740 00:34:36,719 --> 00:34:38,879 that's kind of driven by the community 741 00:34:38,879 --> 00:34:43,040 right go every go example does this not 742 00:34:43,040 --> 00:34:45,800 many note examples do it right so if I 743 00:34:45,800 --> 00:34:48,280 grabbed an first of all I can spot a go 744 00:34:48,280 --> 00:34:51,719 image by the size of the image and know 745 00:34:51,719 --> 00:34:53,800 that if I grabbed it it probably doesn't 746 00:34:53,800 --> 00:34:55,520 even have a shell in the image right 747 00:34:55,520 --> 00:34:57,680 what a pain in the ass for forensics 748 00:34:57,680 --> 00:34:59,280 move on right there's lower hanging 749 00:34:59,280 --> 00:35:00,800 fruit for 750 00:35:00,800 --> 00:35:03,599 sure seven workload identity Federation 751 00:35:03,599 --> 00:35:07,000 for cicd stop using static 752 00:35:07,000 --> 00:35:09,320 credentials but we need no no no no stop 753 00:35:09,320 --> 00:35:11,760 using static 754 00:35:11,960 --> 00:35:15,040 credentials um if you are supporting 755 00:35:15,040 --> 00:35:17,640 developers who are using your pipeline 756 00:35:17,640 --> 00:35:21,160 set it up for them because while you may 757 00:35:21,160 --> 00:35:24,119 control the build context and the 758 00:35:24,119 --> 00:35:25,920 infrastructure around your cicd system 759 00:35:25,920 --> 00:35:27,480 you probably don't control the docker 760 00:35:27,480 --> 00:35:31,800 file right so like the garbage in is the 761 00:35:31,800 --> 00:35:34,160 stuff you don't get to control but maybe 762 00:35:34,160 --> 00:35:36,440 you can help filter the garbage 763 00:35:36,440 --> 00:35:37,960 out 764 00:35:37,960 --> 00:35:39,640 finally 765 00:35:39,640 --> 00:35:42,880 reconsider how sensitive you treat 766 00:35:42,880 --> 00:35:45,880 internal Docker images right it turns 767 00:35:45,880 --> 00:35:49,040 out that they're really easy to screw up 768 00:35:49,040 --> 00:35:51,440 and even if you if you even if you're on 769 00:35:51,440 --> 00:35:53,640 your best behavior you can still screw 770 00:35:53,640 --> 00:35:57,359 it up so think about if you do internal 771 00:35:57,359 --> 00:36:00,720 segmentation by teams who can pull what 772 00:36:00,720 --> 00:36:03,680 from where what workload deployments can 773 00:36:03,680 --> 00:36:06,040 pull from what Registries should they be 774 00:36:06,040 --> 00:36:08,960 able to do that right cuz then you're 775 00:36:08,960 --> 00:36:11,839 talking about Mitigation Of pivots due 776 00:36:11,839 --> 00:36:14,000 to compromise which is what you should 777 00:36:14,000 --> 00:36:15,800 be thinking about at every step right 778 00:36:15,800 --> 00:36:18,760 something's always going to go wrong but 779 00:36:18,760 --> 00:36:21,560 you need it to go wrong in a series for 780 00:36:21,560 --> 00:36:23,319 it to pay off it shouldn't be like it 781 00:36:23,319 --> 00:36:25,280 goes wrong once and you're 782 00:36:25,280 --> 00:36:28,079 screwed so just think about internal 783 00:36:28,079 --> 00:36:31,040 segmentation and images are opaque right 784 00:36:31,040 --> 00:36:33,520 you just get this big fat blob when you 785 00:36:33,520 --> 00:36:36,119 get back download a bunch from your org 786 00:36:36,119 --> 00:36:38,640 crack them open and look just go look 787 00:36:38,640 --> 00:36:41,760 you'll be either like great work 788 00:36:41,760 --> 00:36:44,560 everybody these are spotless or holy 789 00:36:44,560 --> 00:36:46,400 crap would like this is the worst 790 00:36:46,400 --> 00:36:48,359 possible thing and then you know paste 791 00:36:48,359 --> 00:36:49,960 it into slack like what the hell are we 792 00:36:49,960 --> 00:36:52,920 doing um but think about it right just 793 00:36:52,920 --> 00:36:54,480 go 794 00:36:54,480 --> 00:36:57,160 look um if you're kind of interested in 795 00:36:57,160 --> 00:37:01,200 reading more about this there is a paper 796 00:37:01,200 --> 00:37:04,280 in July secrets revealed in container 797 00:37:04,280 --> 00:37:06,440 images an internet wide stady on 798 00:37:06,440 --> 00:37:08,760 occurrence and impact same kind of deal 799 00:37:08,760 --> 00:37:11,400 these researchers go troll through 800 00:37:11,400 --> 00:37:14,839 dockerhub public repositories and also 801 00:37:14,839 --> 00:37:17,640 do a bunch of Port scanning to find 802 00:37:17,640 --> 00:37:19,480 default Docker Registries on like P 803 00:37:19,480 --> 00:37:20,720 5,000 or something like that on the 804 00:37:20,720 --> 00:37:22,839 internet and just pull from there and 805 00:37:22,839 --> 00:37:25,560 they are able to correlate a ton of 806 00:37:25,560 --> 00:37:29,040 private keys in Docker images to public 807 00:37:29,040 --> 00:37:32,640 TLS shts right so they find all kinds 808 00:37:32,640 --> 00:37:34,240 all kinds of Secrets but those are the 809 00:37:34,240 --> 00:37:35,839 ones they actually validate using public 810 00:37:35,839 --> 00:37:39,400 data it's a super cool paper um that's 811 00:37:39,400 --> 00:37:42,119 it I think I hit time pretty well so we 812 00:37:42,119 --> 00:37:45,640 have like five minutes for questions or 813 00:37:45,640 --> 00:37:50,270 we can chat in the hall or whatever 814 00:37:50,270 --> 00:37:54,329 [Applause] 815 00:37:55,599 --> 00:37:58,599 works 816 00:38:01,560 --> 00:38:02,960 uh what do you think about the 817 00:38:02,960 --> 00:38:05,599 application at startup just using its 818 00:38:05,599 --> 00:38:08,359 Cloud identity itself in an SDK to 819 00:38:08,359 --> 00:38:10,920 authenticate and get any secrets that it 820 00:38:10,920 --> 00:38:12,920 needs just in memory right so the 821 00:38:12,920 --> 00:38:15,920 question was uh what do I think about 822 00:38:15,920 --> 00:38:18,880 using the process runtime identity to 823 00:38:18,880 --> 00:38:21,000 pull secrets from an external Source 824 00:38:21,000 --> 00:38:22,160 yeah that's what you should be doing 825 00:38:22,160 --> 00:38:24,640 absolutely you should be using runtime 826 00:38:24,640 --> 00:38:27,000 identity attestation to pull Secrets at 827 00:38:27,000 --> 00:38:30,280 startup uh everything use Vault use 828 00:38:30,280 --> 00:38:32,319 Google secret manager use 829 00:38:32,319 --> 00:38:35,920 AWS use um if you're using kubernetes 830 00:38:35,920 --> 00:38:39,520 use volume mounts don't use secret ref 831 00:38:39,520 --> 00:38:43,079 in environments temps use temp FS yeah 832 00:38:43,079 --> 00:38:45,720 like just don't put it on don't put it 833 00:38:45,720 --> 00:38:47,920 on permanent disc don't don't write it 834 00:38:47,920 --> 00:38:51,359 to dis right just yes use an external 835 00:38:51,359 --> 00:38:53,280 secret manager where you use your 836 00:38:53,280 --> 00:38:55,200 runtime identity to pull the secrets it 837 00:38:55,200 --> 00:38:56,720 just it also means that you can use 838 00:38:56,720 --> 00:38:59,319 runtime identity to be much more strict 839 00:38:59,319 --> 00:39:00,839 about what secrets are available to what 840 00:39:00,839 --> 00:39:03,040 run 841 00:39:03,640 --> 00:39:07,720 times yeah did you find a lot of within 842 00:39:07,720 --> 00:39:09,839 layers people removing their secrets 843 00:39:09,839 --> 00:39:12,119 where you would go back one today okay 844 00:39:12,119 --> 00:39:14,520 okay so the question was did you find 845 00:39:14,520 --> 00:39:17,079 secrets in layers that then got 846 00:39:17,079 --> 00:39:20,720 removed yes which is like the most CTF 847 00:39:20,720 --> 00:39:22,359 thing in the world right there's a 848 00:39:22,359 --> 00:39:24,040 secret in a layer and you have to unpack 849 00:39:24,040 --> 00:39:27,760 the layers yeah just today I found um 850 00:39:27,760 --> 00:39:30,560 something that has to pull it uses a 851 00:39:30,560 --> 00:39:33,359 build key to clone another repo right 852 00:39:33,359 --> 00:39:36,119 and so run copy the build key in Clone 853 00:39:36,119 --> 00:39:38,040 it remove the build key that build key 854 00:39:38,040 --> 00:39:39,599 is still in the image right unless you 855 00:39:39,599 --> 00:39:43,359 do it in one shot it's in each 856 00:39:44,680 --> 00:39:47,240 layer one more uh you talked a lot about 857 00:39:47,240 --> 00:39:49,319 the foot guns and the fact that sort of 858 00:39:49,319 --> 00:39:53,240 documentation and address them what sort 859 00:39:53,240 --> 00:39:56,000 of do you think is the best way for like 860 00:39:56,000 --> 00:39:58,400 better 861 00:39:58,880 --> 00:40:01,319 prevention 862 00:40:02,240 --> 00:40:04,640 of so the question is like what should 863 00:40:04,640 --> 00:40:07,000 we do about bad UI design and 864 00:40:07,000 --> 00:40:09,760 associating the documentation with it 865 00:40:09,760 --> 00:40:11,200 like how do you get that information in 866 00:40:11,200 --> 00:40:13,880 front of users um I actually think AWS 867 00:40:13,880 --> 00:40:15,760 has the best pattern for that anytime 868 00:40:15,760 --> 00:40:17,119 you're about to do something dangerous 869 00:40:17,119 --> 00:40:20,200 or destructive they repeat to you what 870 00:40:20,200 --> 00:40:22,319 it is you're about to do and what you're 871 00:40:22,319 --> 00:40:24,640 about to do it to and then you have to 872 00:40:24,640 --> 00:40:26,560 confirm it by like typing delete or 873 00:40:26,560 --> 00:40:30,119 pasting the resource name um right 874 00:40:30,119 --> 00:40:31,400 that's just harm reduction you're about 875 00:40:31,400 --> 00:40:32,640 to do something dangerous are you sure 876 00:40:32,640 --> 00:40:33,760 you want to do 877 00:40:33,760 --> 00:40:36,160 that 878 00:40:36,160 --> 00:40:39,319 cool thank 879 00:40:39,560 --> 00:40:42,560 you