1 00:00:00,900 --> 00:00:02,600 hi 2 00:00:02,600 --> 00:00:05,759 welcome to Defcon my name is jenko Wong 3 00:00:05,759 --> 00:00:09,420 I'd like to talk more about oauth abuse 4 00:00:09,420 --> 00:00:12,360 Arthur C Clarke has a notable quote 5 00:00:12,360 --> 00:00:15,179 about advanced technology seeming to be 6 00:00:15,179 --> 00:00:17,100 like magic and I think in the security 7 00:00:17,100 --> 00:00:20,400 industry Advanced attacks can also seem 8 00:00:20,400 --> 00:00:23,760 or appear to be magical as well 9 00:00:23,760 --> 00:00:26,400 but I think in reality taking the 10 00:00:26,400 --> 00:00:28,220 Security Professionals view 11 00:00:28,220 --> 00:00:32,340 too often it's just that the com the 12 00:00:32,340 --> 00:00:35,399 technology is complex and confusing and 13 00:00:35,399 --> 00:00:39,719 that really leads to a lot of room for 14 00:00:39,719 --> 00:00:41,460 abuse 15 00:00:41,460 --> 00:00:44,340 and so in order to dive in I want to 16 00:00:44,340 --> 00:00:47,280 first start quickly by summarizing where 17 00:00:47,280 --> 00:00:50,039 I think most of our attention is as a 18 00:00:50,039 --> 00:00:51,899 security industry so starting with 19 00:00:51,899 --> 00:00:53,760 phishing attacks 20 00:00:53,760 --> 00:00:56,520 uh a lot of the attacker focuses on 21 00:00:56,520 --> 00:00:59,219 fooling the victim into visiting a fake 22 00:00:59,219 --> 00:01:01,559 website or web app that they've created 23 00:01:01,559 --> 00:01:05,220 and somehow obtaining the user's 24 00:01:05,220 --> 00:01:08,100 credentials with their participation and 25 00:01:08,100 --> 00:01:09,840 with that they get access no surprise 26 00:01:09,840 --> 00:01:13,380 there defensively the focus then becomes 27 00:01:13,380 --> 00:01:16,619 a lot on filtering or detecting perhaps 28 00:01:16,619 --> 00:01:19,140 suspicious URLs or suspicious domains 29 00:01:19,140 --> 00:01:20,299 that 30 00:01:20,299 --> 00:01:23,640 are indicative of fake or suspicious 31 00:01:23,640 --> 00:01:27,020 websites and that can be done up front 32 00:01:27,020 --> 00:01:30,900 trying to detect a phishing messages of 33 00:01:30,900 --> 00:01:32,700 some sort that becomes a challenge 34 00:01:32,700 --> 00:01:35,100 there's a lot of mediums including 35 00:01:35,100 --> 00:01:38,040 mobile apps and various protocols 36 00:01:38,040 --> 00:01:39,540 besides email 37 00:01:39,540 --> 00:01:42,600 it can also be done at the HTTP level 38 00:01:42,600 --> 00:01:45,619 since these are HTTP 39 00:01:45,619 --> 00:01:51,420 URLs and so after the victim responds 40 00:01:51,420 --> 00:01:53,759 um something like a web proxy could 41 00:01:53,759 --> 00:01:55,979 filter and try to detect suspicious 42 00:01:55,979 --> 00:01:58,439 domains and URLs and block it at that 43 00:01:58,439 --> 00:02:00,119 point but again different devices 44 00:02:00,119 --> 00:02:02,340 including mobile may make that a 45 00:02:02,340 --> 00:02:04,820 challenge to be in line 46 00:02:04,820 --> 00:02:08,098 besides preventative measures we also 47 00:02:08,098 --> 00:02:10,860 tend to look at controls like MFA or 48 00:02:10,860 --> 00:02:13,560 policies and detect maybe something 49 00:02:13,560 --> 00:02:16,379 about the the victim or user or the the 50 00:02:16,379 --> 00:02:18,780 device or location you know their IP or 51 00:02:18,780 --> 00:02:20,580 device they're using and see if it's 52 00:02:20,580 --> 00:02:22,560 suspicious 53 00:02:22,560 --> 00:02:26,040 um if they don't provide MFA or can't as 54 00:02:26,040 --> 00:02:27,900 a way to mitigate 55 00:02:27,900 --> 00:02:29,700 um the the original credential being 56 00:02:29,700 --> 00:02:32,879 stolen sort of detect it in use and if 57 00:02:32,879 --> 00:02:34,860 it's suspicious enough try to block 58 00:02:34,860 --> 00:02:37,379 access 59 00:02:37,379 --> 00:02:40,319 there is also the traditional approach 60 00:02:40,319 --> 00:02:42,540 of security operations 61 00:02:42,540 --> 00:02:45,900 um assuming access is given uh there you 62 00:02:45,900 --> 00:02:50,239 know how do we detect activity of a 63 00:02:50,239 --> 00:02:53,400 unauthorized user and how do we actually 64 00:02:53,400 --> 00:02:56,940 remediate and revoke access 65 00:02:56,940 --> 00:02:58,560 so 66 00:02:58,560 --> 00:03:00,900 I want to start with browser in the 67 00:03:00,900 --> 00:03:04,379 browser uh as a phishing attack that has 68 00:03:04,379 --> 00:03:05,280 come up 69 00:03:05,280 --> 00:03:07,440 maybe in popularity recently although 70 00:03:07,440 --> 00:03:09,720 it's been around for several years and I 71 00:03:09,720 --> 00:03:11,580 have a reference at the bottom 72 00:03:11,580 --> 00:03:15,780 um Mr docs has some good code as well as 73 00:03:15,780 --> 00:03:17,819 demonstrations there 74 00:03:17,819 --> 00:03:21,300 um and what it looks like is we may 75 00:03:21,300 --> 00:03:25,140 actually be visiting a real website this 76 00:03:25,140 --> 00:03:28,319 is canva various design functionality 77 00:03:28,319 --> 00:03:30,900 when you log in 78 00:03:30,900 --> 00:03:34,560 uh you might be prompted for SSO or 79 00:03:34,560 --> 00:03:37,800 other ways to authenticate and you're 80 00:03:37,800 --> 00:03:40,080 presented in this case if it's SSO you 81 00:03:40,080 --> 00:03:42,120 might be presented with what appears to 82 00:03:42,120 --> 00:03:45,000 be the real Google login this is an 83 00:03:45,000 --> 00:03:47,220 oauth dialog 84 00:03:47,220 --> 00:03:49,220 UE being used for SSO 85 00:03:49,220 --> 00:03:51,799 everything looks legit 86 00:03:51,799 --> 00:03:55,200 but in fact here is where the attacker 87 00:03:55,200 --> 00:03:57,000 is doing 88 00:03:57,000 --> 00:03:58,980 um something a little bit magical 89 00:03:58,980 --> 00:04:01,080 although the URL 90 00:04:01,080 --> 00:04:06,540 uh is the valid Google URL for oauth 91 00:04:06,540 --> 00:04:09,239 um in fact underneath if we were looking 92 00:04:09,239 --> 00:04:12,239 at the wire a different domain and URL 93 00:04:12,239 --> 00:04:15,000 uh is is actually being presented to the 94 00:04:15,000 --> 00:04:18,180 user and so if they enter the credential 95 00:04:18,180 --> 00:04:21,600 here that it's uh under control of the 96 00:04:21,600 --> 00:04:24,240 attacker and they obtain the credential 97 00:04:24,240 --> 00:04:26,759 so the question is how how does this 98 00:04:26,759 --> 00:04:28,919 happen right 99 00:04:28,919 --> 00:04:32,699 um and the key to the browser and the 100 00:04:32,699 --> 00:04:36,240 browser Fish can be seen superficially 101 00:04:36,240 --> 00:04:40,440 if you move this pop-up dialog you can 102 00:04:40,440 --> 00:04:42,180 see it cuts off 103 00:04:42,180 --> 00:04:47,520 which strongly hints that it's a iframe 104 00:04:47,520 --> 00:04:50,280 or child window of sorts of the main 105 00:04:50,280 --> 00:04:52,320 browser window which is typically not 106 00:04:52,320 --> 00:04:54,540 the case with a real oauth dialogue so 107 00:04:54,540 --> 00:04:56,040 it's from a user perspective 108 00:04:56,040 --> 00:05:00,900 superficially it's quite subtle and 109 00:05:00,900 --> 00:05:04,680 how was this pulled off essentially this 110 00:05:04,680 --> 00:05:08,360 is just a little bit of magical CSS 111 00:05:08,360 --> 00:05:11,820 in this page that recreates 112 00:05:11,820 --> 00:05:14,220 the actual oauth dialog down to the 113 00:05:14,220 --> 00:05:19,259 icons fake URL address bar and so on and 114 00:05:19,259 --> 00:05:22,560 the actual post underneath 115 00:05:22,560 --> 00:05:24,539 um is a domain and URL under the 116 00:05:24,539 --> 00:05:25,860 attacker's control 117 00:05:25,860 --> 00:05:27,240 so 118 00:05:27,240 --> 00:05:30,720 if we look at this architecturally it is 119 00:05:30,720 --> 00:05:33,300 just another version of the old phishing 120 00:05:33,300 --> 00:05:36,000 attack the attacker has created a fake 121 00:05:36,000 --> 00:05:39,120 website probably registered that domain 122 00:05:39,120 --> 00:05:41,820 tried to make it as real as possible 123 00:05:41,820 --> 00:05:43,919 maybe an SSL cert 124 00:05:43,919 --> 00:05:46,820 and the steps to 125 00:05:46,820 --> 00:05:49,680 attacking the victim are pretty much the 126 00:05:49,680 --> 00:05:50,400 same 127 00:05:50,400 --> 00:05:52,500 as well as the end goal of obtaining 128 00:05:52,500 --> 00:05:54,660 username and password the only thing 129 00:05:54,660 --> 00:05:56,220 that's different is it's been updated 130 00:05:56,220 --> 00:06:00,180 somewhat for maybe the more modern web 131 00:06:00,180 --> 00:06:02,460 where we're playing the attackers 132 00:06:02,460 --> 00:06:05,940 playing off of the oauth authentication 133 00:06:05,940 --> 00:06:08,220 process which which is you know more 134 00:06:08,220 --> 00:06:12,300 popular in the last five years or so but 135 00:06:12,300 --> 00:06:14,460 fundamentally underneath at a protocol 136 00:06:14,460 --> 00:06:16,620 level this actually isn't very different 137 00:06:16,620 --> 00:06:20,520 but I raise it because it's relatively 138 00:06:20,520 --> 00:06:24,380 new er newer and popular 139 00:06:24,380 --> 00:06:27,900 and because of that because this is 140 00:06:27,900 --> 00:06:30,060 essentially A variation on the same old 141 00:06:30,060 --> 00:06:31,440 phishing attacks 142 00:06:31,440 --> 00:06:34,380 a lot of the techniques defensively 143 00:06:34,380 --> 00:06:36,539 still apply because things haven't 144 00:06:36,539 --> 00:06:39,060 fundamentally changed URL inspection up 145 00:06:39,060 --> 00:06:43,139 front MFA IP device detection or 146 00:06:43,139 --> 00:06:44,220 policies 147 00:06:44,220 --> 00:06:48,060 um when access is attempted and then a 148 00:06:48,060 --> 00:06:51,060 bunch of logging detection and clear 149 00:06:51,060 --> 00:06:54,300 procedures to revoke credentials once 150 00:06:54,300 --> 00:06:57,720 once detection has been had has actually 151 00:06:57,720 --> 00:06:58,860 occurred 152 00:06:58,860 --> 00:07:02,160 so let's move on and actually look at a 153 00:07:02,160 --> 00:07:03,479 different kind of fish called the 154 00:07:03,479 --> 00:07:06,660 illicit consent rat and 155 00:07:06,660 --> 00:07:08,460 um a few years back now it's running on 156 00:07:08,460 --> 00:07:11,360 four years or so uh 157 00:07:11,360 --> 00:07:15,380 forgive my pronunciation but juice solo 158 00:07:15,380 --> 00:07:18,600 has a particular blog and and good 159 00:07:18,600 --> 00:07:21,539 demonstration of this around Azure and 160 00:07:21,539 --> 00:07:23,340 office 365. 161 00:07:23,340 --> 00:07:24,840 and 162 00:07:24,840 --> 00:07:26,940 borrowing some screenshots to show the 163 00:07:26,940 --> 00:07:29,220 flow it still starts out with a fish and 164 00:07:29,220 --> 00:07:30,780 of course it doesn't have to be a 165 00:07:30,780 --> 00:07:34,319 straightforward email message they 166 00:07:34,319 --> 00:07:36,139 certainly could use other fishing 167 00:07:36,139 --> 00:07:38,759 variations including attachments that 168 00:07:38,759 --> 00:07:41,580 ultimately when opened uh execute or 169 00:07:41,580 --> 00:07:43,740 follow links 170 00:07:43,740 --> 00:07:47,099 um ultimately underneath 171 00:07:47,099 --> 00:07:47,759 um 172 00:07:47,759 --> 00:07:51,060 what this attack is now doing is 173 00:07:51,060 --> 00:07:53,639 actually being protocol specific to 174 00:07:53,639 --> 00:07:54,720 oauth 175 00:07:54,720 --> 00:07:56,340 so here 176 00:07:56,340 --> 00:07:58,199 um if we were watching The Wire we would 177 00:07:58,199 --> 00:08:00,660 see a URL 178 00:08:00,660 --> 00:08:01,620 um 179 00:08:01,620 --> 00:08:03,840 that the victim is enticed to follow 180 00:08:03,840 --> 00:08:06,360 that is actually a valid domain and 181 00:08:06,360 --> 00:08:07,819 oauth 182 00:08:07,819 --> 00:08:11,340 authentication authorization URL and 183 00:08:11,340 --> 00:08:13,919 this is shown in this red box and the 184 00:08:13,919 --> 00:08:18,080 parameters as well so at this level 185 00:08:18,080 --> 00:08:21,180 because of how oauth is designed there's 186 00:08:21,180 --> 00:08:22,759 very little information 187 00:08:22,759 --> 00:08:26,160 for URL filtering to detect and we'll 188 00:08:26,160 --> 00:08:28,080 come back to that in a short moment but 189 00:08:28,080 --> 00:08:30,259 just bear in mind that if 190 00:08:30,259 --> 00:08:32,700 software filters of any kind or picking 191 00:08:32,700 --> 00:08:34,799 this up it's very hard to detect this as 192 00:08:34,799 --> 00:08:36,419 a phishing attack at this moment because 193 00:08:36,419 --> 00:08:39,299 it's the oauth is so decoupled that 194 00:08:39,299 --> 00:08:41,299 we're really looking at very simple 195 00:08:41,299 --> 00:08:44,099 payloads to 196 00:08:44,099 --> 00:08:44,720 um 197 00:08:44,720 --> 00:08:47,880 valid domains and URLs of the oauth 198 00:08:47,880 --> 00:08:52,620 identity provider Microsoft in this case 199 00:08:52,620 --> 00:08:56,519 if the victim precedes uh and is is 200 00:08:56,519 --> 00:08:58,200 fooled they would be brought and 201 00:08:58,200 --> 00:08:59,940 presented with a real 202 00:08:59,940 --> 00:09:03,540 um oauth dialogue login and in this case 203 00:09:03,540 --> 00:09:05,880 unlike the browser in the browser this 204 00:09:05,880 --> 00:09:07,200 is valid 205 00:09:07,200 --> 00:09:09,240 um nothing fishy here they'd be prompted 206 00:09:09,240 --> 00:09:10,500 to log in 207 00:09:10,500 --> 00:09:13,680 maybe do MFA and as soon as they 208 00:09:13,680 --> 00:09:16,440 authenticate they are presented with uh 209 00:09:16,440 --> 00:09:18,480 typically some kind of approval dialogue 210 00:09:18,480 --> 00:09:21,240 that that mentions what permissions this 211 00:09:21,240 --> 00:09:24,300 application this oauth application which 212 00:09:24,300 --> 00:09:26,640 could be a website 213 00:09:26,640 --> 00:09:27,240 um 214 00:09:27,240 --> 00:09:30,720 and is requesting and in this case you 215 00:09:30,720 --> 00:09:33,240 see a bunch of email one note Microsoft 216 00:09:33,240 --> 00:09:37,140 type access you see o365 access which is 217 00:09:37,140 --> 00:09:39,899 a string title in the oauth world 218 00:09:39,899 --> 00:09:42,120 whoever creates the application in this 219 00:09:42,120 --> 00:09:44,580 case is an attacker they can pretty much 220 00:09:44,580 --> 00:09:46,800 specify anything although there are some 221 00:09:46,800 --> 00:09:49,380 simple validation rules these days and a 222 00:09:49,380 --> 00:09:52,019 lot of trademark names like Microsoft or 223 00:09:52,019 --> 00:09:54,600 Outlook are not allowed 224 00:09:54,600 --> 00:09:57,540 but the point is this is the user 225 00:09:57,540 --> 00:09:59,279 experience and at this point they can 226 00:09:59,279 --> 00:10:01,860 just hit OK or accept 227 00:10:01,860 --> 00:10:05,279 at this moment should they hit accept 228 00:10:05,279 --> 00:10:09,959 here's where the user is owned 229 00:10:09,959 --> 00:10:12,360 the attacker has created a fake oauth 230 00:10:12,360 --> 00:10:15,120 app and they don't get the username and 231 00:10:15,120 --> 00:10:18,000 password but they do get the oauth 232 00:10:18,000 --> 00:10:22,140 credential the oauth access token 233 00:10:22,140 --> 00:10:24,839 and with that they have full access via 234 00:10:24,839 --> 00:10:27,300 API calls to the resources in question 235 00:10:27,300 --> 00:10:30,300 what was presented in the dialogue so so 236 00:10:30,300 --> 00:10:33,240 let's look at this and sort of recap 237 00:10:33,240 --> 00:10:35,820 what this is about looking at an 238 00:10:35,820 --> 00:10:37,620 architectural diagram so there's a 239 00:10:37,620 --> 00:10:40,019 couple key things to note that are 240 00:10:40,019 --> 00:10:42,420 different from traditional phishing 241 00:10:42,420 --> 00:10:44,279 attacks or credential attacks in this 242 00:10:44,279 --> 00:10:46,440 case the attacker to pull this off and 243 00:10:46,440 --> 00:10:48,899 step one in the top left 244 00:10:48,899 --> 00:10:51,720 is focused on not creating uh fake 245 00:10:51,720 --> 00:10:54,600 websites that gather username and 246 00:10:54,600 --> 00:10:56,519 password they are creating 247 00:10:56,519 --> 00:11:00,000 applications that are oauth uh you know 248 00:11:00,000 --> 00:11:03,839 playing with the oauth protocol 249 00:11:03,839 --> 00:11:07,980 and they're ultimately focused on 250 00:11:07,980 --> 00:11:10,440 obtaining oauth tokens 251 00:11:10,440 --> 00:11:12,420 oauth is designed to keep the username 252 00:11:12,420 --> 00:11:14,399 and password secure because the user 253 00:11:14,399 --> 00:11:16,620 only enters that with the real identity 254 00:11:16,620 --> 00:11:19,320 provider so 255 00:11:19,320 --> 00:11:22,140 the way oauth phishing happens is an 256 00:11:22,140 --> 00:11:24,480 attacker creates a fake oauth app they 257 00:11:24,480 --> 00:11:27,420 fish the user in the sense that they 258 00:11:27,420 --> 00:11:29,459 request certain permissions on the 259 00:11:29,459 --> 00:11:31,860 user's resources so this is a fake both 260 00:11:31,860 --> 00:11:35,180 Office 365 app some fish 261 00:11:35,180 --> 00:11:37,459 presented to the victim 262 00:11:37,459 --> 00:11:42,240 via URL but the URL is a valid URL 263 00:11:42,240 --> 00:11:45,540 pointing to Microsoft identity provider 264 00:11:45,540 --> 00:11:47,579 the user is redirected in their browser 265 00:11:47,579 --> 00:11:50,160 to Microsoft and at this stage you can 266 00:11:50,160 --> 00:11:53,579 imagine it's nearly impossible 267 00:11:53,579 --> 00:11:55,440 to know that this is a phishing attack 268 00:11:55,440 --> 00:11:58,019 at this stage because the victim is just 269 00:11:58,019 --> 00:12:00,240 basically going to a real Microsoft 270 00:12:00,240 --> 00:12:01,920 login 271 00:12:01,920 --> 00:12:04,620 anything on the wire looks pretty normal 272 00:12:04,620 --> 00:12:07,019 there's not much information about the 273 00:12:07,019 --> 00:12:08,760 requesting app there's an ID we'll come 274 00:12:08,760 --> 00:12:10,079 back to that 275 00:12:10,079 --> 00:12:12,180 but in step three once the user 276 00:12:12,180 --> 00:12:14,579 authenticates and then is presented with 277 00:12:14,579 --> 00:12:16,680 that dialog then there's a small 278 00:12:16,680 --> 00:12:19,920 screenshot of what we looked at earlier 279 00:12:19,920 --> 00:12:22,560 um typically attackers asking for extra 280 00:12:22,560 --> 00:12:25,320 permissions here more elevated 281 00:12:25,320 --> 00:12:27,420 permissions if you will than than what 282 00:12:27,420 --> 00:12:30,180 Office 365 might ask but they could also 283 00:12:30,180 --> 00:12:31,260 be narrow 284 00:12:31,260 --> 00:12:33,240 and once the user 285 00:12:33,240 --> 00:12:35,399 it's okay I've simplified the actual 286 00:12:35,399 --> 00:12:37,860 oauth protocol but the point is as soon 287 00:12:37,860 --> 00:12:41,220 as they hit accept uh the Tacker is able 288 00:12:41,220 --> 00:12:45,720 to retrieve or get oauth tokens which 289 00:12:45,720 --> 00:12:46,620 are 290 00:12:46,620 --> 00:12:50,339 um used and and essentially all API 291 00:12:50,339 --> 00:12:53,100 calls uh rest API calls of web apps 292 00:12:53,100 --> 00:12:57,959 today so end goal is a bit different but 293 00:12:57,959 --> 00:12:59,880 what is achieved 294 00:12:59,880 --> 00:13:02,220 in terms of access is essentially the 295 00:13:02,220 --> 00:13:04,800 same because of how apis have been 296 00:13:04,800 --> 00:13:07,560 designed today to use a lot 297 00:13:07,560 --> 00:13:08,760 okay 298 00:13:08,760 --> 00:13:11,160 so defensively 299 00:13:11,160 --> 00:13:12,839 how do we adjust and defend against 300 00:13:12,839 --> 00:13:15,860 these new attacks well URL inspection 301 00:13:15,860 --> 00:13:17,880 doesn't help 302 00:13:17,880 --> 00:13:19,980 because we're really trying to discern 303 00:13:19,980 --> 00:13:22,200 hey what's what's suspicion about 304 00:13:22,200 --> 00:13:25,200 microsoft.com and their oauth endpoint 305 00:13:25,200 --> 00:13:28,620 not not much there's a client ID which 306 00:13:28,620 --> 00:13:30,959 you might think can be looked upon 307 00:13:30,959 --> 00:13:32,399 however there's not much information 308 00:13:32,399 --> 00:13:35,459 about these are randomly generated IDs 309 00:13:35,459 --> 00:13:37,560 assigned to the attacker by Microsoft 310 00:13:37,560 --> 00:13:39,180 when the attacker creates their 311 00:13:39,180 --> 00:13:42,060 application and registers it in an Azure 312 00:13:42,060 --> 00:13:44,000 instance but there's no 313 00:13:44,000 --> 00:13:48,240 metadata really available or threat 314 00:13:48,240 --> 00:13:50,399 Intel so 315 00:13:50,399 --> 00:13:52,380 um you you don't know one ID from the 316 00:13:52,380 --> 00:13:54,660 next what it really means 317 00:13:54,660 --> 00:13:57,600 um who who's behind it what app it is 318 00:13:57,600 --> 00:14:00,540 you might get a a string somewhere an 319 00:14:00,540 --> 00:14:03,420 app name so really 320 00:14:03,420 --> 00:14:07,019 what happens is the attacker typically 321 00:14:07,019 --> 00:14:10,320 can easily gain access if the victim is 322 00:14:10,320 --> 00:14:12,480 fooled into clicking accepting okay now 323 00:14:12,480 --> 00:14:14,700 you might say well does the user have a 324 00:14:14,700 --> 00:14:15,540 chance 325 00:14:15,540 --> 00:14:18,240 and could software filtering be in line 326 00:14:18,240 --> 00:14:21,300 between the user and Microsoft 327 00:14:21,300 --> 00:14:24,540 it could be in line but you're you're 328 00:14:24,540 --> 00:14:29,339 really looking at maybe a a random ID a 329 00:14:29,339 --> 00:14:31,380 list of of permissions 330 00:14:31,380 --> 00:14:35,820 possibly a title in some cases and again 331 00:14:35,820 --> 00:14:39,600 what the user sees is very hard to 332 00:14:39,600 --> 00:14:42,300 detect that it's a malicious app you 333 00:14:42,300 --> 00:14:45,120 might be suspicious because what's 0365 334 00:14:45,120 --> 00:14:47,519 access and you might actually look at 335 00:14:47,519 --> 00:14:49,199 the permissions but we all know 336 00:14:49,199 --> 00:14:51,300 that users don't really look at things 337 00:14:51,300 --> 00:14:53,880 before clicking and if you're automating 338 00:14:53,880 --> 00:14:56,940 it with software filtering well same 339 00:14:56,940 --> 00:14:59,160 issues how do we discern this is 340 00:14:59,160 --> 00:15:02,100 actually a fake app so really if we move 341 00:15:02,100 --> 00:15:03,540 defensively 342 00:15:03,540 --> 00:15:05,760 the first opportunity typically is to 343 00:15:05,760 --> 00:15:07,680 try to mitigate 344 00:15:07,680 --> 00:15:08,279 um 345 00:15:08,279 --> 00:15:10,380 compromise credentials in this case a 346 00:15:10,380 --> 00:15:14,160 lot of tokens so MFA doesn't apply 347 00:15:14,160 --> 00:15:16,199 because this is actually a token system 348 00:15:16,199 --> 00:15:19,500 and one of the common design principles 349 00:15:19,500 --> 00:15:22,019 with with tokens are they are are 350 00:15:22,019 --> 00:15:24,300 typically temporary but but importantly 351 00:15:24,300 --> 00:15:26,160 they're post authentication they are 352 00:15:26,160 --> 00:15:30,060 granted after a valid authentication and 353 00:15:30,060 --> 00:15:33,899 so MFA challenges don't apply the tech 354 00:15:33,899 --> 00:15:36,779 as long as the token is valid and isn't 355 00:15:36,779 --> 00:15:40,199 invalidated or expires it will 356 00:15:40,199 --> 00:15:41,040 um 357 00:15:41,040 --> 00:15:42,779 it will never go through reauthorization 358 00:15:42,779 --> 00:15:45,660 or re-challenge of MFA you can still use 359 00:15:45,660 --> 00:15:48,019 IP address device or other 360 00:15:48,019 --> 00:15:50,160 characteristics to try to figure out if 361 00:15:50,160 --> 00:15:53,399 this is a suspicious user using a valid 362 00:15:53,399 --> 00:15:56,160 oauth token but it's very very hard 363 00:15:56,160 --> 00:15:57,959 so 364 00:15:57,959 --> 00:16:00,300 one of the things to point out is that 365 00:16:00,300 --> 00:16:03,540 the temporary nature of almost all token 366 00:16:03,540 --> 00:16:06,260 systems is often used as a 367 00:16:06,260 --> 00:16:10,380 mitigating control even if the oauth 368 00:16:10,380 --> 00:16:12,079 tokens are are 369 00:16:12,079 --> 00:16:15,120 stolen or obtained by intact or while 370 00:16:15,120 --> 00:16:16,920 they're they're only typically valid for 371 00:16:16,920 --> 00:16:20,160 an hour in most implementations 372 00:16:20,160 --> 00:16:22,620 but here's the dirty secret with oauth 373 00:16:22,620 --> 00:16:25,380 maybe not so secret but 374 00:16:25,380 --> 00:16:27,420 um it's not really temporary in practice 375 00:16:27,420 --> 00:16:29,540 it's essentially permanent 376 00:16:29,540 --> 00:16:32,399 once authentication and authorization 377 00:16:32,399 --> 00:16:34,920 happen the requesting app in this case 378 00:16:34,920 --> 00:16:37,500 the attacker receives a pair the access 379 00:16:37,500 --> 00:16:39,480 token which does expire in an hour but 380 00:16:39,480 --> 00:16:42,660 also a refresh token which they can use 381 00:16:42,660 --> 00:16:47,839 to obtain a new access token every hour 382 00:16:47,839 --> 00:16:50,399 and that refresh token typically does 383 00:16:50,399 --> 00:16:52,019 not expire 384 00:16:52,019 --> 00:16:54,839 except again depending on implementation 385 00:16:54,839 --> 00:16:56,639 but it's usually months and months of 386 00:16:56,639 --> 00:16:59,160 inactivity or unused which an attacker 387 00:16:59,160 --> 00:17:00,839 would never do so they they essentially 388 00:17:00,839 --> 00:17:03,360 gain permanent access and it bypasses 389 00:17:03,360 --> 00:17:08,339 MFA and so the huge risk of attacks that 390 00:17:08,339 --> 00:17:11,220 exploit oauth specifically as a protocol 391 00:17:11,220 --> 00:17:14,520 is you start to have attackers gain a 392 00:17:14,520 --> 00:17:17,520 lot easier access to permanent access 393 00:17:17,520 --> 00:17:20,819 with tokens that have bypassed MFA 394 00:17:20,819 --> 00:17:23,280 essentially with all the same access 395 00:17:23,280 --> 00:17:25,260 because all the rest API calls are set 396 00:17:25,260 --> 00:17:27,299 up to take oauth tokens 397 00:17:27,299 --> 00:17:28,679 so 398 00:17:28,679 --> 00:17:31,260 already we're seeing mitigating controls 399 00:17:31,260 --> 00:17:33,360 sort of fall apart what about the rest 400 00:17:33,360 --> 00:17:36,000 of the secops controls or procedures 401 00:17:36,000 --> 00:17:37,860 that are typically used how effective 402 00:17:37,860 --> 00:17:41,580 are they unfortunately oauth is 403 00:17:41,580 --> 00:17:44,880 almost treated as a completely separate 404 00:17:44,880 --> 00:17:49,200 Beast by most implementing vendors so 405 00:17:49,200 --> 00:17:50,880 the logging is limited it's not as 406 00:17:50,880 --> 00:17:54,320 detailed as normal credential or access 407 00:17:54,320 --> 00:17:58,559 actions by the user so you get a lot 408 00:17:58,559 --> 00:18:00,679 more limited information 409 00:18:00,679 --> 00:18:05,340 on top of that revoking oauth tokens 410 00:18:05,340 --> 00:18:07,620 and you have to revoke the pair the 411 00:18:07,620 --> 00:18:09,780 access token the refresh token 412 00:18:09,780 --> 00:18:12,059 is also challenging it's not 413 00:18:12,059 --> 00:18:14,220 consistently implemented sometimes you 414 00:18:14,220 --> 00:18:16,020 can revoke one sometimes the other 415 00:18:16,020 --> 00:18:18,539 sometimes it's not a clean API it's a 416 00:18:18,539 --> 00:18:24,660 confusing uh console or GUI action so 417 00:18:24,660 --> 00:18:26,460 you have to be really careful on the 418 00:18:26,460 --> 00:18:28,260 defensive side to understand the 419 00:18:28,260 --> 00:18:29,600 implications 420 00:18:29,600 --> 00:18:32,100 and this should all obviously be done 421 00:18:32,100 --> 00:18:33,900 before an actual incident from an 422 00:18:33,900 --> 00:18:35,460 attacker perspective a red team in 423 00:18:35,460 --> 00:18:38,580 perspective it just means that the 424 00:18:38,580 --> 00:18:40,860 chances and probability for for having 425 00:18:40,860 --> 00:18:44,580 continued access or persistence is much 426 00:18:44,580 --> 00:18:46,919 much higher and the chances for 427 00:18:46,919 --> 00:18:48,900 detection are much much lower because no 428 00:18:48,900 --> 00:18:50,760 one's really looking at this 429 00:18:50,760 --> 00:18:55,679 so he's to all of this fake oauth app 430 00:18:55,679 --> 00:18:57,960 the authentication authorization step 431 00:18:57,960 --> 00:19:00,539 will appear valid and bypass you know 432 00:19:00,539 --> 00:19:02,760 URL inspection and then the rest of the 433 00:19:02,760 --> 00:19:04,500 controls Downstream tend to have 434 00:19:04,500 --> 00:19:07,020 challenges 435 00:19:07,020 --> 00:19:09,780 um I did want to point out 436 00:19:09,780 --> 00:19:12,840 at the step three defensively the IP 437 00:19:12,840 --> 00:19:15,780 device trust policies 438 00:19:15,780 --> 00:19:17,820 you do have a chance to mitigate there 439 00:19:17,820 --> 00:19:20,280 and as an example Azure has this 440 00:19:20,280 --> 00:19:23,940 dialogue to do different things such as 441 00:19:23,940 --> 00:19:27,240 control number one who can actually 442 00:19:27,240 --> 00:19:30,780 approve oauth application access so 443 00:19:30,780 --> 00:19:33,740 actually this policy 444 00:19:33,740 --> 00:19:37,200 addresses step three the red three of 445 00:19:37,200 --> 00:19:39,780 the user so that can be controlled so 446 00:19:39,780 --> 00:19:42,840 that users normally cannot do it at all 447 00:19:42,840 --> 00:19:44,940 maybe only administrators or perhaps 448 00:19:44,940 --> 00:19:47,520 only a select set of applications that 449 00:19:47,520 --> 00:19:49,740 have been blessed or white listed by an 450 00:19:49,740 --> 00:19:53,039 administrator so that's pretty common 451 00:19:53,039 --> 00:19:53,700 um 452 00:19:53,700 --> 00:19:56,160 slightly different functionality but 453 00:19:56,160 --> 00:19:58,080 it's worth looking at from a defensive 454 00:19:58,080 --> 00:19:59,880 perspective 455 00:19:59,880 --> 00:20:01,860 Okay so 456 00:20:01,860 --> 00:20:04,440 that starts to get a little bit 457 00:20:04,440 --> 00:20:07,260 you know more more complicated to defend 458 00:20:07,260 --> 00:20:08,820 against 459 00:20:08,820 --> 00:20:10,080 um 460 00:20:10,080 --> 00:20:13,380 let's say you do as a user take 461 00:20:13,380 --> 00:20:15,720 defensive measures to really lock down 462 00:20:15,720 --> 00:20:17,700 who can approval off applications do you 463 00:20:17,700 --> 00:20:19,320 think that would be pretty effective at 464 00:20:19,320 --> 00:20:22,799 removing risk however I want to point 465 00:20:22,799 --> 00:20:24,900 out a different phishing attack that 466 00:20:24,900 --> 00:20:29,640 uses oauth that poses new challenges and 467 00:20:29,640 --> 00:20:33,120 credit for this really the research and 468 00:20:33,120 --> 00:20:36,360 and publication comes from Dr Azure ad 469 00:20:36,360 --> 00:20:40,500 doctor Cinema several years ago you can 470 00:20:40,500 --> 00:20:43,260 see though 365 blog many of you 471 00:20:43,260 --> 00:20:45,960 may be familiar with his work with his 472 00:20:45,960 --> 00:20:48,059 Azure ad tools 473 00:20:48,059 --> 00:20:50,400 um fantastic stuff there and there's 474 00:20:50,400 --> 00:20:52,500 been follow-on research sort of playing 475 00:20:52,500 --> 00:20:55,679 off of that and I want to just go 476 00:20:55,679 --> 00:20:59,039 through quickly a a demonstration that I 477 00:20:59,039 --> 00:21:00,440 pre-recorded 478 00:21:00,440 --> 00:21:03,600 utilizing one of the oauth 479 00:21:03,600 --> 00:21:06,120 protocol flows called device code flow 480 00:21:06,120 --> 00:21:08,280 which just does a quick introduction was 481 00:21:08,280 --> 00:21:12,480 designed to accommodate dumb devices 482 00:21:12,480 --> 00:21:14,880 like smart TVs there there is an 483 00:21:14,880 --> 00:21:17,340 oxymoron for you but limited input 484 00:21:17,340 --> 00:21:19,919 devices like smart TVs where people 485 00:21:19,919 --> 00:21:22,320 don't want to or cannot enter easily 486 00:21:22,320 --> 00:21:23,960 full credentials 487 00:21:23,960 --> 00:21:26,580 oauth came to the rescue and several 488 00:21:26,580 --> 00:21:29,039 years ago extended the protocol set the 489 00:21:29,039 --> 00:21:32,280 framework to allow for easier login 490 00:21:32,280 --> 00:21:36,059 well that particular flow is more 491 00:21:36,059 --> 00:21:37,679 susceptible to certain kinds of abuse 492 00:21:37,679 --> 00:21:39,679 and we'll go through this so right here 493 00:21:39,679 --> 00:21:42,480 as quick pause on the left side in the 494 00:21:42,480 --> 00:21:44,460 browser is the user viewpoint on the 495 00:21:44,460 --> 00:21:46,500 right side will be a terminal window on 496 00:21:46,500 --> 00:21:48,539 what the attacker is doing during a 497 00:21:48,539 --> 00:21:50,700 phishing attack against the user so Ed 498 00:21:50,700 --> 00:21:52,679 at Feast Health 499 00:21:52,679 --> 00:21:53,400 um 500 00:21:53,400 --> 00:21:57,659 on microsoft.com is logging in early in 501 00:21:57,659 --> 00:21:59,419 their workday 502 00:21:59,419 --> 00:22:03,299 they may of course have MFA enabled in 503 00:22:03,299 --> 00:22:06,539 Azure everything's normal this is all to 504 00:22:06,539 --> 00:22:09,000 get at maybe their their mailbox Office 505 00:22:09,000 --> 00:22:12,600 365 Suite so everything is normal so far 506 00:22:12,600 --> 00:22:16,200 on the left meanwhile independently the 507 00:22:16,200 --> 00:22:17,340 attacker 508 00:22:17,340 --> 00:22:19,440 is just running a script they have not 509 00:22:19,440 --> 00:22:21,780 built a fake website or or even a fake 510 00:22:21,780 --> 00:22:24,299 oauth application and 511 00:22:24,299 --> 00:22:26,100 um they're going to start interacting 512 00:22:26,100 --> 00:22:28,860 with azure 513 00:22:28,860 --> 00:22:33,240 um via oauth endpoints and apis using 514 00:22:33,240 --> 00:22:35,880 this device code flow that we have been 515 00:22:35,880 --> 00:22:38,159 alluding to and I want to point out the 516 00:22:38,159 --> 00:22:40,140 first step is 517 00:22:40,140 --> 00:22:41,880 they are able 518 00:22:41,880 --> 00:22:44,460 they Supply a client ID as well as a 519 00:22:44,460 --> 00:22:47,100 Microsoft resource which essentially is 520 00:22:47,100 --> 00:22:49,500 is you know set of apis the graph API 521 00:22:49,500 --> 00:22:50,940 being very common 522 00:22:50,940 --> 00:22:53,220 and they get two codes back a user and 523 00:22:53,220 --> 00:22:55,080 device code and they will use one to 524 00:22:55,080 --> 00:22:57,720 fish the user and so you can see the 525 00:22:57,720 --> 00:23:00,419 response here on the right this is close 526 00:23:00,419 --> 00:23:02,940 enough for you to sort of see the the 527 00:23:02,940 --> 00:23:06,480 payload from an HTTP perspective very 528 00:23:06,480 --> 00:23:08,460 simple they get a user code which is 529 00:23:08,460 --> 00:23:11,400 usually eight and characters or so they 530 00:23:11,400 --> 00:23:13,320 get a longer device code 531 00:23:13,320 --> 00:23:16,380 expires in 15 minutes in this case 900 532 00:23:16,380 --> 00:23:20,159 seconds and a suggested sign 533 00:23:20,159 --> 00:23:22,799 text message to give to the user in this 534 00:23:22,799 --> 00:23:24,780 case the attacker decides to just send 535 00:23:24,780 --> 00:23:27,539 it off in a phishing campaign and so an 536 00:23:27,539 --> 00:23:29,580 email gets sent out which we'll see pop 537 00:23:29,580 --> 00:23:32,539 into the left 538 00:23:32,720 --> 00:23:36,600 box right here at the top of the user 539 00:23:36,600 --> 00:23:39,600 and we will expand that to take a look 540 00:23:39,600 --> 00:23:40,559 at it 541 00:23:40,559 --> 00:23:42,120 in this case 542 00:23:42,120 --> 00:23:45,000 I did a lot of work on this template so 543 00:23:45,000 --> 00:23:46,980 I want to pause here so you can admire 544 00:23:46,980 --> 00:23:51,360 my poor HTML skills this is a fish 545 00:23:51,360 --> 00:23:52,220 um 546 00:23:52,220 --> 00:23:55,760 pretending to be the 365 product team 547 00:23:55,760 --> 00:23:58,500 basically promoting extra storage space 548 00:23:58,500 --> 00:24:00,600 or attachment size space 549 00:24:00,600 --> 00:24:03,419 suggesting a user to receive this extra 550 00:24:03,419 --> 00:24:06,000 sort of freebie for being such a good 551 00:24:06,000 --> 00:24:08,460 customer is to follow this URL and type 552 00:24:08,460 --> 00:24:10,440 in this user code which the attacker 553 00:24:10,440 --> 00:24:13,200 obtained easily for Microsoft by 554 00:24:13,200 --> 00:24:16,380 participating in device code below 555 00:24:16,380 --> 00:24:17,840 and 556 00:24:17,840 --> 00:24:20,100 just so we know there's no funny 557 00:24:20,100 --> 00:24:24,780 business with this URL this doesn't this 558 00:24:24,780 --> 00:24:28,320 actual text uh the title of the href 559 00:24:28,320 --> 00:24:30,419 embedded here is the actual URL there's 560 00:24:30,419 --> 00:24:32,159 there's nothing funny here 561 00:24:32,159 --> 00:24:33,960 um that you know some old South Fishing 562 00:24:33,960 --> 00:24:35,940 attacks will will obfuscate the actual 563 00:24:35,940 --> 00:24:37,980 URL there's nothing here 564 00:24:37,980 --> 00:24:39,720 so if the user 565 00:24:39,720 --> 00:24:42,059 decides to you know copy the code and 566 00:24:42,059 --> 00:24:43,140 then follow 567 00:24:43,140 --> 00:24:45,480 the actual URL 568 00:24:45,480 --> 00:24:48,179 in a 569 00:24:48,179 --> 00:24:51,960 tab we see there's a redirect from that 570 00:24:51,960 --> 00:24:54,360 actual original URL but both the 571 00:24:54,360 --> 00:24:56,700 original as well as the redirect are 572 00:24:56,700 --> 00:24:59,039 actual valid oauth and points of 573 00:24:59,039 --> 00:25:00,840 Microsoft so 574 00:25:00,840 --> 00:25:03,360 imagine you're looking at this as a user 575 00:25:03,360 --> 00:25:05,700 or picking this up as a software filter 576 00:25:05,700 --> 00:25:08,940 so far it is hard to figure out 577 00:25:08,940 --> 00:25:11,280 anything suspicious here 578 00:25:11,280 --> 00:25:13,200 um they're prompted for the code that 579 00:25:13,200 --> 00:25:15,720 was supplied the a character code and so 580 00:25:15,720 --> 00:25:17,940 let's say the user enters that 581 00:25:17,940 --> 00:25:20,580 to get their promotion and now they are 582 00:25:20,580 --> 00:25:24,360 typically prompted to authenticate 583 00:25:24,360 --> 00:25:26,940 um these days it's pretty common for 584 00:25:26,940 --> 00:25:28,799 Microsoft the Google the big providers 585 00:25:28,799 --> 00:25:31,440 things in the browser right so we 586 00:25:31,440 --> 00:25:32,520 probably have all seen this you can 587 00:25:32,520 --> 00:25:34,740 select a cache to log in but if I 588 00:25:34,740 --> 00:25:36,600 weren't logged in for my Outlook session 589 00:25:36,600 --> 00:25:38,700 in the same browser 590 00:25:38,700 --> 00:25:40,440 it would be a full login and could 591 00:25:40,440 --> 00:25:42,840 include MFA so just keep that in mind 592 00:25:42,840 --> 00:25:47,340 code prompt authentication prompt 593 00:25:47,340 --> 00:25:49,440 is what the user sees in this phishing 594 00:25:49,440 --> 00:25:51,360 attack now 595 00:25:51,360 --> 00:25:54,779 they continue on and or pause before we 596 00:25:54,779 --> 00:25:57,600 switch over to the attacker side 597 00:25:57,600 --> 00:25:59,880 happen fast but I want to point out that 598 00:25:59,880 --> 00:26:02,100 as soon as they authenticated which was 599 00:26:02,100 --> 00:26:05,880 picking an existing cash session 600 00:26:05,880 --> 00:26:09,900 they got no further prompts 601 00:26:09,900 --> 00:26:12,419 or approval dialogues 602 00:26:12,419 --> 00:26:15,720 which we saw in the earlier attack the 603 00:26:15,720 --> 00:26:17,880 illicit consent Grant they just got a 604 00:26:17,880 --> 00:26:19,200 confirmation that you're signed into 605 00:26:19,200 --> 00:26:22,260 Microsoft Office and this information is 606 00:26:22,260 --> 00:26:24,240 presented by Microsoft right this is not 607 00:26:24,240 --> 00:26:26,460 actually even affected or presented by 608 00:26:26,460 --> 00:26:30,500 the attacker anyway this is all traffic 609 00:26:30,500 --> 00:26:33,120 directly with Microsoft okay back to 610 00:26:33,120 --> 00:26:35,159 what the attacker does well the attacker 611 00:26:35,159 --> 00:26:38,340 in this oauth flow 612 00:26:38,340 --> 00:26:42,240 is pulling and asking Microsoft has the 613 00:26:42,240 --> 00:26:43,320 user 614 00:26:43,320 --> 00:26:45,900 logged in and if they have 615 00:26:45,900 --> 00:26:48,419 please give me what I need to get their 616 00:26:48,419 --> 00:26:52,500 oauth tokens and so we will see quickly 617 00:26:52,500 --> 00:26:55,740 the actual post request to pull and ask 618 00:26:55,740 --> 00:26:58,020 Microsoft is presented here 619 00:26:58,020 --> 00:27:00,659 okay and 620 00:27:00,659 --> 00:27:03,840 shortly after it returns with a whole 621 00:27:03,840 --> 00:27:05,059 bunch of information 622 00:27:05,059 --> 00:27:07,620 it actually returns with the access 623 00:27:07,620 --> 00:27:10,740 token here this very long 624 00:27:10,740 --> 00:27:11,539 um 625 00:27:11,539 --> 00:27:15,600 hexadecimal string or more and 626 00:27:15,600 --> 00:27:17,400 Scopes which are the permissions 627 00:27:17,400 --> 00:27:19,860 associated with this access token 628 00:27:19,860 --> 00:27:21,779 the resource which was requested 629 00:27:21,779 --> 00:27:24,419 originally which is graph API access 630 00:27:24,419 --> 00:27:27,360 so think about that the user 631 00:27:27,360 --> 00:27:28,620 authenticated 632 00:27:28,620 --> 00:27:31,500 add put in a code attacker immediately 633 00:27:31,500 --> 00:27:33,779 gets credentials 634 00:27:33,779 --> 00:27:37,620 and they can do this from anywhere with 635 00:27:37,620 --> 00:27:39,840 a simple little script doing not much 636 00:27:39,840 --> 00:27:43,260 more than some curl calls 637 00:27:43,260 --> 00:27:46,559 okay let's let this go through a little 638 00:27:46,559 --> 00:27:48,960 bit further and actually see what we can 639 00:27:48,960 --> 00:27:52,380 obtain or access with this so the 640 00:27:52,380 --> 00:27:55,020 attacker can continue on 641 00:27:55,020 --> 00:27:56,940 and 642 00:27:56,940 --> 00:27:58,799 one of the calls you see at the bottom 643 00:27:58,799 --> 00:28:02,100 we'll get that uh 644 00:28:02,100 --> 00:28:06,120 bar on the way the token can be used to 645 00:28:06,120 --> 00:28:07,980 enumerate ad users that's what you can 646 00:28:07,980 --> 00:28:09,480 do with among other things with the 647 00:28:09,480 --> 00:28:12,659 graph API and so this little attacker 648 00:28:12,659 --> 00:28:13,679 script 649 00:28:13,679 --> 00:28:15,480 uh the only thing I'm doing is having 650 00:28:15,480 --> 00:28:18,419 the user log into ad just so we can look 651 00:28:18,419 --> 00:28:22,080 side by side to validate hey three users 652 00:28:22,080 --> 00:28:24,480 were pulled by the attacker with the 653 00:28:24,480 --> 00:28:27,120 oauth token and 654 00:28:27,120 --> 00:28:28,200 um 655 00:28:28,200 --> 00:28:31,500 there they are David Ed and Sandra and 656 00:28:31,500 --> 00:28:33,900 you know back back in ad if we go to 657 00:28:33,900 --> 00:28:36,600 users we see you know three users in 658 00:28:36,600 --> 00:28:39,480 this actual ad instance 659 00:28:39,480 --> 00:28:40,559 um 660 00:28:40,559 --> 00:28:42,659 now there's a second call again at the 661 00:28:42,659 --> 00:28:44,880 bottom a little bit obscured 662 00:28:44,880 --> 00:28:45,720 um 663 00:28:45,720 --> 00:28:48,539 but certainly email and other Office 365 664 00:28:48,539 --> 00:28:51,299 information can be obtained that's also 665 00:28:51,299 --> 00:28:54,179 supported and you know a printout of 666 00:28:54,179 --> 00:28:55,919 some of the Header information shows 667 00:28:55,919 --> 00:28:58,679 three email messages and right if we go 668 00:28:58,679 --> 00:29:00,960 back to Outlook or if you recall 669 00:29:00,960 --> 00:29:02,820 there are three messages in fact the 670 00:29:02,820 --> 00:29:04,260 most recent one is the phishing email 671 00:29:04,260 --> 00:29:10,080 right okay so access to what the user uh 672 00:29:10,080 --> 00:29:12,299 can have access to in within their own 673 00:29:12,299 --> 00:29:15,840 Outlook 365. it is certainly available 674 00:29:15,840 --> 00:29:19,080 to that hacker now here's where it 675 00:29:19,080 --> 00:29:22,320 becomes really interesting okay so far 676 00:29:22,320 --> 00:29:25,620 we've shown a phishing attack with 677 00:29:25,620 --> 00:29:27,539 um Outlook we've shown a device code 678 00:29:27,539 --> 00:29:30,059 flow which just lends itself to phishing 679 00:29:30,059 --> 00:29:31,679 because of you know these short codes 680 00:29:31,679 --> 00:29:34,020 that get presented to users the 681 00:29:34,020 --> 00:29:35,640 attackers in control they initiate 682 00:29:35,640 --> 00:29:37,799 things they get they get codes they can 683 00:29:37,799 --> 00:29:40,279 send them off 684 00:29:40,440 --> 00:29:41,580 um 685 00:29:41,580 --> 00:29:45,000 but this access token which was actually 686 00:29:45,000 --> 00:29:46,919 requested 687 00:29:46,919 --> 00:29:49,799 by the attacker and what I I didn't 688 00:29:49,799 --> 00:29:53,220 dwell on is an ID was an application ID 689 00:29:53,220 --> 00:29:56,220 was passed in in the very beginning in 690 00:29:56,220 --> 00:29:58,080 step one of what the attacker did and 691 00:29:58,080 --> 00:30:01,200 and the ID was nothing associated with 692 00:30:01,200 --> 00:30:03,539 an attacker fake app 693 00:30:03,539 --> 00:30:05,520 it was actually 694 00:30:05,520 --> 00:30:10,820 the Outlook 365 application ID 695 00:30:11,059 --> 00:30:14,760 so jumping ahead two steps anything that 696 00:30:14,760 --> 00:30:16,740 gets logged is going to look like 697 00:30:16,740 --> 00:30:21,240 user Ed doing office 365. but where this 698 00:30:21,240 --> 00:30:23,279 becomes interesting is the attacker's 699 00:30:23,279 --> 00:30:25,020 now going to Pivot move laterally and 700 00:30:25,020 --> 00:30:27,299 access all of azure at least what Ed can 701 00:30:27,299 --> 00:30:29,580 access in Azure and 702 00:30:29,580 --> 00:30:32,640 The Next Step they do is use the refresh 703 00:30:32,640 --> 00:30:34,679 token they received 704 00:30:34,679 --> 00:30:37,679 to get a completely new access token 705 00:30:37,679 --> 00:30:40,559 with a different resource or set of apis 706 00:30:40,559 --> 00:30:44,700 now it's Azure not graph API or Outlook 707 00:30:44,700 --> 00:30:46,679 365. 708 00:30:46,679 --> 00:30:48,360 so now 709 00:30:48,360 --> 00:30:51,539 and it so happens that Ed is a global 710 00:30:51,539 --> 00:30:54,480 admin in Azure now the attacker has a 711 00:30:54,480 --> 00:30:56,039 different access token 712 00:30:56,039 --> 00:30:58,200 and they did this all without requiring 713 00:30:58,200 --> 00:31:01,460 any special secrets 714 00:31:01,460 --> 00:31:05,700 data essentially exchanged um 715 00:31:05,700 --> 00:31:08,460 and gotten a new access token with 716 00:31:08,460 --> 00:31:11,240 different privileges this is the pivot 717 00:31:11,240 --> 00:31:13,980 and we can see that in the payload and 718 00:31:13,980 --> 00:31:15,059 response 719 00:31:15,059 --> 00:31:16,679 and 720 00:31:16,679 --> 00:31:19,860 now the attacker I'll let it run 721 00:31:19,860 --> 00:31:22,679 you can access Azure data and what what 722 00:31:22,679 --> 00:31:24,659 this call does 723 00:31:24,659 --> 00:31:27,419 um just enumerates Azure resources so 724 00:31:27,419 --> 00:31:29,039 you can see a subscription Azure 725 00:31:29,039 --> 00:31:31,500 subscription one back in the users view 726 00:31:31,500 --> 00:31:35,039 in their Azure tab on the subscription 727 00:31:35,039 --> 00:31:38,340 excuse me is azure subscription one 728 00:31:38,340 --> 00:31:42,320 there are buckets storage containers 729 00:31:43,100 --> 00:31:45,360 storage accounts 730 00:31:45,360 --> 00:31:48,960 and actual objects on those there's also 731 00:31:48,960 --> 00:31:51,480 various keys and and compute instances 732 00:31:51,480 --> 00:31:54,320 right all of this 733 00:31:54,320 --> 00:31:57,899 shows that we now have full user access 734 00:31:57,899 --> 00:32:00,480 to Ebbs Azure now I'm going to pause 735 00:32:00,480 --> 00:32:03,000 this in interest of time move it forward 736 00:32:03,000 --> 00:32:07,020 to let's look at how this happens 737 00:32:07,020 --> 00:32:09,600 it's different now than the illicit 738 00:32:09,600 --> 00:32:11,700 consent Grant one the attacker has less 739 00:32:11,700 --> 00:32:14,520 work to do and leaves less tracks They 740 00:32:14,520 --> 00:32:16,620 Don't create fake anything no fake 741 00:32:16,620 --> 00:32:18,440 application code 742 00:32:18,440 --> 00:32:20,700 in this case they 743 00:32:20,700 --> 00:32:23,279 they assume an existing application 744 00:32:23,279 --> 00:32:26,220 identity just by using a well-known 745 00:32:26,220 --> 00:32:30,600 public ID of office 365. 746 00:32:30,600 --> 00:32:34,679 the user in this device code flow isn't 747 00:32:34,679 --> 00:32:36,600 presented even with an authorization 748 00:32:36,600 --> 00:32:38,520 dialog 749 00:32:38,520 --> 00:32:40,320 that probably wouldn't have prevented 750 00:32:40,320 --> 00:32:41,299 the attack 751 00:32:41,299 --> 00:32:43,919 but just notice that the user is 752 00:32:43,919 --> 00:32:46,440 presented with less information 753 00:32:46,440 --> 00:32:48,419 so the attacker immediately gets and 754 00:32:48,419 --> 00:32:51,539 acts gets access with an oauth token in 755 00:32:51,539 --> 00:32:53,539 terms of our mitigating 756 00:32:53,539 --> 00:32:56,940 controls well same thing applies but 757 00:32:56,940 --> 00:32:59,159 it's worse I mean MFA doesn't apply 758 00:32:59,159 --> 00:33:02,100 device policies might help but it's 759 00:33:02,100 --> 00:33:03,799 worse in that 760 00:33:03,799 --> 00:33:06,899 lateral movement is very very easy and 761 00:33:06,899 --> 00:33:08,820 Microsoft's device code implementation 762 00:33:08,820 --> 00:33:10,200 why 763 00:33:10,200 --> 00:33:12,799 it's because and there's great research 764 00:33:12,799 --> 00:33:15,360 done by the scareworks team so I'm going 765 00:33:15,360 --> 00:33:18,360 to call out Ryan Cobb and Tony Gore 766 00:33:18,360 --> 00:33:20,940 who early 767 00:33:20,940 --> 00:33:24,840 in 2022 did some research 768 00:33:24,840 --> 00:33:27,480 and some back and forth with Microsoft 769 00:33:27,480 --> 00:33:28,980 and 770 00:33:28,980 --> 00:33:32,640 there's a family of Microsoft apps and 771 00:33:32,640 --> 00:33:35,519 it is started with 15 but with further 772 00:33:35,519 --> 00:33:37,820 research it's in the 30s 773 00:33:37,820 --> 00:33:40,980 where Microsoft wanted to provide SSO 774 00:33:40,980 --> 00:33:42,240 capabilities 775 00:33:42,240 --> 00:33:46,559 and so it allowed effectively this 776 00:33:46,559 --> 00:33:49,140 switching of tokens or refreshing and 777 00:33:49,140 --> 00:33:50,760 getting a different access token with 778 00:33:50,760 --> 00:33:52,380 different permissions 779 00:33:52,380 --> 00:33:54,539 to be very easy 780 00:33:54,539 --> 00:33:56,760 among their apps 781 00:33:56,760 --> 00:33:58,740 so that's exactly what we did Azure is 782 00:33:58,740 --> 00:34:01,440 part of that family Office 365 still on 783 00:34:01,440 --> 00:34:04,380 can take a look at the GitHub and sort 784 00:34:04,380 --> 00:34:05,940 of see the latest 785 00:34:05,940 --> 00:34:10,980 and I want to point out that when oauth 786 00:34:10,980 --> 00:34:14,280 of any kind is used in SSO there's a 787 00:34:14,280 --> 00:34:16,918 danger here of getting these ah makes 788 00:34:16,918 --> 00:34:18,659 sense for SSO 789 00:34:18,659 --> 00:34:22,320 ah gives us a few surprise magical 790 00:34:22,320 --> 00:34:26,460 things uh because of oauth and and what 791 00:34:26,460 --> 00:34:29,699 it brings with this sort of kitchen sink 792 00:34:29,699 --> 00:34:32,760 complicated protocol framework 793 00:34:32,760 --> 00:34:34,080 okay 794 00:34:34,080 --> 00:34:37,199 so essentially the the attacker has all 795 00:34:37,199 --> 00:34:39,659 the advantages of the previous attack 796 00:34:39,659 --> 00:34:41,699 but has an additional at least with 797 00:34:41,699 --> 00:34:43,980 Microsoft's device code flow an ability 798 00:34:43,980 --> 00:34:45,359 to move laterally and just remember 799 00:34:45,359 --> 00:34:48,260 device code flow was originally 800 00:34:48,260 --> 00:34:49,820 uh 801 00:34:49,820 --> 00:34:52,879 created for dumb 802 00:34:52,879 --> 00:34:55,619 devices call them Smart TVs they're 803 00:34:55,619 --> 00:34:57,920 still dumb devices with limited input 804 00:34:57,920 --> 00:35:00,839 even though 805 00:35:00,839 --> 00:35:03,359 many other apps including Office 365 806 00:35:03,359 --> 00:35:06,119 support it why it's a great question to 807 00:35:06,119 --> 00:35:08,040 ask 808 00:35:08,040 --> 00:35:09,300 okay 809 00:35:09,300 --> 00:35:11,820 let's continue on 810 00:35:11,820 --> 00:35:14,220 let's talk about defensively 811 00:35:14,220 --> 00:35:16,200 what can we do here 812 00:35:16,200 --> 00:35:17,579 well 813 00:35:17,579 --> 00:35:20,060 when the user sorry when the user 814 00:35:20,060 --> 00:35:22,020 authenticates but it wasn't presented 815 00:35:22,020 --> 00:35:23,700 with an authorization well you have no 816 00:35:23,700 --> 00:35:25,200 control over that you can't change it 817 00:35:25,200 --> 00:35:27,660 it's way Microsoft implemented it but 818 00:35:27,660 --> 00:35:30,540 how about we go back to the attacker and 819 00:35:30,540 --> 00:35:33,000 how can we detect things can can we in 820 00:35:33,000 --> 00:35:35,280 any way prevent or detect assumed app 821 00:35:35,280 --> 00:35:38,579 identities no 822 00:35:38,579 --> 00:35:40,140 um there are no secrets involved even if 823 00:35:40,140 --> 00:35:42,300 there were Secrets um they're often easy 824 00:35:42,300 --> 00:35:44,040 to obtain 825 00:35:44,040 --> 00:35:46,140 um but in this case the attacker just 826 00:35:46,140 --> 00:35:48,900 needed a well-known public ID there's 827 00:35:48,900 --> 00:35:50,220 really nothing to prevent the attack 828 00:35:50,220 --> 00:35:52,619 from initiating this attack how about 829 00:35:52,619 --> 00:35:54,839 the pivot is there anything to you know 830 00:35:54,839 --> 00:35:58,020 prevent turn that off well nope that is 831 00:35:58,020 --> 00:36:00,119 a custom Implement implementation for 832 00:36:00,119 --> 00:36:03,240 SSO purposes utilizing oauth device code 833 00:36:03,240 --> 00:36:04,680 flow 834 00:36:04,680 --> 00:36:05,400 um 835 00:36:05,400 --> 00:36:07,320 and think about it from an SSO 836 00:36:07,320 --> 00:36:09,060 perspective it makes perfect sense I 837 00:36:09,060 --> 00:36:10,800 mean if you have a valid credential to 838 00:36:10,800 --> 00:36:14,339 access Office 365 and SSO is enabled why 839 00:36:14,339 --> 00:36:18,300 could you just pivot and and go to Azure 840 00:36:18,300 --> 00:36:21,660 or exchange or or 841 00:36:21,660 --> 00:36:25,680 uh Microsoft Office or Excel no reason 842 00:36:25,680 --> 00:36:27,480 Google does the same thing in fact 843 00:36:27,480 --> 00:36:30,839 Google doesn't use device code flow but 844 00:36:30,839 --> 00:36:33,540 they do support SSO the point is from an 845 00:36:33,540 --> 00:36:37,619 SSO perspective it doesn't seem strange 846 00:36:37,619 --> 00:36:39,960 that that's the way things behave 847 00:36:39,960 --> 00:36:44,280 from an but from an oauth perspective 848 00:36:44,280 --> 00:36:46,800 it's an area for abuse because once you 849 00:36:46,800 --> 00:36:51,119 have access and this is a third party 850 00:36:51,119 --> 00:36:53,579 app or rather an attacker 851 00:36:53,579 --> 00:36:56,040 playing the role of a third party app 852 00:36:56,040 --> 00:36:59,280 that is office 365. 853 00:36:59,280 --> 00:37:03,660 they now have access to everything that 854 00:37:03,660 --> 00:37:05,700 the user has access all 30 plus 855 00:37:05,700 --> 00:37:08,760 applications okay so 856 00:37:08,760 --> 00:37:09,359 um 857 00:37:09,359 --> 00:37:11,099 you can't prevent that 858 00:37:11,099 --> 00:37:13,619 and the same issues with Downstream 859 00:37:13,619 --> 00:37:14,960 security Ops 860 00:37:14,960 --> 00:37:17,780 still applies in that 861 00:37:17,780 --> 00:37:19,859 logging's limited revoking is a 862 00:37:19,859 --> 00:37:22,260 challenge and um essentially the user 863 00:37:22,260 --> 00:37:24,119 has permanent access 864 00:37:24,119 --> 00:37:26,820 so there's one thing 865 00:37:26,820 --> 00:37:29,040 that is worth doing and 866 00:37:29,040 --> 00:37:29,760 um 867 00:37:29,760 --> 00:37:31,920 can apply which is some kind of access 868 00:37:31,920 --> 00:37:35,640 policy to check API calls and 869 00:37:35,640 --> 00:37:37,440 characteristics about the user like 870 00:37:37,440 --> 00:37:40,320 their location IP address or uh device 871 00:37:40,320 --> 00:37:43,079 characteristics so 872 00:37:43,079 --> 00:37:43,980 um 873 00:37:43,980 --> 00:37:48,000 I want to say that you should do it but 874 00:37:48,000 --> 00:37:50,520 there's a fair amount of caveats in the 875 00:37:50,520 --> 00:37:52,560 implementation so it does not solve 876 00:37:52,560 --> 00:37:56,220 everything so here are some useful links 877 00:37:56,220 --> 00:37:59,579 uh and there has been good work by Dr 878 00:37:59,579 --> 00:38:03,540 Azure ad as well as Boku on 879 00:38:03,540 --> 00:38:06,060 the limitations of con conditional 880 00:38:06,060 --> 00:38:07,920 access policies and I would just want to 881 00:38:07,920 --> 00:38:09,359 summarize that 882 00:38:09,359 --> 00:38:11,099 going into all the details is beyond 883 00:38:11,099 --> 00:38:14,460 this presentation but as an example 884 00:38:14,460 --> 00:38:16,460 IP address 885 00:38:16,460 --> 00:38:19,260 generally can work to the extent that 886 00:38:19,260 --> 00:38:21,420 you can detect suspicious IP addresses 887 00:38:21,420 --> 00:38:23,780 or or you know whitelist 888 00:38:23,780 --> 00:38:26,160 allowed IP addresses the other things 889 00:38:26,160 --> 00:38:28,140 you can do 890 00:38:28,140 --> 00:38:31,560 such as use InTune to see whether 891 00:38:31,560 --> 00:38:33,240 um you know something's compliant or not 892 00:38:33,240 --> 00:38:35,400 or whether the device the user is using 893 00:38:35,400 --> 00:38:38,720 is joint a d device characters Etc 894 00:38:38,720 --> 00:38:41,339 there's more functionality 895 00:38:41,339 --> 00:38:42,960 and to different extents they can be 896 00:38:42,960 --> 00:38:46,560 faked or bypassed or spoofed so 897 00:38:46,560 --> 00:38:49,500 I'm not saying you shouldn't use it I'm 898 00:38:49,500 --> 00:38:51,780 saying some of it works some of it's 899 00:38:51,780 --> 00:38:54,540 still susceptible to abuse so at best 900 00:38:54,540 --> 00:38:58,619 it's a layer that is a little porous 901 00:38:58,619 --> 00:39:01,320 but but a little help is better than 902 00:39:01,320 --> 00:39:03,180 none so I suggest 903 00:39:03,180 --> 00:39:05,400 you look at it no matter what oauth 904 00:39:05,400 --> 00:39:09,560 implementation you're you're looking at 905 00:39:09,599 --> 00:39:11,820 what else can be done let's let's drill 906 00:39:11,820 --> 00:39:14,579 in and not leave everything you know to 907 00:39:14,579 --> 00:39:18,240 be you know without uh you know means of 908 00:39:18,240 --> 00:39:20,400 Defending uh let's talk a little bit 909 00:39:20,400 --> 00:39:23,700 more well behavioral detection 910 00:39:23,700 --> 00:39:25,560 is really the answer with most 911 00:39:25,560 --> 00:39:29,880 compromised credential attacks so okay 912 00:39:29,880 --> 00:39:32,880 the problem is we've been looking at 913 00:39:32,880 --> 00:39:34,800 that for for many many years and it's 914 00:39:34,800 --> 00:39:37,079 been very very difficult 915 00:39:37,079 --> 00:39:39,140 um what's most popular today is taking 916 00:39:39,140 --> 00:39:41,700 ml models of different sorts and trying 917 00:39:41,700 --> 00:39:43,200 to discern whether we have good 918 00:39:43,200 --> 00:39:45,740 indicators or features to detect 919 00:39:45,740 --> 00:39:48,260 suspicious activity 920 00:39:48,260 --> 00:39:52,380 within narrow use cases or very specific 921 00:39:52,380 --> 00:39:54,839 ones this can be very effective it is 922 00:39:54,839 --> 00:39:58,280 hard to to you know have General uh 923 00:39:58,280 --> 00:40:02,000 one size fits all 924 00:40:02,060 --> 00:40:05,280 obviously not many Defenders are in the 925 00:40:05,280 --> 00:40:07,140 position to build their own or want to 926 00:40:07,140 --> 00:40:09,599 or think that's even a good idea but 927 00:40:09,599 --> 00:40:10,980 this certainly becomes a discussion 928 00:40:10,980 --> 00:40:14,400 point with vendors supplying detection 929 00:40:14,400 --> 00:40:18,599 um uh Solutions of any kind 930 00:40:18,599 --> 00:40:20,880 um is what's in there and even the 931 00:40:20,880 --> 00:40:22,920 vendors who are 932 00:40:22,920 --> 00:40:25,700 owning the identity side like Microsoft 933 00:40:25,700 --> 00:40:29,040 have introduced various behavioral 934 00:40:29,040 --> 00:40:31,800 oriented or ml-based detections so 935 00:40:31,800 --> 00:40:34,320 that's all good news it's just doesn't 936 00:40:34,320 --> 00:40:37,320 solve everything not a silver bullet so 937 00:40:37,320 --> 00:40:39,180 as an example if you do look in 938 00:40:39,180 --> 00:40:40,320 Microsoft 939 00:40:40,320 --> 00:40:41,220 um 940 00:40:41,220 --> 00:40:45,240 Cloud Defender you will see certain use 941 00:40:45,240 --> 00:40:47,339 cases around oauth 942 00:40:47,339 --> 00:40:50,460 um and anomalyten it is uh documented as 943 00:40:50,460 --> 00:40:52,500 being an ml approach 944 00:40:52,500 --> 00:40:55,800 um it's hard to trigger these but 945 00:40:55,800 --> 00:40:59,099 nonetheless it is a good start in that 946 00:40:59,099 --> 00:41:02,520 there is an appreciation that behavioral 947 00:41:02,520 --> 00:41:03,380 detection 948 00:41:03,380 --> 00:41:06,079 is definitely part of the solution 949 00:41:06,079 --> 00:41:08,339 on the other hand it doesn't detect the 950 00:41:08,339 --> 00:41:10,320 Microsoft device code fish because 951 00:41:10,320 --> 00:41:13,380 that's just very hard to detect period 952 00:41:13,380 --> 00:41:16,440 it looks like real user Behavior 953 00:41:16,440 --> 00:41:17,880 so 954 00:41:17,880 --> 00:41:19,859 there's a point where it's like a bad 955 00:41:19,859 --> 00:41:21,960 relationship breakup right maybe we're 956 00:41:21,960 --> 00:41:24,240 thinking it's not me it's you and you I 957 00:41:24,240 --> 00:41:26,220 don't really mean all of you listeners 958 00:41:26,220 --> 00:41:28,859 maybe it's the vendors that we're using 959 00:41:28,859 --> 00:41:30,960 the technology stack so maybe switching 960 00:41:30,960 --> 00:41:33,960 them uh avoid some of these problems and 961 00:41:33,960 --> 00:41:36,420 so it's worth saying not that it's easy 962 00:41:36,420 --> 00:41:38,700 to switch from Microsoft to Google I'm 963 00:41:38,700 --> 00:41:40,200 not even suggesting that but let's 964 00:41:40,200 --> 00:41:42,839 analyze let's let's look at Google's 965 00:41:42,839 --> 00:41:44,640 device code flow right is this a 966 00:41:44,640 --> 00:41:48,240 protocol problem that's inherited across 967 00:41:48,240 --> 00:41:50,099 vendors or is it an implementation 968 00:41:50,099 --> 00:41:52,200 problem that perhaps doesn't appear in 969 00:41:52,200 --> 00:41:55,380 other vendors that's worth asking so 970 00:41:55,380 --> 00:41:58,020 August over a year ago 971 00:41:58,020 --> 00:41:59,640 um in 2021 972 00:41:59,640 --> 00:42:00,420 um 973 00:42:00,420 --> 00:42:03,540 I did some research and showed that uh 974 00:42:03,540 --> 00:42:05,760 around Google device code flow as well 975 00:42:05,760 --> 00:42:07,320 as other flows and let's take a look at 976 00:42:07,320 --> 00:42:09,540 that so when you actually go through 977 00:42:09,540 --> 00:42:12,140 Google device code flow the attacker 978 00:42:12,140 --> 00:42:14,760 similarly and I'm showing less of the 979 00:42:14,760 --> 00:42:16,020 screenshots more of the underlying 980 00:42:16,020 --> 00:42:17,820 protocols so we can jump into the 981 00:42:17,820 --> 00:42:19,260 details 982 00:42:19,260 --> 00:42:21,960 um it's it's a different implementation 983 00:42:21,960 --> 00:42:24,240 uh Microsoft implementation is 984 00:42:24,240 --> 00:42:27,119 non-standard to say the least according 985 00:42:27,119 --> 00:42:29,400 to the spec even though the oau spec 986 00:42:29,400 --> 00:42:31,320 leaves room for interpretation and 987 00:42:31,320 --> 00:42:33,300 optional arguments one of the things 988 00:42:33,300 --> 00:42:34,760 with Microsoft 989 00:42:34,760 --> 00:42:38,339 device code implementation is 990 00:42:38,339 --> 00:42:42,180 the user the application or the attacker 991 00:42:42,180 --> 00:42:44,640 in the phishing attack does not have to 992 00:42:44,640 --> 00:42:47,640 present or ask for Scopes up front in 993 00:42:47,640 --> 00:42:49,320 Microsoft's implementation they ask for 994 00:42:49,320 --> 00:42:51,420 resources which are 995 00:42:51,420 --> 00:42:53,220 sets of apis 996 00:42:53,220 --> 00:42:56,040 the Google stuck closer to spec and so 997 00:42:56,040 --> 00:42:58,619 the attacker or the app would request 998 00:42:58,619 --> 00:43:02,339 Scopes and Google does some upfront 999 00:43:02,339 --> 00:43:04,800 validation there's very limited Scopes 1000 00:43:04,800 --> 00:43:07,200 that can actually be asked for or 1001 00:43:07,200 --> 00:43:09,119 requested otherwise you're rejected so 1002 00:43:09,119 --> 00:43:10,500 profile information like the email 1003 00:43:10,500 --> 00:43:13,980 address is valid but I can't go asking 1004 00:43:13,980 --> 00:43:16,560 for Google Cloud access it'll get 1005 00:43:16,560 --> 00:43:20,160 rejected up front so just to point out 1006 00:43:20,160 --> 00:43:23,339 there are some differences but you can 1007 00:43:23,339 --> 00:43:25,500 participate in the Google implementation 1008 00:43:25,500 --> 00:43:27,780 and get very similar device code user 1009 00:43:27,780 --> 00:43:30,540 code 1800 seconds you know 30 minute 1010 00:43:30,540 --> 00:43:31,980 expiration 1011 00:43:31,980 --> 00:43:35,640 and the Google endpoint for this oauth 1012 00:43:35,640 --> 00:43:37,859 and you can't fish the user not showing 1013 00:43:37,859 --> 00:43:39,780 that but if the user followed the fish 1014 00:43:39,780 --> 00:43:41,640 or whatever it is they're prompted for 1015 00:43:41,640 --> 00:43:43,619 code that's very similar very standard 1016 00:43:43,619 --> 00:43:46,200 they are prompted to authenticate cash 1017 00:43:46,200 --> 00:43:48,780 credentials very standard or if I 1018 00:43:48,780 --> 00:43:51,839 weren't actually uh already logged in 1019 00:43:51,839 --> 00:43:55,440 I'd have a full login including MFA 1020 00:43:55,440 --> 00:43:56,400 um 1021 00:43:56,400 --> 00:44:00,359 and then yes a very quick sort of 1022 00:44:00,359 --> 00:44:05,000 success no approval same thing 1023 00:44:05,000 --> 00:44:07,319 there are some cases where where 1024 00:44:07,319 --> 00:44:10,859 approval dialogues are presented but 1025 00:44:10,859 --> 00:44:14,339 um many that that it's as simple on the 1026 00:44:14,339 --> 00:44:16,800 user as the Microsoft implementation 1027 00:44:16,800 --> 00:44:19,319 the attacker can separately be pulling 1028 00:44:19,319 --> 00:44:21,660 once the user authenticates they get 1029 00:44:21,660 --> 00:44:23,940 tokens they have access 1030 00:44:23,940 --> 00:44:27,060 but and they can use those that token 1031 00:44:27,060 --> 00:44:29,940 immediately in API calls but where 1032 00:44:29,940 --> 00:44:32,640 Google simplification differs is because 1033 00:44:32,640 --> 00:44:35,900 the Scopes are very limited up front 1034 00:44:35,900 --> 00:44:39,180 the damage that the attacker can do is 1035 00:44:39,180 --> 00:44:41,400 very limited they are in fact sort of 1036 00:44:41,400 --> 00:44:42,900 sandbox with very restrictive 1037 00:44:42,900 --> 00:44:44,700 permissions versus Microsoft's 1038 00:44:44,700 --> 00:44:47,160 implementation which probably because of 1039 00:44:47,160 --> 00:44:50,579 SSO requirements or reasons has a wide 1040 00:44:50,579 --> 00:44:53,040 ranging set of Scopes that are not 1041 00:44:53,040 --> 00:44:56,700 validated or restricted so in this case 1042 00:44:56,700 --> 00:44:58,440 the attacker might get the user's 1043 00:44:58,440 --> 00:45:00,020 information which is profile information 1044 00:45:00,020 --> 00:45:03,720 picture email there's some data leakage 1045 00:45:03,720 --> 00:45:06,660 and risk but but not major access issues 1046 00:45:06,660 --> 00:45:08,339 right off the bat 1047 00:45:08,339 --> 00:45:10,440 so defending 1048 00:45:10,440 --> 00:45:12,240 um 1049 00:45:12,240 --> 00:45:14,339 I want to point out there was some 1050 00:45:14,339 --> 00:45:17,099 disclosure done with with Google over a 1051 00:45:17,099 --> 00:45:20,420 year ago at Defcon 29 1052 00:45:20,420 --> 00:45:25,319 and since then early in 2022 1053 00:45:25,319 --> 00:45:27,420 around February 1054 00:45:27,420 --> 00:45:28,380 um 1055 00:45:28,380 --> 00:45:30,839 there was further validation done by 1056 00:45:30,839 --> 00:45:34,380 Google not just on Scopes requested but 1057 00:45:34,380 --> 00:45:37,560 in fact on the application and against 1058 00:45:37,560 --> 00:45:40,440 the device code flow what do I mean by 1059 00:45:40,440 --> 00:45:43,380 that if you try to assume the identity 1060 00:45:43,380 --> 00:45:46,160 of an existing application like Google 1061 00:45:46,160 --> 00:45:48,420 CLI which normally doesn't do device 1062 00:45:48,420 --> 00:45:50,520 code flow and you try to start a device 1063 00:45:50,520 --> 00:45:54,960 code flow as a attacker you would get an 1064 00:45:54,960 --> 00:45:56,760 error message which you can see hey only 1065 00:45:56,760 --> 00:45:59,520 clients of type this and that can use 1066 00:45:59,520 --> 00:46:00,660 this flow 1067 00:46:00,660 --> 00:46:04,740 and if you step eight steps back when 1068 00:46:04,740 --> 00:46:06,599 you create an oauth application and 1069 00:46:06,599 --> 00:46:08,280 register with the identity provider 1070 00:46:08,280 --> 00:46:10,380 Google or Microsoft you typically have 1071 00:46:10,380 --> 00:46:13,099 to pre-disclose or 1072 00:46:13,099 --> 00:46:15,660 disclose up front what Scopes you 1073 00:46:15,660 --> 00:46:18,119 support what permissions you will ever 1074 00:46:18,119 --> 00:46:21,960 ask for the superset as well as how to 1075 00:46:21,960 --> 00:46:25,140 contact the app you know to give tokens 1076 00:46:25,140 --> 00:46:27,540 or codes to get tokens you know you 1077 00:46:27,540 --> 00:46:29,520 supply a URL 1078 00:46:29,520 --> 00:46:31,500 and you have to identify what flow you 1079 00:46:31,500 --> 00:46:33,800 want to support so 1080 00:46:33,800 --> 00:46:36,599 developer the Google team that develops 1081 00:46:36,599 --> 00:46:38,700 the Google CLI well the Google CLI 1082 00:46:38,700 --> 00:46:41,940 doesn't use device code flow and so it 1083 00:46:41,940 --> 00:46:44,339 makes sense that this could be validated 1084 00:46:44,339 --> 00:46:49,380 and it wasn't a year plus ago but since 1085 00:46:49,380 --> 00:46:52,980 earlier in 2022 it is checked so great 1086 00:46:52,980 --> 00:46:55,260 great job great news complicated 1087 00:46:55,260 --> 00:46:57,380 protocol this is good validation check 1088 00:46:57,380 --> 00:47:00,359 contrast that with Microsoft's 1089 00:47:00,359 --> 00:47:02,280 implementation device code flow and let 1090 00:47:02,280 --> 00:47:03,599 me just fix this sounds like I'm 1091 00:47:03,599 --> 00:47:05,640 slamming Microsoft a lot I'm just trying 1092 00:47:05,640 --> 00:47:08,339 to get into the complexity of the 1093 00:47:08,339 --> 00:47:10,500 protocol and how easy it is to open 1094 00:47:10,500 --> 00:47:13,440 doors for abuse right in Microsoft's 1095 00:47:13,440 --> 00:47:15,020 it's a non-standard implementation 1096 00:47:15,020 --> 00:47:17,780 there's SSO requirements in there 1097 00:47:17,780 --> 00:47:21,180 there's no pres presentation of Scopes 1098 00:47:21,180 --> 00:47:23,160 up front 1099 00:47:23,160 --> 00:47:27,359 um office 365. can participate in device 1100 00:47:27,359 --> 00:47:30,180 code flow which from a 50 000 foot level 1101 00:47:30,180 --> 00:47:32,400 makes no sense at all because why is 1102 00:47:32,400 --> 00:47:35,339 Office 365 a limited input device like a 1103 00:47:35,339 --> 00:47:37,319 smart TV it is not 1104 00:47:37,319 --> 00:47:38,880 so on so forth 1105 00:47:38,880 --> 00:47:40,260 um 1106 00:47:40,260 --> 00:47:42,740 Stow 1107 00:47:42,960 --> 00:47:45,599 good job Google on device code flow not 1108 00:47:45,599 --> 00:47:47,700 major risk even though the same kinds of 1109 00:47:47,700 --> 00:47:49,980 flow and attacks could be presented the 1110 00:47:49,980 --> 00:47:54,119 impact is much more limited however 1111 00:47:54,119 --> 00:47:56,880 let's not say that Google you know is 1112 00:47:56,880 --> 00:47:58,440 better than Microsoft or this or that 1113 00:47:58,440 --> 00:48:00,300 these are just examples you can probably 1114 00:48:00,300 --> 00:48:02,760 find you know half dozen more as you go 1115 00:48:02,760 --> 00:48:05,880 through major uh vendors or apps what I 1116 00:48:05,880 --> 00:48:07,140 want to do is switch off device code 1117 00:48:07,140 --> 00:48:09,660 flow and say look device code flow I 1118 00:48:09,660 --> 00:48:13,500 think is dangerous or risky 1119 00:48:13,500 --> 00:48:17,099 so are we safe if we encounter you know 1120 00:48:17,099 --> 00:48:21,300 as a user if we use apps that don't use 1121 00:48:21,300 --> 00:48:22,800 device code flow that'd be a natural 1122 00:48:22,800 --> 00:48:25,380 thing to sort of say oh and and you 1123 00:48:25,380 --> 00:48:26,880 might also be asking a little about 1124 00:48:26,880 --> 00:48:28,619 Google is Google is better at 1125 00:48:28,619 --> 00:48:30,480 implementing so I wanted to switch it up 1126 00:48:30,480 --> 00:48:32,339 and say well let's look at a different 1127 00:48:32,339 --> 00:48:34,920 flow called the authorization code Grant 1128 00:48:34,920 --> 00:48:37,500 this is the it's a bad name but it's the 1129 00:48:37,500 --> 00:48:43,160 main common flow of oauth that is used 1130 00:48:43,160 --> 00:48:45,619 predominantly through the public web 1131 00:48:45,619 --> 00:48:47,700 shopping cart 1132 00:48:47,700 --> 00:48:49,200 uh 1133 00:48:49,200 --> 00:48:52,020 that's the app requests access to your 1134 00:48:52,020 --> 00:48:55,260 PayPal account there's an oauth dialogue 1135 00:48:55,260 --> 00:48:57,540 you log into PayPal you hit approve that 1136 00:48:57,540 --> 00:48:58,859 app never gets your username and 1137 00:48:58,859 --> 00:49:00,960 password for PayPal but they do get an 1138 00:49:00,960 --> 00:49:03,540 oauth token and to actually get payment 1139 00:49:03,540 --> 00:49:06,780 and Away things go okay so let's look at 1140 00:49:06,780 --> 00:49:08,940 Google's implementation 1141 00:49:08,940 --> 00:49:13,440 and oob is out of band and at the point 1142 00:49:13,440 --> 00:49:17,880 a year plus ago this introduced risk 1143 00:49:17,880 --> 00:49:20,760 and so the way it would be carried out 1144 00:49:20,760 --> 00:49:24,119 ends up to the user being very similar 1145 00:49:24,119 --> 00:49:26,339 but let me explain a few differences so 1146 00:49:26,339 --> 00:49:28,560 this is shares some characteristics with 1147 00:49:28,560 --> 00:49:29,940 traditional phishing the attacker 1148 00:49:29,940 --> 00:49:31,800 actually creates a website so there's a 1149 00:49:31,800 --> 00:49:33,900 little bit of work a little bit of maybe 1150 00:49:33,900 --> 00:49:36,540 leaving some tracks in this case it is 1151 00:49:36,540 --> 00:49:38,480 presenting a 1152 00:49:38,480 --> 00:49:42,359 promotion hey join Google's clouds you 1153 00:49:42,359 --> 00:49:44,040 know customer group you get all these 1154 00:49:44,040 --> 00:49:45,660 benefits 1155 00:49:45,660 --> 00:49:48,660 um in the email I sent you 1156 00:49:48,660 --> 00:49:50,520 um a special invite code please plug it 1157 00:49:50,520 --> 00:49:52,079 in I'm not showing the email I'm jumping 1158 00:49:52,079 --> 00:49:53,819 ahead 1159 00:49:53,819 --> 00:49:57,240 um if the user types in the right code 1160 00:49:57,240 --> 00:49:58,740 um 1161 00:49:58,740 --> 00:50:01,319 they'll go through an actual 1162 00:50:01,319 --> 00:50:03,119 authentication step they will get 1163 00:50:03,119 --> 00:50:05,940 perhaps a dialogue that says Hey Google 1164 00:50:05,940 --> 00:50:08,099 Cloud SDK wants to access your account 1165 00:50:08,099 --> 00:50:10,980 in this case the attacker is 1166 00:50:10,980 --> 00:50:12,960 impersonating or assuming the identity 1167 00:50:12,960 --> 00:50:15,839 of the Google CLI which is titled the 1168 00:50:15,839 --> 00:50:18,480 Google Cloud SDK that includes the CLI 1169 00:50:18,480 --> 00:50:20,520 you see all of this is really confusing 1170 00:50:20,520 --> 00:50:26,579 but but the user can actually log in so 1171 00:50:26,579 --> 00:50:28,859 sorry let me let me just describe that 1172 00:50:28,859 --> 00:50:30,839 flow a little clear it's slightly 1173 00:50:30,839 --> 00:50:33,359 different than the device code flow I'm 1174 00:50:33,359 --> 00:50:35,460 presenting a real URL for Google for the 1175 00:50:35,460 --> 00:50:37,980 user to go to log in I'm telling them 1176 00:50:37,980 --> 00:50:40,140 they'll get the code after they log in 1177 00:50:40,140 --> 00:50:42,000 and they should copy and paste it back 1178 00:50:42,000 --> 00:50:45,000 to this website okay so the fact that 1179 00:50:45,000 --> 00:50:46,619 this is an attacker website does mean 1180 00:50:46,619 --> 00:50:48,540 there's a chance to catch and detect 1181 00:50:48,540 --> 00:50:50,460 this this sort of like traditional 1182 00:50:50,460 --> 00:50:53,099 phishing detecting suspicious things 1183 00:50:53,099 --> 00:50:55,619 here while the user is authenticating is 1184 00:50:55,619 --> 00:50:57,500 still very hard because it's real Google 1185 00:50:57,500 --> 00:51:01,020 domain and URL you can see that after 1186 00:51:01,020 --> 00:51:04,440 login the user will get a code it's 1187 00:51:04,440 --> 00:51:08,280 longer but there's a copy paste icon and 1188 00:51:08,280 --> 00:51:11,040 I also want to point out this has been 1189 00:51:11,040 --> 00:51:13,260 closed I'm jumping ahead by Google as a 1190 00:51:13,260 --> 00:51:17,700 risk but in 2021 this existed 1191 00:51:17,700 --> 00:51:20,040 so the user copies and pastes that code 1192 00:51:20,040 --> 00:51:23,099 back and once they hit submit 1193 00:51:23,099 --> 00:51:23,760 um 1194 00:51:23,760 --> 00:51:25,740 the attacker gets that code because they 1195 00:51:25,740 --> 00:51:27,420 control this website and they're able to 1196 00:51:27,420 --> 00:51:30,059 get oauth tokens 1197 00:51:30,059 --> 00:51:32,520 um and underneath 1198 00:51:32,520 --> 00:51:35,819 um the I'm showing the attacker I'm 1199 00:51:35,819 --> 00:51:37,200 using 1200 00:51:37,200 --> 00:51:39,000 you can actually see the curl command 1201 00:51:39,000 --> 00:51:41,720 it's using the ID of the Google Cloud 1202 00:51:41,720 --> 00:51:44,460 CLI or SDK 1203 00:51:44,460 --> 00:51:47,579 it's using a well-known secret as well 1204 00:51:47,579 --> 00:51:50,640 from that CLI the code that the user 1205 00:51:50,640 --> 00:51:52,559 copy and pasted back and there's some 1206 00:51:52,559 --> 00:51:56,040 Scopes including Cloud platform which is 1207 00:51:56,040 --> 00:51:58,940 all of Google Cloud access 1208 00:51:58,940 --> 00:52:01,859 the redirect URI is sort of Google's 1209 00:52:01,859 --> 00:52:04,079 variation it just means 1210 00:52:04,079 --> 00:52:06,599 the users involved in a copy paste of 1211 00:52:06,599 --> 00:52:09,359 codes between Google and the app 1212 00:52:09,359 --> 00:52:11,280 requesting 1213 00:52:11,280 --> 00:52:12,119 um 1214 00:52:12,119 --> 00:52:14,220 that's really the danger and risk is 1215 00:52:14,220 --> 00:52:16,440 involving the user in anything but you 1216 00:52:16,440 --> 00:52:18,240 can see ultimately at the bottom in blue 1217 00:52:18,240 --> 00:52:21,240 access token refresh token 1218 00:52:21,240 --> 00:52:23,700 a pretty wide range of scope is given to 1219 00:52:23,700 --> 00:52:26,700 the user uh to the attacker sorry in 1220 00:52:26,700 --> 00:52:29,700 this case and that can be used for real 1221 00:52:29,700 --> 00:52:32,160 API calls to Google Cloud get all the 1222 00:52:32,160 --> 00:52:37,160 storage objects buckets so on so forth 1223 00:52:37,440 --> 00:52:40,740 complicated confused yeah it is so 1224 00:52:40,740 --> 00:52:43,980 before February 2022 this is what 1225 00:52:43,980 --> 00:52:46,020 happened underneath that sort of exposed 1226 00:52:46,020 --> 00:52:49,380 Google to more risk or or rather users 1227 00:52:49,380 --> 00:52:51,480 using Google 1228 00:52:51,480 --> 00:52:54,599 um to more risk uh is if someone fished 1229 00:52:54,599 --> 00:52:55,440 them 1230 00:52:55,440 --> 00:52:57,540 um so what happens 1231 00:52:57,540 --> 00:53:00,780 so the Google CLI 1232 00:53:00,780 --> 00:53:04,680 normally if you launch it locally on 1233 00:53:04,680 --> 00:53:08,280 the desktop or laptop that you you're 1234 00:53:08,280 --> 00:53:11,220 working off of and that has a browser 1235 00:53:11,220 --> 00:53:13,020 and a windowing system installed 1236 00:53:13,020 --> 00:53:16,020 normally 1237 00:53:16,020 --> 00:53:18,420 um that will immediately redirect you to 1238 00:53:18,420 --> 00:53:21,839 a browser you log in with Google 1239 00:53:21,839 --> 00:53:23,040 um 1240 00:53:23,040 --> 00:53:24,500 and 1241 00:53:24,500 --> 00:53:27,300 redirected transparently are things like 1242 00:53:27,300 --> 00:53:30,660 codes and and tokens and that's how you 1243 00:53:30,660 --> 00:53:33,420 authenticate your Google CLI with oauth 1244 00:53:33,420 --> 00:53:38,040 however you may be remoted into a 1245 00:53:38,040 --> 00:53:41,819 SSH or uh into a remote 1246 00:53:41,819 --> 00:53:42,480 um 1247 00:53:42,480 --> 00:53:48,300 computer Computing or VM or host and in 1248 00:53:48,300 --> 00:53:51,839 that case it can't launch a browser 1249 00:53:51,839 --> 00:53:54,440 um and so you can use command line 1250 00:53:54,440 --> 00:53:57,119 options that will go through a different 1251 00:53:57,119 --> 00:54:00,900 flow and so in this case it outputs a 1252 00:54:00,900 --> 00:54:03,300 very long URL 1253 00:54:03,300 --> 00:54:05,400 which you would then copy and paste back 1254 00:54:05,400 --> 00:54:09,000 to your your actual local device that 1255 00:54:09,000 --> 00:54:11,460 has a browser and you would go through 1256 00:54:11,460 --> 00:54:13,260 the authentication and then you would 1257 00:54:13,260 --> 00:54:15,480 get this copy and paste code 1258 00:54:15,480 --> 00:54:17,339 which we saw in the attack 1259 00:54:17,339 --> 00:54:19,559 I'm just showing the valid flow and use 1260 00:54:19,559 --> 00:54:21,119 of this and you would copy and paste it 1261 00:54:21,119 --> 00:54:23,040 back to the app which it gives you this 1262 00:54:23,040 --> 00:54:27,300 prompt so so this was by Design and and 1263 00:54:27,300 --> 00:54:29,640 it's it's a fine use case admin 1264 00:54:29,640 --> 00:54:32,720 especially might be running CLI commands 1265 00:54:32,720 --> 00:54:37,440 on a system with no windowing and it's 1266 00:54:37,440 --> 00:54:39,900 remote right 1267 00:54:39,900 --> 00:54:43,380 the problem is the copy paste step in 1268 00:54:43,380 --> 00:54:44,940 the bottom right 1269 00:54:44,940 --> 00:54:47,220 opens it up for phishing attacks 1270 00:54:47,220 --> 00:54:50,280 particularly so in this case the 1271 00:54:50,280 --> 00:54:52,140 attacker can assume identity of the 1272 00:54:52,140 --> 00:54:53,940 Google CLI just has to know the ID and 1273 00:54:53,940 --> 00:54:55,440 secret 1274 00:54:55,440 --> 00:54:57,260 um and when it comes time 1275 00:54:57,260 --> 00:54:59,640 after the user authenticates and 1276 00:54:59,640 --> 00:55:03,359 authorizes uh the way the attacker gets 1277 00:55:03,359 --> 00:55:07,380 the token is they just need that code 1278 00:55:07,380 --> 00:55:09,900 and by having the user copy and paste it 1279 00:55:09,900 --> 00:55:12,900 they get it now why is the copying paste 1280 00:55:12,900 --> 00:55:16,140 in the user involvement key to this well 1281 00:55:16,140 --> 00:55:18,420 if we didn't use that variation normally 1282 00:55:18,420 --> 00:55:21,119 what happens on the public internet is a 1283 00:55:21,119 --> 00:55:22,920 direct communication 1284 00:55:22,920 --> 00:55:24,680 between 1285 00:55:24,680 --> 00:55:28,200 Google the identity provider passing a 1286 00:55:28,200 --> 00:55:31,079 code to the app the valid app 1287 00:55:31,079 --> 00:55:33,540 and if those are publicly available on 1288 00:55:33,540 --> 00:55:34,800 the internet 1289 00:55:34,800 --> 00:55:37,079 um they can directly communicate if that 1290 00:55:37,079 --> 00:55:41,940 app is local to on the same machine as 1291 00:55:41,940 --> 00:55:45,200 your user agent or browser the user 1292 00:55:45,200 --> 00:55:47,819 it can also be done through an HTTP 1293 00:55:47,819 --> 00:55:49,980 redirect to localhost in a certain port 1294 00:55:49,980 --> 00:55:53,160 number the problem though is 1295 00:55:53,160 --> 00:55:55,440 the whole reason this use case 1296 00:55:55,440 --> 00:55:58,619 exists is the location of the app the 1297 00:55:58,619 --> 00:56:00,599 Google CLI exists 1298 00:56:00,599 --> 00:56:03,180 anywhere and it could be fully blocked 1299 00:56:03,180 --> 00:56:05,520 from incoming traffic so the only way 1300 00:56:05,520 --> 00:56:07,140 for it to get a code for it to get a 1301 00:56:07,140 --> 00:56:10,200 token is for the user to sort of copy 1302 00:56:10,200 --> 00:56:12,900 and paste in there so 1303 00:56:12,900 --> 00:56:15,599 the the mechanism the redirect mechanism 1304 00:56:15,599 --> 00:56:19,940 for the Google identity provider Google 1305 00:56:19,940 --> 00:56:23,819 workspace to contact the app with codes 1306 00:56:23,819 --> 00:56:26,400 that the app can use to get tokens 1307 00:56:26,400 --> 00:56:29,220 that cannot be directly can't be direct 1308 00:56:29,220 --> 00:56:31,559 communication that's why copy and paste 1309 00:56:31,559 --> 00:56:33,780 was introduced 1310 00:56:33,780 --> 00:56:35,880 by Google 1311 00:56:35,880 --> 00:56:36,960 um 1312 00:56:36,960 --> 00:56:38,579 but it opened the door for phishing 1313 00:56:38,579 --> 00:56:39,960 attacks 1314 00:56:39,960 --> 00:56:45,020 now what about defending this well 1315 00:56:45,540 --> 00:56:47,700 you can see that 1316 00:56:47,700 --> 00:56:50,280 the key here is getting the code this 1317 00:56:50,280 --> 00:56:52,559 code is needed by the attacker or the 1318 00:56:52,559 --> 00:56:55,140 real app to get the access token in it's 1319 00:56:55,140 --> 00:56:57,059 still hard to prevent this but this is 1320 00:56:57,059 --> 00:57:00,839 all pre version 372 of SDK so this is 1321 00:57:00,839 --> 00:57:05,099 all in before February 2022. 1322 00:57:05,099 --> 00:57:08,099 um Google did take measures 1323 00:57:08,099 --> 00:57:10,680 likely in response to our disclosure 1324 00:57:10,680 --> 00:57:14,040 um in 2021 and essentially they took 1325 00:57:14,040 --> 00:57:16,500 away this oob copy paste there's still 1326 00:57:16,500 --> 00:57:19,800 copy and pasting but it's really without 1327 00:57:19,800 --> 00:57:21,720 getting into details it's a really long 1328 00:57:21,720 --> 00:57:23,780 obscure you know 1329 00:57:23,780 --> 00:57:26,460 URLs so it's much harder to fish with 1330 00:57:26,460 --> 00:57:28,200 that because it's a lot harder to fool a 1331 00:57:28,200 --> 00:57:30,180 user into thinking like this full-blown 1332 00:57:30,180 --> 00:57:33,540 long URL is actually a code of any sort 1333 00:57:33,540 --> 00:57:36,720 that that uh but 1334 00:57:36,720 --> 00:57:40,079 um it's still possible it all depends 1335 00:57:40,079 --> 00:57:42,240 right you know some users ultimately are 1336 00:57:42,240 --> 00:57:44,700 going to do things but a lot of the risk 1337 00:57:44,700 --> 00:57:47,099 is removed by removing the copy paste 1338 00:57:47,099 --> 00:57:50,819 part of the user uh what the OB 1339 00:57:50,819 --> 00:57:52,800 variation 1340 00:57:52,800 --> 00:57:55,020 um in fact the whole OB thing will be 1341 00:57:55,020 --> 00:57:56,940 deprecated 1342 00:57:56,940 --> 00:57:57,720 um 1343 00:57:57,720 --> 00:58:02,520 in various stages and as of late 2022 uh 1344 00:58:02,520 --> 00:58:04,079 should not exist there'll be warnings 1345 00:58:04,079 --> 00:58:06,079 and then it will be removed so 1346 00:58:06,079 --> 00:58:10,260 ultimately before we go on this was a 1347 00:58:10,260 --> 00:58:11,880 very good 1348 00:58:11,880 --> 00:58:12,720 um 1349 00:58:12,720 --> 00:58:14,240 foreign 1350 00:58:14,240 --> 00:58:17,400 ultimately you can see or You might 1351 00:58:17,400 --> 00:58:20,099 notice that what the user experiences is 1352 00:58:20,099 --> 00:58:23,339 is more complicated because boy when 1353 00:58:23,339 --> 00:58:24,660 they go through this process They're 1354 00:58:24,660 --> 00:58:27,300 copying around you know longer strings 1355 00:58:27,300 --> 00:58:30,540 of characters and URLs and it's 1356 00:58:30,540 --> 00:58:33,359 it's uh definitely 1357 00:58:33,359 --> 00:58:36,299 um a less usable friendly process 1358 00:58:36,299 --> 00:58:40,559 however we gain by the security of the 1359 00:58:40,559 --> 00:58:42,960 overall system and protocol 1360 00:58:42,960 --> 00:58:45,059 so 1361 00:58:45,059 --> 00:58:47,640 the lesson here is that even with the 1362 00:58:47,640 --> 00:58:48,960 most common 1363 00:58:48,960 --> 00:58:51,480 tested protocol 1364 00:58:51,480 --> 00:58:53,940 some of the implementation 1365 00:58:53,940 --> 00:58:56,400 or customizations in this case an 1366 00:58:56,400 --> 00:59:00,359 extension to the redirection url url can 1367 00:59:00,359 --> 00:59:03,960 cause problems or at least increase risk 1368 00:59:03,960 --> 00:59:07,020 so I want to talk quickly about a 1369 00:59:07,020 --> 00:59:08,780 completely different attack 1370 00:59:08,780 --> 00:59:12,299 which was documented by samuda in May of 1371 00:59:12,299 --> 00:59:15,180 2022 URL up in the top left and 1372 00:59:15,180 --> 00:59:17,520 Malwarebytes did a summary there and I'm 1373 00:59:17,520 --> 00:59:19,920 going to try to do this Justice although 1374 00:59:19,920 --> 00:59:23,520 it's not fully documented but samuda did 1375 00:59:23,520 --> 00:59:26,040 some really good work and seems to be an 1376 00:59:26,040 --> 00:59:28,680 expert at Facebook takeover bugs and Bug 1377 00:59:28,680 --> 00:59:31,260 bounties so he got a good Bounty off of 1378 00:59:31,260 --> 00:59:33,720 this and I want to show how complex 1379 00:59:33,720 --> 00:59:36,119 chaining of attacks with traditional web 1380 00:59:36,119 --> 00:59:39,359 vulnerabilities and identity protocols 1381 00:59:39,359 --> 00:59:40,440 like 1382 00:59:40,440 --> 00:59:43,140 oauth or SSO protocols can lead to 1383 00:59:43,140 --> 00:59:46,260 further abuse so there were three sort 1384 00:59:46,260 --> 00:59:49,680 of interacting call them issues that by 1385 00:59:49,680 --> 00:59:51,599 themselves may not have alarmed anybody 1386 00:59:51,599 --> 00:59:53,819 even if you knew them beforehand but 1387 00:59:53,819 --> 00:59:56,099 together resulted in a big Facebook 1388 00:59:56,099 --> 00:59:59,280 takeover uh risk so 1389 00:59:59,280 --> 01:00:02,400 essentially facebook.com 1390 01:00:02,400 --> 01:00:03,599 um 1391 01:00:03,599 --> 01:00:06,180 has a Sandbox at a completely different 1392 01:00:06,180 --> 01:00:08,099 domain and 1393 01:00:08,099 --> 01:00:11,460 sandbox developer area to play with 1394 01:00:11,460 --> 01:00:12,180 um 1395 01:00:12,180 --> 01:00:14,700 Salesforce has it there's good reasons 1396 01:00:14,700 --> 01:00:18,660 for certain apps that allow at a minimum 1397 01:00:18,660 --> 01:00:20,520 HTML 1398 01:00:20,520 --> 01:00:23,880 home page or dashboard customization for 1399 01:00:23,880 --> 01:00:25,500 there to be a developer sandbox where 1400 01:00:25,500 --> 01:00:27,960 you can customize the HTML as well as 1401 01:00:27,960 --> 01:00:30,960 the script normally that those are sort 1402 01:00:30,960 --> 01:00:31,819 of 1403 01:00:31,819 --> 01:00:35,040 non-production areas to play with so 1404 01:00:35,040 --> 01:00:36,480 even 1405 01:00:36,480 --> 01:00:41,040 though by uploading your own HTML CSS an 1406 01:00:41,040 --> 01:00:42,599 attacker could do the same and upload 1407 01:00:42,599 --> 01:00:44,700 and try to get users to go there the 1408 01:00:44,700 --> 01:00:46,619 risk is pretty contained right because I 1409 01:00:46,619 --> 01:00:49,140 have to convince someone to go to face 1410 01:00:49,140 --> 01:00:52,579 my my attacker account at Facebook 1411 01:00:52,579 --> 01:00:55,920 sandbox sbx.com and that's no different 1412 01:00:55,920 --> 01:00:57,900 than me creating my own website right so 1413 01:00:57,900 --> 01:00:59,280 that doesn't really change the risk 1414 01:00:59,280 --> 01:01:02,339 profile but but number one is there's an 1415 01:01:02,339 --> 01:01:05,280 existence of sandbox and the top Arrow 1416 01:01:05,280 --> 01:01:08,520 shows that obviously allows attacker to 1417 01:01:08,520 --> 01:01:09,960 upload code 1418 01:01:09,960 --> 01:01:11,760 um that can lead to cross-site scripting 1419 01:01:11,760 --> 01:01:15,660 or uh request forgery attacks 1420 01:01:15,660 --> 01:01:19,440 the kicker of where the risk of that 1421 01:01:19,440 --> 01:01:22,440 becomes less contained or intermixed 1422 01:01:22,440 --> 01:01:24,180 with production is that there's actually 1423 01:01:24,180 --> 01:01:26,460 a trust relationship of sorts between 1424 01:01:26,460 --> 01:01:29,040 Facebook the production site and its 1425 01:01:29,040 --> 01:01:30,180 sandbox 1426 01:01:30,180 --> 01:01:32,339 the reasons were 1427 01:01:32,339 --> 01:01:33,980 apparently 1428 01:01:33,980 --> 01:01:36,720 according to samuda 1429 01:01:36,720 --> 01:01:39,960 it was in order for whatever reason the 1430 01:01:39,960 --> 01:01:43,680 sandbox hosted a captcha iframe that was 1431 01:01:43,680 --> 01:01:47,280 used during account reset flows meaning 1432 01:01:47,280 --> 01:01:48,720 if you had to reset your password on 1433 01:01:48,720 --> 01:01:51,420 facebook.com it would redirect you via 1434 01:01:51,420 --> 01:01:55,619 an iframe to the sandbox domain 1435 01:01:55,619 --> 01:01:59,640 where the caption would be presented 1436 01:01:59,640 --> 01:02:03,599 okay that by itself wasn't 1437 01:02:03,599 --> 01:02:05,400 horrible 1438 01:02:05,400 --> 01:02:07,020 um that's just sort of cross domain 1439 01:02:07,020 --> 01:02:10,079 issues cropping up really though there 1440 01:02:10,079 --> 01:02:12,420 was trust relationship and data leakage 1441 01:02:12,420 --> 01:02:15,359 in the sense that while you're in the 1442 01:02:15,359 --> 01:02:16,740 state of reset 1443 01:02:16,740 --> 01:02:20,220 if you hit try to access facebook.com 1444 01:02:20,220 --> 01:02:24,900 URLs it would redirect you still to the 1445 01:02:24,900 --> 01:02:26,460 caption basically saying no wait you 1446 01:02:26,460 --> 01:02:28,500 have to clean up your account first you 1447 01:02:28,500 --> 01:02:31,200 can't just access facebook.com URLs but 1448 01:02:31,200 --> 01:02:33,180 there would be data leakage in that the 1449 01:02:33,180 --> 01:02:35,819 referrer would get passed along 1450 01:02:35,819 --> 01:02:37,920 to fake the sandbox 1451 01:02:37,920 --> 01:02:42,000 as a parameter a get parameter so 1452 01:02:42,000 --> 01:02:46,740 now you can see that URL potential URL 1453 01:02:46,740 --> 01:02:48,180 information of things hitting 1454 01:02:48,180 --> 01:02:51,180 facebook.com can end up on the sandbox 1455 01:02:51,180 --> 01:02:54,359 side and you could guess that 1456 01:02:54,359 --> 01:02:57,660 if that you hit an attacker controlled 1457 01:02:57,660 --> 01:02:59,099 sandbox 1458 01:02:59,099 --> 01:03:03,059 they are might get URL or URL parameter 1459 01:03:03,059 --> 01:03:05,819 information that was intended for the 1460 01:03:05,819 --> 01:03:07,859 Facebook side okay 1461 01:03:07,859 --> 01:03:10,500 the sense at more risk interconnected 1462 01:03:10,500 --> 01:03:12,839 risk but the third piece was really the 1463 01:03:12,839 --> 01:03:14,520 kicker which is 1464 01:03:14,520 --> 01:03:17,700 oauth open ID connect 1465 01:03:17,700 --> 01:03:21,480 which is oauth for SSO was 1466 01:03:21,480 --> 01:03:23,280 is used 1467 01:03:23,280 --> 01:03:25,440 um in this case when Google is used as 1468 01:03:25,440 --> 01:03:27,900 the SSO system the interaction between 1469 01:03:27,900 --> 01:03:30,980 Facebook and Google 1470 01:03:30,980 --> 01:03:35,040 to provide that SSL capability utilizes 1471 01:03:35,040 --> 01:03:36,299 oauth 1472 01:03:36,299 --> 01:03:38,940 and the kicker which by itself isn't 1473 01:03:38,940 --> 01:03:40,380 strange 1474 01:03:40,380 --> 01:03:43,859 um that's why oidc was was created is to 1475 01:03:43,859 --> 01:03:48,119 extend oauth securely to handle SSO but 1476 01:03:48,119 --> 01:03:50,280 while in this password reset State this 1477 01:03:50,280 --> 01:03:52,940 checkpoint state 1478 01:03:53,220 --> 01:03:54,900 um oauth tokens 1479 01:03:54,900 --> 01:03:57,720 can be caused to be sent from the 1480 01:03:57,720 --> 01:03:59,280 identity provider Google 1481 01:03:59,280 --> 01:04:01,079 back to Facebook 1482 01:04:01,079 --> 01:04:04,140 there has to be communication of tokens 1483 01:04:04,140 --> 01:04:07,799 anyway between the two parties in an SSO 1484 01:04:07,799 --> 01:04:09,599 system the main site and and the 1485 01:04:09,599 --> 01:04:11,940 identity site that's not weird but when 1486 01:04:11,940 --> 01:04:14,339 coupled with these other two issues you 1487 01:04:14,339 --> 01:04:17,040 can start to think that the oauth token 1488 01:04:17,040 --> 01:04:20,579 if it's sent in a URL because oauth all 1489 01:04:20,579 --> 01:04:23,579 works over HTTP that maybe that could be 1490 01:04:23,579 --> 01:04:26,760 leaked through to the sandbox and if 1491 01:04:26,760 --> 01:04:28,319 it's the right sandbox controlled by 1492 01:04:28,319 --> 01:04:30,480 attacker the attacker now has an oauth 1493 01:04:30,480 --> 01:04:32,760 token 1494 01:04:32,760 --> 01:04:34,559 so 1495 01:04:34,559 --> 01:04:37,260 a full complicated flow I will in the 1496 01:04:37,260 --> 01:04:38,880 interest of time and sanity not go 1497 01:04:38,880 --> 01:04:41,339 through because it's complicated but I 1498 01:04:41,339 --> 01:04:43,200 want to point out what I've numbered are 1499 01:04:43,200 --> 01:04:47,160 the rough steps that samuda went through 1500 01:04:47,160 --> 01:04:49,260 which is as an attacker you can create 1501 01:04:49,260 --> 01:04:51,480 some cost site scripting and request 1502 01:04:51,480 --> 01:04:53,400 forgery code 1503 01:04:53,400 --> 01:04:55,380 and put it up in a sandbox you can then 1504 01:04:55,380 --> 01:04:58,140 direct the user to go visit that 1505 01:04:58,140 --> 01:04:58,980 um 1506 01:04:58,980 --> 01:05:03,359 and that code a lot of things it can set 1507 01:05:03,359 --> 01:05:05,819 Facebook or the user into the right 1508 01:05:05,819 --> 01:05:08,520 Facebook reset or checkpoint state 1509 01:05:08,520 --> 01:05:11,940 uh request an oauth token uh get that 1510 01:05:11,940 --> 01:05:13,319 token 1511 01:05:13,319 --> 01:05:14,819 um sent 1512 01:05:14,819 --> 01:05:18,960 to facebook.com forwarded on back to the 1513 01:05:18,960 --> 01:05:20,460 attackers 1514 01:05:20,460 --> 01:05:21,299 um 1515 01:05:21,299 --> 01:05:23,160 sandbox 1516 01:05:23,160 --> 01:05:26,339 and from there they can extract it 1517 01:05:26,339 --> 01:05:28,740 it's extremely complicated and advanced 1518 01:05:28,740 --> 01:05:33,780 but it shows how three different sort of 1519 01:05:33,780 --> 01:05:37,260 less than ideal security designs can be 1520 01:05:37,260 --> 01:05:39,839 pieced together and the sum total is 1521 01:05:39,839 --> 01:05:42,240 much much more than the individual ones 1522 01:05:42,240 --> 01:05:45,740 from a risk perspective 1523 01:05:46,020 --> 01:05:48,420 and we've been talking a ton about 1524 01:05:48,420 --> 01:05:50,099 fishing and I want to make sure that 1525 01:05:50,099 --> 01:05:52,920 people understand that this is 1526 01:05:52,920 --> 01:05:57,859 Not Just Fishing risk 1527 01:05:57,859 --> 01:06:02,099 oauth tokens any kind of hijacking or 1528 01:06:02,099 --> 01:06:03,420 theft 1529 01:06:03,420 --> 01:06:04,920 um 1530 01:06:04,920 --> 01:06:08,040 is a risk area so in general think about 1531 01:06:08,040 --> 01:06:12,180 credential attacks right so 1532 01:06:12,180 --> 01:06:16,380 um a while back I had talked about via 1533 01:06:16,380 --> 01:06:19,920 blog posts about various 1534 01:06:19,920 --> 01:06:23,160 not so obvious uses of oauth and once 1535 01:06:23,160 --> 01:06:26,400 oauth is used tokens exist if tokens 1536 01:06:26,400 --> 01:06:29,099 exist and are cached anywhere those are 1537 01:06:29,099 --> 01:06:31,500 areas for abuse so I want to quickly 1538 01:06:31,500 --> 01:06:33,539 point out a very different non-fishing 1539 01:06:33,539 --> 01:06:35,640 example right so 1540 01:06:35,640 --> 01:06:38,579 uh not to pick on any particular vendor 1541 01:06:38,579 --> 01:06:41,220 almost all vendors once you have a CLI 1542 01:06:41,220 --> 01:06:42,960 as an example 1543 01:06:42,960 --> 01:06:45,240 um and it speaks oauth because that's 1544 01:06:45,240 --> 01:06:47,700 what's what the vendor uses across the 1545 01:06:47,700 --> 01:06:48,960 board 1546 01:06:48,960 --> 01:06:50,640 um it will have to Cache oauth tokens 1547 01:06:50,640 --> 01:06:53,339 and they are often cached in the clear 1548 01:06:53,339 --> 01:06:57,359 in clear text so if you can 1549 01:06:57,359 --> 01:07:00,000 gain access to the system where the CLI 1550 01:07:00,000 --> 01:07:03,299 is installed well you have access easily 1551 01:07:03,299 --> 01:07:06,119 to cash tokens which in oauth World 1552 01:07:06,119 --> 01:07:07,680 remember are essentially permanent 1553 01:07:07,680 --> 01:07:10,500 bypass mfx hard to deal with so on so 1554 01:07:10,500 --> 01:07:12,180 forth 1555 01:07:12,180 --> 01:07:13,980 um so that's sort of obvious once you 1556 01:07:13,980 --> 01:07:15,180 think about it you're like okay great 1557 01:07:15,180 --> 01:07:16,140 fine 1558 01:07:16,140 --> 01:07:18,839 if these are endpoints of users 1559 01:07:18,839 --> 01:07:20,940 a typical response by by everyone as 1560 01:07:20,940 --> 01:07:22,559 well of course once you gain access to 1561 01:07:22,559 --> 01:07:24,359 the user's endpoint you have access to 1562 01:07:24,359 --> 01:07:26,760 everything so whatever it's it's you 1563 01:07:26,760 --> 01:07:28,920 know they can um they can do everything 1564 01:07:28,920 --> 01:07:31,500 including gain access to credentials 1565 01:07:31,500 --> 01:07:34,319 like oauth tokens however 1566 01:07:34,319 --> 01:07:36,780 there are the hidden uses of oauth and 1567 01:07:36,780 --> 01:07:38,660 so if you dig deeper in the cloud 1568 01:07:38,660 --> 01:07:40,500 implementations the general Cloud 1569 01:07:40,500 --> 01:07:41,760 providers 1570 01:07:41,760 --> 01:07:45,119 you find that wow almost all of them 1571 01:07:45,119 --> 01:07:48,960 provide a easy to you well one they 1572 01:07:48,960 --> 01:07:51,000 provide virtual machines so compute 1573 01:07:51,000 --> 01:07:55,680 engines were often Cloud uh tools and 1574 01:07:55,680 --> 01:07:58,020 sclis are installed 1575 01:07:58,020 --> 01:07:59,460 okay 1576 01:07:59,460 --> 01:08:01,920 that's that's another area to worry 1577 01:08:01,920 --> 01:08:03,780 about and and people 1578 01:08:03,780 --> 01:08:05,819 vendors tend to be more lacked once 1579 01:08:05,819 --> 01:08:07,680 you're within the walls of the cloud 1580 01:08:07,680 --> 01:08:09,720 right there's this idea well you've you 1581 01:08:09,720 --> 01:08:11,280 know you had to gain access through our 1582 01:08:11,280 --> 01:08:14,220 very very restrictive IAM system and and 1583 01:08:14,220 --> 01:08:16,439 once you do then well of course you can 1584 01:08:16,439 --> 01:08:18,359 do damage but but the point is did 1585 01:08:18,359 --> 01:08:19,920 anyone think that there's a whole bunch 1586 01:08:19,920 --> 01:08:21,719 of cash tokens well 1587 01:08:21,719 --> 01:08:24,960 Cloud World AWS included Microsoft 1588 01:08:24,960 --> 01:08:26,580 Google 1589 01:08:26,580 --> 01:08:28,560 um so on and so forth 1590 01:08:28,560 --> 01:08:31,500 yeah compute engines become an area that 1591 01:08:31,500 --> 01:08:33,120 can be exploited 1592 01:08:33,120 --> 01:08:35,460 um without even talking about that I 1593 01:08:35,460 --> 01:08:37,198 neglected to mention I want to mention 1594 01:08:37,198 --> 01:08:39,719 service accounts okay you're talking 1595 01:08:39,719 --> 01:08:40,799 about 1596 01:08:40,799 --> 01:08:44,040 permanent running code uh 1597 01:08:44,040 --> 01:08:47,279 typically if you have a job running or 1598 01:08:47,279 --> 01:08:49,140 compute engine you know you might have 1599 01:08:49,140 --> 01:08:51,299 separate API Keys set up service 1600 01:08:51,299 --> 01:08:53,698 accounts non-user accounts right 1601 01:08:53,698 --> 01:08:55,319 what does that have to do with oauth 1602 01:08:55,319 --> 01:08:57,238 well one of the Dirty Secrets is 1603 01:08:57,238 --> 01:09:01,560 sometimes what appears not oh oauth to 1604 01:09:01,560 --> 01:09:03,359 just provide contacts 1605 01:09:03,359 --> 01:09:05,279 really it was designed for user 1606 01:09:05,279 --> 01:09:07,738 interaction for a user to Grant a subset 1607 01:09:07,738 --> 01:09:11,460 of privileges not their whole user uh 1608 01:09:11,460 --> 01:09:13,679 set of privileges to third-party 1609 01:09:13,679 --> 01:09:15,540 applications right that's really oauth's 1610 01:09:15,540 --> 01:09:18,359 purpose is user want to Grant access to 1611 01:09:18,359 --> 01:09:19,259 an app 1612 01:09:19,259 --> 01:09:21,479 to some of my resources and I don't want 1613 01:09:21,479 --> 01:09:23,880 to give them my username and credential 1614 01:09:23,880 --> 01:09:27,060 which has all of my access okay service 1615 01:09:27,060 --> 01:09:29,160 account you might think what's that have 1616 01:09:29,160 --> 01:09:31,620 to do with oauth I mean 1617 01:09:31,620 --> 01:09:33,719 usually it wouldn't 1618 01:09:33,719 --> 01:09:35,698 the user's not involved they can't press 1619 01:09:35,698 --> 01:09:38,160 press accept on what permissions they 1620 01:09:38,160 --> 01:09:40,679 can't do the approval process mostly 1621 01:09:40,679 --> 01:09:43,319 service accounts are hard-coded with 1622 01:09:43,319 --> 01:09:47,460 API Keys hard-coded credentials so so on 1623 01:09:47,460 --> 01:09:49,319 point out is in some implementations 1624 01:09:49,319 --> 01:09:51,299 it's actually quite common 1625 01:09:51,299 --> 01:09:53,819 that oauth pops up so what happens what 1626 01:09:53,819 --> 01:09:55,560 do I mean by that well 1627 01:09:55,560 --> 01:09:58,199 you can configure CLI not just with user 1628 01:09:58,199 --> 01:10:00,960 credentials in Google you can configure 1629 01:10:00,960 --> 01:10:03,900 them with service accounts 1630 01:10:03,900 --> 01:10:07,080 presumably so an admin can take on the 1631 01:10:07,080 --> 01:10:09,540 identity of a service account and maybe 1632 01:10:09,540 --> 01:10:11,940 do some debugging okay so it's not crazy 1633 01:10:11,940 --> 01:10:14,900 the problem is that service account 1634 01:10:14,900 --> 01:10:17,040 generates oauth 1635 01:10:17,040 --> 01:10:19,980 tokens underneath and they get cached so 1636 01:10:19,980 --> 01:10:21,960 the exposure is not just user accounts 1637 01:10:21,960 --> 01:10:23,159 you might get 1638 01:10:23,159 --> 01:10:24,960 service account 1639 01:10:24,960 --> 01:10:28,920 s access also exposed through this 1640 01:10:28,920 --> 01:10:33,780 caching of tokens in CLI so that 1641 01:10:33,780 --> 01:10:35,640 anything that's hidden not explicit 1642 01:10:35,640 --> 01:10:38,460 becomes a risk area and and the access 1643 01:10:38,460 --> 01:10:40,560 is typically wider than you would think 1644 01:10:40,560 --> 01:10:42,719 than just a user account access you 1645 01:10:42,719 --> 01:10:44,699 could find service accounts what else 1646 01:10:44,699 --> 01:10:47,159 well there are hidden installations of 1647 01:10:47,159 --> 01:10:50,100 sdks so I believe all the major vendors 1648 01:10:50,100 --> 01:10:52,020 there have a cloud shell implementation 1649 01:10:52,020 --> 01:10:54,120 which is a pre-installed shell 1650 01:10:54,120 --> 01:10:55,920 environment for user access typically 1651 01:10:55,920 --> 01:11:00,000 admins includes this SDK and the CLI and 1652 01:11:00,000 --> 01:11:02,100 therefore 1653 01:11:02,100 --> 01:11:05,100 uses oauth and caches oauth and uh 1654 01:11:05,100 --> 01:11:09,000 there's persistence in in those and so 1655 01:11:09,000 --> 01:11:11,580 um you can gain access still tokens from 1656 01:11:11,580 --> 01:11:13,800 there the security measures often lacks 1657 01:11:13,800 --> 01:11:15,060 because it's again assumed to be 1658 01:11:15,060 --> 01:11:17,640 protected behind a couple moats 1659 01:11:17,640 --> 01:11:18,600 um 1660 01:11:18,600 --> 01:11:22,140 and so I I'd put forth there's less 1661 01:11:22,140 --> 01:11:24,659 protection than an endpoint for a cloud 1662 01:11:24,659 --> 01:11:26,520 Channel environment and points at least 1663 01:11:26,520 --> 01:11:28,199 you know typically there's AV and other 1664 01:11:28,199 --> 01:11:32,280 controls to detect uh uh access uh 1665 01:11:32,280 --> 01:11:34,560 strange access 1666 01:11:34,560 --> 01:11:36,560 um 1667 01:11:36,780 --> 01:11:39,179 the last one is sort of well known but 1668 01:11:39,179 --> 01:11:42,420 I'm just pointing out that cash tokens 1669 01:11:42,420 --> 01:11:43,560 um 1670 01:11:43,560 --> 01:11:47,100 virtual machines often simplify access 1671 01:11:47,100 --> 01:11:49,500 so they they run as a particular role 1672 01:11:49,500 --> 01:11:51,420 with certain privileges not user 1673 01:11:51,420 --> 01:11:53,760 Privileges and whatever those privileges 1674 01:11:53,760 --> 01:11:56,820 are typically you can gain access once 1675 01:11:56,820 --> 01:11:58,140 you gain access to the compute engine 1676 01:11:58,140 --> 01:12:00,199 that's not necessarily new or different 1677 01:12:00,199 --> 01:12:03,900 but again it's sort of Breaking Down the 1678 01:12:03,900 --> 01:12:05,580 Walls between a service account being 1679 01:12:05,580 --> 01:12:08,280 used by a compute Engine versus and 1680 01:12:08,280 --> 01:12:09,960 getting some a different form of it 1681 01:12:09,960 --> 01:12:12,000 which is an oauth access token which is 1682 01:12:12,000 --> 01:12:13,440 typically in everyone's mind associated 1683 01:12:13,440 --> 01:12:16,219 with user access 1684 01:12:16,679 --> 01:12:18,540 so 1685 01:12:18,540 --> 01:12:21,960 um again there is a lot uh here that I 1686 01:12:21,960 --> 01:12:22,980 don't necessarily want to cover in 1687 01:12:22,980 --> 01:12:26,159 detail I do reference back to Juan 1688 01:12:26,159 --> 01:12:29,159 Berner who did talk about how to do some 1689 01:12:29,159 --> 01:12:31,860 persistence in Cloud shells 1690 01:12:31,860 --> 01:12:33,900 um pick your favorite 1691 01:12:33,900 --> 01:12:36,780 um one-liner shell script that you can 1692 01:12:36,780 --> 01:12:40,020 put into startup scripts bash RCS or 1693 01:12:40,020 --> 01:12:41,159 profiles 1694 01:12:41,159 --> 01:12:44,460 and provide a reverse access or a 1695 01:12:44,460 --> 01:12:47,880 dumping of the cached ol tokens I'm just 1696 01:12:47,880 --> 01:12:50,219 showing how easy it is to leverage this 1697 01:12:50,219 --> 01:12:52,159 in a practical manner 1698 01:12:52,159 --> 01:12:56,940 cache tokens combined with a cloud shell 1699 01:12:56,940 --> 01:13:00,500 which is persistent and also has 1700 01:13:00,500 --> 01:13:03,659 cash tokens 1701 01:13:03,659 --> 01:13:06,540 um easy to install a back door and may 1702 01:13:06,540 --> 01:13:10,400 never be detected 1703 01:13:10,400 --> 01:13:12,179 so 1704 01:13:12,179 --> 01:13:14,340 I wanted to finish from coming towards 1705 01:13:14,340 --> 01:13:17,219 the end this is longer than than sort of 1706 01:13:17,219 --> 01:13:18,840 the live version 1707 01:13:18,840 --> 01:13:20,520 um 1708 01:13:20,520 --> 01:13:22,159 I just wanted from a research 1709 01:13:22,159 --> 01:13:24,840 perspective to present sort of a 1710 01:13:24,840 --> 01:13:27,300 quadrant of sort of where the 1711 01:13:27,300 --> 01:13:29,940 opportunities are for abuse in my mind 1712 01:13:29,940 --> 01:13:32,159 sort of looking on along two Dimensions 1713 01:13:32,159 --> 01:13:34,980 easy to hard and near-term to sort of 1714 01:13:34,980 --> 01:13:37,080 further in the future so anytime 1715 01:13:37,080 --> 01:13:39,300 usability is talked about 1716 01:13:39,300 --> 01:13:41,159 um to me it's an easy one to look at 1717 01:13:41,159 --> 01:13:43,800 today device code flow is an example of 1718 01:13:43,800 --> 01:13:46,260 that probe in there usually there's some 1719 01:13:46,260 --> 01:13:48,659 issues because usability in my mind is 1720 01:13:48,659 --> 01:13:52,500 often add-ons with security 1721 01:13:52,500 --> 01:13:54,540 um similar to that 1722 01:13:54,540 --> 01:13:56,520 um you know when vendor say Hey by 1723 01:13:56,520 --> 01:13:59,159 design of the future it's or it's the 1724 01:13:59,159 --> 01:14:01,560 user blames the user to me that's sort 1725 01:14:01,560 --> 01:14:04,800 of avoiding solving the problem and and 1726 01:14:04,800 --> 01:14:07,500 I get that a lot with anything that 1727 01:14:07,500 --> 01:14:09,420 hints at phishing abuse 1728 01:14:09,420 --> 01:14:12,000 um and I I don't buy that it's a little 1729 01:14:12,000 --> 01:14:14,460 bit harder to find Opportunities there 1730 01:14:14,460 --> 01:14:16,199 but that there's a lot of that talk 1731 01:14:16,199 --> 01:14:17,760 today and and you hear that with 1732 01:14:17,760 --> 01:14:19,320 temporary token systems hey it's by 1733 01:14:19,320 --> 01:14:21,360 Design it's a feature it just times out 1734 01:14:21,360 --> 01:14:23,640 after an hour 1735 01:14:23,640 --> 01:14:25,679 um it's you hear it about phishing 1736 01:14:25,679 --> 01:14:28,080 attacks where it's like hey what can you 1737 01:14:28,080 --> 01:14:29,820 do if a user's fished I mean you can try 1738 01:14:29,820 --> 01:14:33,060 to train them but that's not our problem 1739 01:14:33,060 --> 01:14:35,760 um And all I'll see there is I'm sure at 1740 01:14:35,760 --> 01:14:37,100 one point we said that about password 1741 01:14:37,100 --> 01:14:40,320 strength right hey what can we do if a 1742 01:14:40,320 --> 01:14:42,659 user picks a a bad password that's too 1743 01:14:42,659 --> 01:14:44,760 short or a dictionary word 1744 01:14:44,760 --> 01:14:46,739 but that didn't stop the industry from 1745 01:14:46,739 --> 01:14:49,199 ultimately trying to 1746 01:14:49,199 --> 01:14:51,300 create better password systems including 1747 01:14:51,300 --> 01:14:54,360 no password systems and and device you 1748 01:14:54,360 --> 01:14:57,780 know keys and authentication or password 1749 01:14:57,780 --> 01:15:00,659 managers or password policies right so I 1750 01:15:00,659 --> 01:15:02,159 don't buy that but from a research 1751 01:15:02,159 --> 01:15:04,440 perspective any talk about that from 1752 01:15:04,440 --> 01:15:07,920 vendors or in documentation is an 1753 01:15:07,920 --> 01:15:10,380 opportunity that there are to to find 1754 01:15:10,380 --> 01:15:13,020 areas for abuse anytime they're sort of 1755 01:15:13,020 --> 01:15:16,080 hidden non-explicit defaults and and I 1756 01:15:16,080 --> 01:15:17,280 mentioned Scopes which are the 1757 01:15:17,280 --> 01:15:19,920 permissions Microsoft device code flow 1758 01:15:19,920 --> 01:15:22,800 has default scopes again to me it's a 1759 01:15:22,800 --> 01:15:24,600 big opportunity 1760 01:15:24,600 --> 01:15:28,380 um to find issues or problems with that 1761 01:15:28,380 --> 01:15:29,360 um 1762 01:15:29,360 --> 01:15:31,560 inconsistencies or differences among 1763 01:15:31,560 --> 01:15:33,679 vendor implementations so that could be 1764 01:15:33,679 --> 01:15:36,360 outflow versus Microsoft device code 1765 01:15:36,360 --> 01:15:39,800 flow inconsistencies could be hey 1766 01:15:39,800 --> 01:15:42,360 Microsoft or Google I treat my own apps 1767 01:15:42,360 --> 01:15:46,199 differently than other third-party apps 1768 01:15:46,199 --> 01:15:48,780 and we saw that with SSO device code 1769 01:15:48,780 --> 01:15:52,219 flow implementation by Microsoft 1770 01:15:52,219 --> 01:15:56,120 anytime the protocol is customized 1771 01:15:56,120 --> 01:15:58,860 extensions now oauth did provide for 1772 01:15:58,860 --> 01:16:00,719 extensions I just think it's a dangerous 1773 01:16:00,719 --> 01:16:03,060 area that usually introduces risks so 1774 01:16:03,060 --> 01:16:05,940 the out-of-band extension to the URL 1775 01:16:05,940 --> 01:16:08,219 redirect 1776 01:16:08,219 --> 01:16:11,159 ultimately led to more fishing risk and 1777 01:16:11,159 --> 01:16:13,800 abuse the fact that there's no approvals 1778 01:16:13,800 --> 01:16:16,320 and even if approvals are optional and 1779 01:16:16,320 --> 01:16:17,900 left to the vendor 1780 01:16:17,900 --> 01:16:20,699 it's a it's a warning sign anything 1781 01:16:20,699 --> 01:16:22,860 that's undocumented a family of client 1782 01:16:22,860 --> 01:16:25,080 IDs is really the work done by secure 1783 01:16:25,080 --> 01:16:29,280 Works about the SSO Microsoft apps and 1784 01:16:29,280 --> 01:16:32,520 their IDs that are treated as SSO and 1785 01:16:32,520 --> 01:16:35,400 therefore at an oauth level can can you 1786 01:16:35,400 --> 01:16:36,120 can 1787 01:16:36,120 --> 01:16:39,780 obtain a new oauth token without any 1788 01:16:39,780 --> 01:16:42,360 further Authentication 1789 01:16:42,360 --> 01:16:45,440 um furthest in the future 1790 01:16:45,440 --> 01:16:47,760 I think it's worth looking at where Pro 1791 01:16:47,760 --> 01:16:49,620 the protocol itself oauth is moving 1792 01:16:49,620 --> 01:16:51,900 where vendor roadmaps are and there are 1793 01:16:51,900 --> 01:16:54,780 moves to you know use hidden secrets or 1794 01:16:54,780 --> 01:16:58,320 keys with pkce those are good 1795 01:16:58,320 --> 01:16:59,760 um will prevent 1796 01:16:59,760 --> 01:17:01,800 um you know attacks that rely on 1797 01:17:01,800 --> 01:17:04,260 interception of traffic 1798 01:17:04,260 --> 01:17:07,260 um depop proof of purchase type systems 1799 01:17:07,260 --> 01:17:10,500 where maybe the hardware in some way is 1800 01:17:10,500 --> 01:17:11,640 signing 1801 01:17:11,640 --> 01:17:13,800 um and and that's sort of similar to 1802 01:17:13,800 --> 01:17:16,380 passwordless systems that's all great in 1803 01:17:16,380 --> 01:17:18,360 case credentials are still on Microsoft 1804 01:17:18,360 --> 01:17:20,820 did a really good RSA presentation 1805 01:17:20,820 --> 01:17:22,980 where they saw a lot of malware doing a 1806 01:17:22,980 --> 01:17:24,659 lot of theft and so there's some 1807 01:17:24,659 --> 01:17:25,920 engineering effort there I think those 1808 01:17:25,920 --> 01:17:27,239 are all great 1809 01:17:27,239 --> 01:17:29,159 and those become further areas for 1810 01:17:29,159 --> 01:17:30,360 research depending on how they're 1811 01:17:30,360 --> 01:17:32,580 implemented uh just to see if there's 1812 01:17:32,580 --> 01:17:34,980 room for abuse to me anytime a wealth is 1813 01:17:34,980 --> 01:17:36,540 used for us so 1814 01:17:36,540 --> 01:17:39,120 easy one it's worth probing um there's a 1815 01:17:39,120 --> 01:17:41,219 lot out there I don't think in general 1816 01:17:41,219 --> 01:17:43,560 it's a good idea it usually introduces 1817 01:17:43,560 --> 01:17:47,780 more risk than benefit but oidc was 1818 01:17:47,780 --> 01:17:50,280 specifically created so auth could be 1819 01:17:50,280 --> 01:17:52,980 used for SSO I just think oauth is way 1820 01:17:52,980 --> 01:17:55,140 more complicated than needed for SSO 1821 01:17:55,140 --> 01:17:59,040 stick to saml if at all possible at 1822 01:17:59,040 --> 01:18:00,540 least the issues that are more contained 1823 01:18:00,540 --> 01:18:03,960 in my mind and the last point is hey 1824 01:18:03,960 --> 01:18:06,420 don't just get hyper focused on fishing 1825 01:18:06,420 --> 01:18:08,880 credential tax escalation privilege 1826 01:18:08,880 --> 01:18:11,159 lateral movement whole attack chain is 1827 01:18:11,159 --> 01:18:13,500 really at play here oauth just becomes 1828 01:18:13,500 --> 01:18:16,739 the pro caller means to look at abuse 1829 01:18:16,739 --> 01:18:20,340 so thank you I appreciate uh you getting 1830 01:18:20,340 --> 01:18:23,280 to the end of a very long presentation I 1831 01:18:23,280 --> 01:18:26,040 hope you got some more ideas or insights 1832 01:18:26,040 --> 01:18:28,020 from either the research perspective or 1833 01:18:28,020 --> 01:18:30,840 the defensive perspective and I hope to 1834 01:18:30,840 --> 01:18:33,300 see all of you at some point in person 1835 01:18:33,300 --> 01:18:35,640 if you need to contact me uh there's my 1836 01:18:35,640 --> 01:18:41,960 contact info I'm also on Mastodon on 1837 01:18:41,960 --> 01:18:45,239 infosec.exchange at jenko thanks very 1838 01:18:45,239 --> 01:18:47,360 much