1 00:00:00,760 --> 00:00:04,200 okay here we go next up we've got Hubert 2 00:00:04,200 --> 00:00:06,759 Lynn an offensive security expert Hubert 3 00:00:06,759 --> 00:00:09,160 will be T talking to us about gcp Cloud 4 00:00:09,160 --> 00:00:11,160 shell uh That featuring some interesting 5 00:00:11,160 --> 00:00:13,000 and unexpected findings actually 6 00:00:13,000 --> 00:00:14,799 discovered during his Recon the title of 7 00:00:14,799 --> 00:00:17,320 her's talk is one port to serve them all 8 00:00:17,320 --> 00:00:19,680 Google gcps Cloud shell abuse everyone 9 00:00:19,680 --> 00:00:22,279 please welcome 10 00:00:23,920 --> 00:00:25,640 here thank 11 00:00:25,640 --> 00:00:28,359 you hello everyone how's it going in 12 00:00:28,359 --> 00:00:31,000 Vegas 13 00:00:31,000 --> 00:00:34,719 wo uh I'm Hill Berlin I'm on the desk of 14 00:00:34,719 --> 00:00:37,480 theb teams and today we're going to uh 15 00:00:37,480 --> 00:00:39,960 talk about the abuse methodology 16 00:00:39,960 --> 00:00:42,640 regarding the Google gcp cloud 17 00:00:42,640 --> 00:00:44,719 share 18 00:00:44,719 --> 00:00:47,520 uh at beginning we'll be talking about 19 00:00:47,520 --> 00:00:51,320 what a cloud Shield is and after we 20 00:00:51,320 --> 00:00:53,680 initiated a cloud Shield instance we 21 00:00:53,680 --> 00:00:57,000 have some Recon and what's the finding 22 00:00:57,000 --> 00:01:00,600 we we we found during the discovery uh 23 00:01:00,600 --> 00:01:04,360 Discovery stage and how we abuse one of 24 00:01:04,360 --> 00:01:07,400 the open board we found to 25 00:01:07,400 --> 00:01:09,320 further to 26 00:01:09,320 --> 00:01:14,000 further up more impact to the users and 27 00:01:14,000 --> 00:01:17,119 then we'll talk about the mitigation and 28 00:01:17,119 --> 00:01:19,640 how we can counter measure uh this kind 29 00:01:19,640 --> 00:01:21,880 of 30 00:01:21,880 --> 00:01:24,320 abuse so let's talk about what's the 31 00:01:24,320 --> 00:01:28,479 cloud Shi Cloud shell is basically a 32 00:01:28,479 --> 00:01:33,399 a interface terminal that you can access 33 00:01:33,399 --> 00:01:36,439 your car resource or manage your Cloud 34 00:01:36,439 --> 00:01:40,799 resource and with in the clal instance 35 00:01:40,799 --> 00:01:43,520 the vendor actually preloaded or 36 00:01:43,520 --> 00:01:46,240 pre-install a lot of useful tools 37 00:01:46,240 --> 00:01:49,399 especially those are related with the 38 00:01:49,399 --> 00:01:55,360 cloud access in gcp such as gcloud or 39 00:01:55,360 --> 00:01:59,920 GS something like that and for the 40 00:01:59,920 --> 00:02:03,600 developer is also has a lot of program 41 00:02:03,600 --> 00:02:06,200 uh language installed so you can have 42 00:02:06,200 --> 00:02:09,560 your uh testing or 43 00:02:09,560 --> 00:02:14,000 ding apps running or testing have a uh 44 00:02:14,000 --> 00:02:15,680 uh on Cal 45 00:02:15,680 --> 00:02:19,239 instance for Cal instance it has a 46 00:02:19,239 --> 00:02:23,200 pretty short lifespan according to your 47 00:02:23,200 --> 00:02:26,879 activity if you have for for Google you 48 00:02:26,879 --> 00:02:31,080 have inactiv for few more than 60 49 00:02:31,080 --> 00:02:34,239 minutes it will get you disconnected and 50 00:02:34,239 --> 00:02:36,680 you might lose your 51 00:02:36,680 --> 00:02:38,239 sessions 52 00:02:38,239 --> 00:02:43,680 but the sh instance have some a few Mega 53 00:02:43,680 --> 00:02:47,200 a few gigs of precis T that we can use 54 00:02:47,200 --> 00:02:50,720 and which uh we can save a lot of useful 55 00:02:50,720 --> 00:02:52,920 tools or scripts or even your 56 00:02:52,920 --> 00:02:55,319 configuration for later 57 00:02:55,319 --> 00:03:00,800 use so once we have the claure instance 58 00:03:00,800 --> 00:03:04,599 launched we have a map scan against this 59 00:03:04,599 --> 00:03:08,599 inre public IP as well as this private 60 00:03:08,599 --> 00:03:10,590 IP from 61 00:03:10,590 --> 00:03:12,280 [Music] 62 00:03:12,280 --> 00:03:18,200 the list above we found two open ports 63 00:03:18,200 --> 00:03:19,360 that is 64 00:03:19,360 --> 00:03:21,000 publicly 65 00:03:21,000 --> 00:03:24,959 accessible but the result is quite 66 00:03:24,959 --> 00:03:28,760 inconsistent to how we found to the 67 00:03:28,760 --> 00:03:30,400 private 68 00:03:30,400 --> 00:03:32,400 IP 69 00:03:32,400 --> 00:03:36,120 results and by comparing to to Le we 70 00:03:36,120 --> 00:03:38,239 found that the 71 00:03:38,239 --> 00:03:43,720 only consistence is the open SSH version 72 00:03:43,720 --> 00:03:49,879 8.9 which uh with extra observation by 73 00:03:49,879 --> 00:03:54,599 using TCP dump as well as uh Nest States 74 00:03:54,599 --> 00:03:56,000 we can 75 00:03:56,000 --> 00:04:00,439 further understand that in N States 76 00:04:00,439 --> 00:04:06,079 we see that 422 is used by S demon and 77 00:04:06,079 --> 00:04:08,840 through the TCP D we can observe that 78 00:04:08,840 --> 00:04:10,319 this Sy 79 00:04:10,319 --> 00:04:16,238 package observed from the port 922 it's 80 00:04:16,238 --> 00:04:20,720 actually from externals for 6,000 so 81 00:04:20,720 --> 00:04:25,720 that's the basic idea of the current po 82 00:04:26,000 --> 00:04:28,320 exposed before we move on there's 83 00:04:28,320 --> 00:04:30,800 another feature called the web preview 84 00:04:30,800 --> 00:04:34,840 web preview is uh an extra feature in 85 00:04:34,840 --> 00:04:37,400 the cloud shell that provide the 86 00:04:37,400 --> 00:04:40,639 developers to test their own 87 00:04:40,639 --> 00:04:46,039 applications through extra H HTP PS 88 00:04:46,039 --> 00:04:50,360 layer it's more like Google will add the 89 00:04:50,360 --> 00:04:54,680 htps layer for you and that directed to 90 00:04:54,680 --> 00:05:00,479 the backend HTP servers in your C so the 91 00:05:00,479 --> 00:05:02,720 develop developers can just focus on his 92 00:05:02,720 --> 00:05:05,960 own web without uh 93 00:05:05,960 --> 00:05:10,560 further uh without the has of T 94 00:05:10,560 --> 00:05:16,919 stuff and we have once we have the 95 00:05:17,360 --> 00:05:23,319 Cal preview clicked it will redirect us 96 00:05:23,319 --> 00:05:27,600 with a few H HTP 302 redirection by 97 00:05:27,600 --> 00:05:31,720 bypassing the all token further to the 98 00:05:31,720 --> 00:05:35,639 final URL the final URL looks like that 99 00:05:35,639 --> 00:05:38,520 will ends with Cloud shell dat there if 100 00:05:38,520 --> 00:05:43,360 we share this link to someone else uh it 101 00:05:43,360 --> 00:05:46,400 actually will not work they will get a 102 00:05:46,400 --> 00:05:49,199 Google authentication prompt to ask for 103 00:05:49,199 --> 00:05:51,840 authentication actually this URL is only 104 00:05:51,840 --> 00:05:55,919 for for the user that launches the Pu sh 105 00:05:55,919 --> 00:05:58,919 instance 106 00:06:01,600 --> 00:06:04,240 and by 107 00:06:04,919 --> 00:06:09,599 observing by adding the web web 108 00:06:09,599 --> 00:06:13,720 preview view to the to our diagram we 109 00:06:13,720 --> 00:06:16,720 can have diagram like this on the left 110 00:06:16,720 --> 00:06:20,080 hand side we have authenticated users 111 00:06:20,080 --> 00:06:23,560 that can access our web service through 112 00:06:23,560 --> 00:06:29,680 an identity aware proxy over the https 113 00:06:31,360 --> 00:06:35,120 and let's talk about the refuseed 114 00:06:35,120 --> 00:06:37,960 methodology from this 115 00:06:37,960 --> 00:06:41,919 diagram we can we only have control over 116 00:06:41,919 --> 00:06:48,720 the Blue Area the container part so by a 117 00:06:48,720 --> 00:06:52,440 little hacking in the Netflix uh 118 00:06:52,440 --> 00:06:55,720 Netflix net filter in lenux we can 119 00:06:55,720 --> 00:06:57,400 redirect the 120 00:06:57,400 --> 00:07:01,800 traffic to the 922 to several different 121 00:07:01,800 --> 00:07:06,720 Services based on where they connected 122 00:07:06,720 --> 00:07:09,759 from the idea is quite 123 00:07:09,759 --> 00:07:14,240 simple this is part of the diagram of 124 00:07:14,240 --> 00:07:19,080 the litics net filter and we can have 125 00:07:19,080 --> 00:07:22,280 control in the pre- routing chain in the 126 00:07:22,280 --> 00:07:24,319 NAT 127 00:07:24,319 --> 00:07:28,039 tables and by adding actra granularity 128 00:07:28,039 --> 00:07:31,400 to the firewall rules we can control how 129 00:07:31,400 --> 00:07:34,639 the package FL to our internal 130 00:07:34,639 --> 00:07:39,440 services from the sh SCP below we have 131 00:07:39,440 --> 00:07:41,919 three different CER blocks 132 00:07:41,919 --> 00:07:47,039 defined for the first one this SSH for 133 00:07:47,039 --> 00:07:52,240 attackers like you guys and for the last 134 00:07:52,240 --> 00:07:55,960 one with the Wiest range for the rest of 135 00:07:55,960 --> 00:08:00,120 the world so with 136 00:08:00,120 --> 00:08:04,280 uh first match with priority keeps in 137 00:08:04,280 --> 00:08:08,319 mind we insert the rule that has the 138 00:08:08,319 --> 00:08:12,000 most widest range first and the most 139 00:08:12,000 --> 00:08:14,520 narrowest one in the 140 00:08:14,520 --> 00:08:17,840 end and after we apply 141 00:08:17,840 --> 00:08:22,479 the firewall rules we can have a path 142 00:08:22,479 --> 00:08:27,319 like this so from this from this diagram 143 00:08:27,319 --> 00:08:29,879 the users connected from the side one 144 00:08:29,879 --> 00:08:35,599 will have sess service to P 6,000 and 145 00:08:35,599 --> 00:08:39,360 for users from c 2 they will have a sub 146 00:08:39,360 --> 00:08:42,279 server and for the rest of the world if 147 00:08:42,279 --> 00:08:44,399 they connected to the 148 00:08:44,399 --> 00:08:49,279 46,000 they will have an HTTP 149 00:08:49,279 --> 00:08:52,480 server that's that's the whole point of 150 00:08:52,480 --> 00:08:53,880 of the 151 00:08:53,880 --> 00:08:57,560 topic that we abuse only one single open 152 00:08:57,560 --> 00:09:00,360 p to serve different 153 00:09:00,360 --> 00:09:02,480 a different service to the 154 00:09:02,480 --> 00:09:05,649 [Music] 155 00:09:08,160 --> 00:09:13,440 world and du the Green Path for the rest 156 00:09:13,440 --> 00:09:18,120 of the world we somehow can bypass the I 157 00:09:18,120 --> 00:09:22,920 proxy earlier then we need to access the 158 00:09:22,920 --> 00:09:28,040 web Serv so this somehow get us bypass 159 00:09:28,040 --> 00:09:31,079 to that proxy and direct access to our 160 00:09:31,079 --> 00:09:34,920 web uh to our internal 161 00:09:35,920 --> 00:09:39,240 servers so we could dump the original 162 00:09:39,240 --> 00:09:43,399 official URL which requires Google 163 00:09:43,399 --> 00:09:47,880 authentication and use our new 164 00:09:47,880 --> 00:09:51,600 URL which is actually the 165 00:09:51,600 --> 00:09:56,000 reverse domain from our e IP which is 166 00:09:56,000 --> 00:09:58,240 pretty perfect that ends with Google 167 00:09:58,240 --> 00:10:02,079 user content.com which 168 00:10:02,079 --> 00:10:05,279 somehow gave us some advantage to 169 00:10:05,279 --> 00:10:09,560 further maybe could bypass some of these 170 00:10:09,560 --> 00:10:12,640 security controls 171 00:10:12,640 --> 00:10:15,760 instructions or better yet if you new if 172 00:10:15,760 --> 00:10:19,279 new an https service and you have your 173 00:10:19,279 --> 00:10:22,160 own DNS you can also configure your DNS 174 00:10:22,160 --> 00:10:25,440 server and get some certificate set up 175 00:10:25,440 --> 00:10:29,959 to make this all over htvs all through 176 00:10:29,959 --> 00:10:32,030 the external 177 00:10:32,030 --> 00:10:35,419 [Music] 178 00:10:36,639 --> 00:10:39,880 46,000 so let's talk about the impacts 179 00:10:39,880 --> 00:10:43,279 the first impact is the pre web preview 180 00:10:43,279 --> 00:10:46,399 of bypass we earlier talked about and by 181 00:10:46,399 --> 00:10:50,760 doing so we could further uh since the 182 00:10:50,760 --> 00:10:55,040 server is we uh is perly available to 183 00:10:55,040 --> 00:10:58,279 the world so we could do something evil 184 00:10:58,279 --> 00:11:02,639 Maybe by this building malw do that port 185 00:11:02,639 --> 00:11:07,880 or we could do some more uh Evo stuff by 186 00:11:07,880 --> 00:11:11,279 ex X in the cloud 187 00:11:11,279 --> 00:11:15,160 resources to to the web 188 00:11:15,560 --> 00:11:19,959 service and by adding extra HTTP uh SSH 189 00:11:19,959 --> 00:11:22,920 public key to the P 190 00:11:22,920 --> 00:11:29,320 here we could also dump the web we 191 00:11:29,320 --> 00:11:31,160 used to access the web 192 00:11:31,160 --> 00:11:35,040 sh and we can use only the SSH native 193 00:11:35,040 --> 00:11:40,719 SSH client to access our CL sh as 194 00:11:41,200 --> 00:11:45,360 well and from the sub servers we created 195 00:11:45,360 --> 00:11:48,680 we could somehow pivot in our traffic 196 00:11:48,680 --> 00:11:52,839 even uh either malicious or py to make 197 00:11:52,839 --> 00:11:54,680 the traffic all through the Google 198 00:11:54,680 --> 00:11:57,959 Network which could be possibly used to 199 00:11:57,959 --> 00:12:01,279 bypass certain restriction C or we can 200 00:12:01,279 --> 00:12:05,200 also create indirect C2 access to some 201 00:12:05,200 --> 00:12:08,200 C2 servers somewhere it will looks like 202 00:12:08,200 --> 00:12:11,040 they're connected all through the Google 203 00:12:11,040 --> 00:12:14,400 [Music] 204 00:12:15,240 --> 00:12:19,600 networ to further mitigate this uh the 205 00:12:19,600 --> 00:12:23,040 first one I recommend is the fa MFA 206 00:12:23,040 --> 00:12:27,040 hardening since I think most of us use 207 00:12:27,040 --> 00:12:29,839 the time base one time password right 208 00:12:29,839 --> 00:12:34,320 the authenticators from various vendors 209 00:12:34,320 --> 00:12:38,639 um from my previous raim exercises I'm 210 00:12:38,639 --> 00:12:43,240 sure that the this one is pretty feable 211 00:12:43,240 --> 00:12:46,800 and it's also recommended by Google that 212 00:12:46,800 --> 00:12:48,839 do not use 213 00:12:48,839 --> 00:12:53,880 TTP for the resource that as uh has I 214 00:12:53,880 --> 00:12:56,760 value I value 215 00:12:56,760 --> 00:12:59,480 resources the best practice will be us 216 00:12:59,480 --> 00:13:01,720 Hardware based security key which is 217 00:13:01,720 --> 00:13:05,120 more efficient 218 00:13:05,560 --> 00:13:08,600 resistance and the second one is uh we 219 00:13:08,600 --> 00:13:11,279 can have a review of our access control 220 00:13:11,279 --> 00:13:16,000 of the cloud shell to see if it's really 221 00:13:16,000 --> 00:13:19,279 necessary to allow certain users or 222 00:13:19,279 --> 00:13:22,880 certain groups of users to have that 223 00:13:22,880 --> 00:13:26,720 privilege if not we could use the Google 224 00:13:26,720 --> 00:13:33,240 admin console not the counil to further 225 00:13:33,240 --> 00:13:35,210 Define which or 226 00:13:35,210 --> 00:13:37,079 [Music] 227 00:13:37,079 --> 00:13:40,360 you could or could not have that clal 228 00:13:40,360 --> 00:13:43,079 access 229 00:13:45,000 --> 00:13:49,560 privilege the third one is the port we 230 00:13:49,560 --> 00:13:53,000 discovered during our 231 00:13:53,360 --> 00:13:57,519 Recon that it's pretty unusual that who 232 00:13:57,519 --> 00:14:01,160 has two this two p exposed to the world 233 00:14:01,160 --> 00:14:04,920 which is uh I think is not necessary for 234 00:14:04,920 --> 00:14:08,040 the users since probably don't need to 235 00:14:08,040 --> 00:14:11,440 expose this to SSH service to the world 236 00:14:11,440 --> 00:14:13,480 so maybe they could somehow mitigate 237 00:14:13,480 --> 00:14:19,279 that or make it more private to to the 238 00:14:20,240 --> 00:14:23,920 world and last but not least it's the 239 00:14:23,920 --> 00:14:27,079 principle of PR uh this privilege we can 240 00:14:27,079 --> 00:14:29,560 all uh review all our resource IM am 241 00:14:29,560 --> 00:14:32,560 rules and the permissions we uh we've 242 00:14:32,560 --> 00:14:36,800 been assigned in for them to a few tools 243 00:14:36,800 --> 00:14:38,240 provided by 244 00:14:38,240 --> 00:14:42,040 Google such as the policy analyzer as 245 00:14:42,040 --> 00:14:46,199 well as the recommander in Rec Commander 246 00:14:46,199 --> 00:14:50,079 they have some kind of AI model that can 247 00:14:50,079 --> 00:14:53,800 learn the permissions used in the past 248 00:14:53,800 --> 00:14:57,480 90 days and it will give you some 249 00:14:57,480 --> 00:15:00,639 insight to show you if certain 250 00:15:00,639 --> 00:15:02,800 permissions is over overly 251 00:15:02,800 --> 00:15:06,120 granted and which permission you can 252 00:15:06,120 --> 00:15:09,880 remote or even you can use a 253 00:15:09,880 --> 00:15:13,800 more less privileged I am role to get 254 00:15:13,800 --> 00:15:16,519 their drop 255 00:15:18,160 --> 00:15:21,880 down this is a disclosure line of these 256 00:15:21,880 --> 00:15:25,199 abuse to 257 00:15:25,240 --> 00:15:29,959 Google I've disced around April 258 00:15:29,959 --> 00:15:35,199 April and they have more than 100 days 259 00:15:35,199 --> 00:15:38,839 to mitigate this but the current latest 260 00:15:38,839 --> 00:15:43,600 status is that they still need to decide 261 00:15:43,600 --> 00:15:48,839 if the fix is needed or or 262 00:15:50,959 --> 00:15:55,839 not yeah that's all for me 263 00:16:01,480 --> 00:16:03,720 oh