1 00:00:00,680 --> 00:00:03,520 okay next up we've got Xander Mackey a 2 00:00:03,520 --> 00:00:05,879 father husband and security researcher 3 00:00:05,879 --> 00:00:08,519 who is quote driven by a Relentless need 4 00:00:08,519 --> 00:00:11,280 to figure out how things work which is I 5 00:00:11,280 --> 00:00:12,960 think a trait that many of us uh share 6 00:00:12,960 --> 00:00:16,079 and and can associate with today Xander 7 00:00:16,079 --> 00:00:17,840 is going to be exploring as your policy 8 00:00:17,840 --> 00:00:19,359 service and how it can be used for 9 00:00:19,359 --> 00:00:21,760 Badness the title of his talk is who 10 00:00:21,760 --> 00:00:23,920 policies who polices oh it's a tongue 11 00:00:23,920 --> 00:00:26,560 twister who Poli your policies please 12 00:00:26,560 --> 00:00:30,400 give a warm welcome presid 13 00:00:32,119 --> 00:00:34,360 um hey everyone thanks for coming it's a 14 00:00:34,360 --> 00:00:36,559 real pleasure to be here a real honor um 15 00:00:36,559 --> 00:00:39,040 I want to thank the organizers and I 16 00:00:39,040 --> 00:00:42,800 also want to thank Nick frett and Katie 17 00:00:42,800 --> 00:00:44,879 nolles and Zach Allen who are colleagues 18 00:00:44,879 --> 00:00:47,000 of mine who supported me and doing a lot 19 00:00:47,000 --> 00:00:48,280 of This research and gave me some good 20 00:00:48,280 --> 00:00:53,320 mentorship so um okay so quick agenda 21 00:00:53,320 --> 00:00:55,120 we're going to talk about what the Azure 22 00:00:55,120 --> 00:00:57,320 policy service is and then we're going 23 00:00:57,320 --> 00:01:00,239 to talk about how you can abuse with 24 00:01:00,239 --> 00:01:02,280 something called an effect and then how 25 00:01:02,280 --> 00:01:04,199 you can escalate your privileges using 26 00:01:04,199 --> 00:01:06,000 this 27 00:01:06,000 --> 00:01:08,400 service um if you want to leave this is 28 00:01:08,400 --> 00:01:10,080 basically the talk right here 29 00:01:10,080 --> 00:01:12,159 [Music] 30 00:01:12,159 --> 00:01:14,400 um okay 31 00:01:14,400 --> 00:01:16,799 so before I go further I should say that 32 00:01:16,799 --> 00:01:18,479 like this isn't something I invented 33 00:01:18,479 --> 00:01:20,439 like this is actually in the Microsoft 34 00:01:20,439 --> 00:01:24,360 um threat Matrix um but as you can see 35 00:01:24,360 --> 00:01:26,360 there's not a lot of detail it sort of 36 00:01:26,360 --> 00:01:29,119 just says okay stuff can happen if you 37 00:01:29,119 --> 00:01:31,720 mess around with a service and I I 38 00:01:31,720 --> 00:01:33,920 actually only discovered this after I 39 00:01:33,920 --> 00:01:35,840 had done all the research someone 40 00:01:35,840 --> 00:01:36,840 pointed out to me you should probably 41 00:01:36,840 --> 00:01:40,560 check Microsoft first do that but um 42 00:01:40,560 --> 00:01:42,399 what the value I think I bring here is 43 00:01:42,399 --> 00:01:43,600 that I'm I'm sort of filling out the 44 00:01:43,600 --> 00:01:44,719 picture here because this is really 45 00:01:44,719 --> 00:01:46,840 opaque it's like you don't know what the 46 00:01:46,840 --> 00:01:48,479 service is or what you can do with it 47 00:01:48,479 --> 00:01:50,799 this doesn't really tell you very 48 00:01:50,799 --> 00:01:54,520 much okay so um what is the aop policy 49 00:01:54,520 --> 00:01:57,479 service has anyone use this 50 00:01:57,479 --> 00:02:01,799 service yeah sorry guys 51 00:02:01,799 --> 00:02:04,759 yeah um okay so basically it is a 52 00:02:04,759 --> 00:02:06,200 compliance 53 00:02:06,200 --> 00:02:09,520 service um that can also do 54 00:02:09,520 --> 00:02:13,080 remediation so sounds kind of boring 55 00:02:13,080 --> 00:02:16,040 right compliance is you know everyone's 56 00:02:16,040 --> 00:02:19,599 favorite thing um no not mine um the 57 00:02:19,599 --> 00:02:21,440 remediation part is the part that caught 58 00:02:21,440 --> 00:02:24,599 my attention and why I sort of dug 59 00:02:24,599 --> 00:02:27,239 further um so at a high level the 60 00:02:27,239 --> 00:02:29,440 components of this service are a policy 61 00:02:29,440 --> 00:02:30,640 definition 62 00:02:30,640 --> 00:02:32,560 which is basically the conditions for 63 00:02:32,560 --> 00:02:36,000 validating a resource does it comply 64 00:02:36,000 --> 00:02:38,160 with these conditions and if it doesn't 65 00:02:38,160 --> 00:02:40,440 what do we do if this if this 66 00:02:40,440 --> 00:02:42,959 non-compliance happens um then there's a 67 00:02:42,959 --> 00:02:45,080 policy assignment which is when you 68 00:02:45,080 --> 00:02:48,120 attach a definition to a scope a scope 69 00:02:48,120 --> 00:02:49,840 is sort of a thing in Azure where you 70 00:02:49,840 --> 00:02:52,239 can it's like a a resource boundary sort 71 00:02:52,239 --> 00:02:56,360 of um and in order for policies to cause 72 00:02:56,360 --> 00:02:59,000 things to happen they need what's called 73 00:02:59,000 --> 00:03:00,560 a managed identity 74 00:03:00,560 --> 00:03:02,120 which has a role managed identity if 75 00:03:02,120 --> 00:03:04,760 you're not familiar with it in Azure is 76 00:03:04,760 --> 00:03:06,640 basically like a service 77 00:03:06,640 --> 00:03:09,680 account um and then there's another 78 00:03:09,680 --> 00:03:11,280 thing called a policy initiative which 79 00:03:11,280 --> 00:03:14,440 is a bunch of policy definitions um and 80 00:03:14,440 --> 00:03:16,640 that might be expressing something like 81 00:03:16,640 --> 00:03:19,280 you know Hippa or the CIS framework or 82 00:03:19,280 --> 00:03:20,720 whatever 83 00:03:20,720 --> 00:03:24,640 like yeah so a definition looks like 84 00:03:24,640 --> 00:03:26,360 this um they're actually written in Json 85 00:03:26,360 --> 00:03:28,239 but I put it in yaml because it's easier 86 00:03:28,239 --> 00:03:31,200 to read I think the you know they we 87 00:03:31,200 --> 00:03:33,040 have the parameters that you can 88 00:03:33,040 --> 00:03:34,560 parameterize it but then the policy rule 89 00:03:34,560 --> 00:03:37,360 is the me the meat of it um you have 90 00:03:37,360 --> 00:03:40,080 this if right if something is out of 91 00:03:40,080 --> 00:03:43,200 compliance then do X it's pretty 92 00:03:43,200 --> 00:03:45,400 self-explanatory so this is an example 93 00:03:45,400 --> 00:03:49,159 of one um this one is just saying okay 94 00:03:49,159 --> 00:03:51,959 if the the resources don't have the 95 00:03:51,959 --> 00:03:54,720 department tag deny and what that deny 96 00:03:54,720 --> 00:03:56,400 does is it doesn't let you make that 97 00:03:56,400 --> 00:03:58,640 resource um so this is happening in the 98 00:03:58,640 --> 00:04:00,490 loop of resource 99 00:04:00,490 --> 00:04:02,280 [Music] 100 00:04:02,280 --> 00:04:05,280 creation um this is a sort of confusing 101 00:04:05,280 --> 00:04:06,959 diagram but roughly speaking these are 102 00:04:06,959 --> 00:04:08,480 these are how all these things fit 103 00:04:08,480 --> 00:04:11,040 together um you know the policy 104 00:04:11,040 --> 00:04:13,040 definition on the bottom left is 105 00:04:13,040 --> 00:04:15,360 assigned it might get a managed identity 106 00:04:15,360 --> 00:04:17,440 top left and the managed identity would 107 00:04:17,440 --> 00:04:19,639 have a role assigned to it and then if 108 00:04:19,639 --> 00:04:22,000 you have a bunch of policy definitions 109 00:04:22,000 --> 00:04:23,400 um you have an 110 00:04:23,400 --> 00:04:25,840 initiative okay so yeah what do you do 111 00:04:25,840 --> 00:04:27,960 with it okay you can audit stuff like 112 00:04:27,960 --> 00:04:29,720 you can have it in this auditing thing 113 00:04:29,720 --> 00:04:31,400 or just can tell you okay this stuff is 114 00:04:31,400 --> 00:04:33,680 non compliant you can deny things like I 115 00:04:33,680 --> 00:04:35,840 mentioned uh which doesn't let you build 116 00:04:35,840 --> 00:04:37,000 the 117 00:04:37,000 --> 00:04:40,600 resources and um Microsoft packages a 118 00:04:40,600 --> 00:04:42,240 lot of their kind of security guidance 119 00:04:42,240 --> 00:04:43,919 in the form of policy initiatives and 120 00:04:43,919 --> 00:04:46,840 they also provide a lot of built in 121 00:04:46,840 --> 00:04:48,520 compliance Frameworks in the form of 122 00:04:48,520 --> 00:04:50,520 initiatives so if you are doing 123 00:04:50,520 --> 00:04:52,360 compliance in Azure it's a really useful 124 00:04:52,360 --> 00:04:55,320 service actually um there's a lot of a 125 00:04:55,320 --> 00:04:56,400 lot of power and there's a lot of 126 00:04:56,400 --> 00:04:59,880 pre-made stuff there for you to lean on 127 00:04:59,880 --> 00:05:02,199 um but you know that's not why we're 128 00:05:02,199 --> 00:05:03,919 here to talk about compliance there's 129 00:05:03,919 --> 00:05:07,479 more more fun stuff um you can yeah you 130 00:05:07,479 --> 00:05:11,600 can misuse it so there's this this piece 131 00:05:11,600 --> 00:05:14,280 of a policy definition called an effect 132 00:05:14,280 --> 00:05:18,160 which lets you do things like append 133 00:05:18,160 --> 00:05:20,880 data to your deployment 134 00:05:20,880 --> 00:05:24,400 configuration um you can also modify 135 00:05:24,400 --> 00:05:26,600 that deployment configuration and it can 136 00:05:26,600 --> 00:05:29,240 deploy other resources as a side effect 137 00:05:29,240 --> 00:05:30,240 of that 138 00:05:30,240 --> 00:05:32,319 and this is all like if a resource isn't 139 00:05:32,319 --> 00:05:34,440 compliant oh by the way I want you to 140 00:05:34,440 --> 00:05:36,080 you know deploy a database I don't know 141 00:05:36,080 --> 00:05:37,880 why you would need to do that but you 142 00:05:37,880 --> 00:05:41,759 know um and then at the end yeah we'll 143 00:05:41,759 --> 00:05:43,479 talk about how you can use these things 144 00:05:43,479 --> 00:05:45,880 to effectively escalate your 145 00:05:45,880 --> 00:05:47,840 privileges so 146 00:05:47,840 --> 00:05:51,120 okay um these are some of the things you 147 00:05:51,120 --> 00:05:53,840 can do with these effects right you can 148 00:05:53,840 --> 00:05:57,639 append things like SSH keys to a VM um 149 00:05:57,639 --> 00:06:00,280 you can create back doors in BMS you can 150 00:06:00,280 --> 00:06:03,120 assign roles um through this 151 00:06:03,120 --> 00:06:06,919 service um so this append action is 152 00:06:06,919 --> 00:06:08,840 actually pretty interesting because it 153 00:06:08,840 --> 00:06:10,919 it even though it's doing this stuff 154 00:06:10,919 --> 00:06:13,240 even though it's modifying state it does 155 00:06:13,240 --> 00:06:15,599 not require a role so in other words it 156 00:06:15,599 --> 00:06:18,759 doesn't require any permissions um and 157 00:06:18,759 --> 00:06:20,520 this is how you find all the properties 158 00:06:20,520 --> 00:06:23,039 that are modifiable via a pend and 159 00:06:23,039 --> 00:06:26,280 there's a lot and um Microsoft does take 160 00:06:26,280 --> 00:06:28,080 requests on their GitHub so if you want 161 00:06:28,080 --> 00:06:30,800 more stuff to screw around with you can 162 00:06:30,800 --> 00:06:34,120 can ask them um okay so this would be an 163 00:06:34,120 --> 00:06:37,280 aen policy basically this is saying um 164 00:06:37,280 --> 00:06:39,919 if these things on the top basically if 165 00:06:39,919 --> 00:06:42,120 it if these tags exist on this virtual 166 00:06:42,120 --> 00:06:46,960 machine append my SSH key to the public 167 00:06:46,960 --> 00:06:50,039 keys of this 168 00:06:50,639 --> 00:06:55,080 VM this one is opening an Ackle in a 169 00:06:55,080 --> 00:06:58,400 network security group um you know 170 00:06:58,400 --> 00:06:59,879 someone deploys something and locked 171 00:06:59,879 --> 00:07:01,280 down but you don't want it to be locked 172 00:07:01,280 --> 00:07:02,900 down you can just punch a hole in 173 00:07:02,900 --> 00:07:04,319 [Music] 174 00:07:04,319 --> 00:07:07,039 it um this one is the what I mentioned 175 00:07:07,039 --> 00:07:09,000 the adding stuff that deploy if not 176 00:07:09,000 --> 00:07:13,080 exists um so Microsoft's VMS have this 177 00:07:13,080 --> 00:07:15,960 thing called a VM extension and one of 178 00:07:15,960 --> 00:07:20,160 them is basically arbitrary code know 179 00:07:20,160 --> 00:07:24,800 bash shell so you can um put in commands 180 00:07:24,800 --> 00:07:29,280 to execute when the machine boots up 181 00:07:30,240 --> 00:07:32,360 um and here's another one it'll just 182 00:07:32,360 --> 00:07:35,280 make every blob storage account that you 183 00:07:35,280 --> 00:07:37,319 have that you're trying to make private 184 00:07:37,319 --> 00:07:39,800 it'll just make them all 185 00:07:39,800 --> 00:07:41,800 public so yeah there's a lot of stuff 186 00:07:41,800 --> 00:07:43,319 you can do if you want to you know kind 187 00:07:43,319 --> 00:07:44,960 of break this 188 00:07:44,960 --> 00:07:46,919 service 189 00:07:46,919 --> 00:07:49,400 um so you know that's some of some of 190 00:07:49,400 --> 00:07:51,199 the bad stuff you can do what what is 191 00:07:51,199 --> 00:07:54,039 this privilege escalation thing I talked 192 00:07:54,039 --> 00:07:58,319 about um okay so the the role that has 193 00:07:58,319 --> 00:08:00,000 the ability to create 194 00:08:00,000 --> 00:08:02,000 and modify these these policy 195 00:08:02,000 --> 00:08:04,280 definitions is called resource policy 196 00:08:04,280 --> 00:08:07,800 contributor um that that Ro is not 197 00:08:07,800 --> 00:08:10,759 allowed to assign roles it's not allowed 198 00:08:10,759 --> 00:08:12,319 to do you know identity and 199 00:08:12,319 --> 00:08:13,720 permissioning it's only allowed to 200 00:08:13,720 --> 00:08:17,039 create these policies um user access 201 00:08:17,039 --> 00:08:18,639 admin or contributor these people can 202 00:08:18,639 --> 00:08:22,199 bind identities and roles so let's say 203 00:08:22,199 --> 00:08:25,199 Bob just has resource policy contributor 204 00:08:25,199 --> 00:08:28,000 that means he can't uh he can't escalate 205 00:08:28,000 --> 00:08:30,479 his privileges himself he can't change 206 00:08:30,479 --> 00:08:32,760 his permissions himself Alice would be 207 00:08:32,760 --> 00:08:33,919 able to do 208 00:08:33,919 --> 00:08:37,120 that but okay sorry this is getting a 209 00:08:37,120 --> 00:08:40,958 little Tangled here um okay so sorry for 210 00:08:40,958 --> 00:08:43,599 the diagram here so let's say Alice 211 00:08:43,599 --> 00:08:45,680 initially creates a policy 212 00:08:45,680 --> 00:08:48,160 definition um binds 213 00:08:48,160 --> 00:08:52,360 it adds a managed identity and then that 214 00:08:52,360 --> 00:08:54,680 managed identity is able to do things 215 00:08:54,680 --> 00:08:57,480 via the policy um and say that managed 216 00:08:57,480 --> 00:09:00,480 identity has very high privileges 217 00:09:00,480 --> 00:09:03,880 in the case of Bob who can't do anything 218 00:09:03,880 --> 00:09:07,040 with identities Bob who's able to M 219 00:09:07,040 --> 00:09:09,880 who's able to modify policies can alter 220 00:09:09,880 --> 00:09:11,880 the definition the thing that was 221 00:09:11,880 --> 00:09:14,079 originally used to create the assignment 222 00:09:14,079 --> 00:09:16,399 and that will modify all of the 223 00:09:16,399 --> 00:09:18,040 assignments so he can modify the 224 00:09:18,040 --> 00:09:19,720 underlying resource and it'll do 225 00:09:19,720 --> 00:09:21,240 entirely new 226 00:09:21,240 --> 00:09:24,519 things um at the level of the initiative 227 00:09:24,519 --> 00:09:27,640 you can even get more tricky because 228 00:09:27,640 --> 00:09:30,399 initiatives remember are aable policy 229 00:09:30,399 --> 00:09:34,160 definitions um and you could all of 230 00:09:34,160 --> 00:09:36,040 those you know bad policies I showed you 231 00:09:36,040 --> 00:09:37,720 before you could add them on to an 232 00:09:37,720 --> 00:09:39,800 existing initiative even if you didn't 233 00:09:39,800 --> 00:09:42,399 have the ability to create any of the 234 00:09:42,399 --> 00:09:44,519 role assignments um and if that 235 00:09:44,519 --> 00:09:47,320 initiative had highly privileged roles 236 00:09:47,320 --> 00:09:49,880 well you've just gotten all of its 237 00:09:49,880 --> 00:09:52,680 permissions now um according to 238 00:09:52,680 --> 00:09:54,040 Microsoft this isn't really privilege 239 00:09:54,040 --> 00:09:55,720 escalation it's like intended to do that 240 00:09:55,720 --> 00:09:57,480 which is yeah it's ARG it's arguable 241 00:09:57,480 --> 00:10:00,640 it's true um but I just thought it was 242 00:10:00,640 --> 00:10:03,000 interesting that a role that seems so 243 00:10:03,000 --> 00:10:04,920 anod you know like resource policy 244 00:10:04,920 --> 00:10:06,839 comper who's going to be auditing that 245 00:10:06,839 --> 00:10:09,440 person well it turns out they can really 246 00:10:09,440 --> 00:10:11,000 wreak a lot of Havoc if if you get a 247 00:10:11,000 --> 00:10:13,640 hold of that um 248 00:10:13,640 --> 00:10:16,600 so yeah this is the Azure policy service 249 00:10:16,600 --> 00:10:18,240 it's used for compliance you can abuse 250 00:10:18,240 --> 00:10:20,480 it for almost anything and you can 251 00:10:20,480 --> 00:10:23,800 escalate your privileges with it um I 252 00:10:23,800 --> 00:10:27,560 have a little more time so I'm going to 253 00:10:27,560 --> 00:10:31,120 show you this this is yeah the Olympics 254 00:10:31,120 --> 00:10:32,440 are going on I'm going to tell you a 255 00:10:32,440 --> 00:10:35,040 little bit about the backstory of how I 256 00:10:35,040 --> 00:10:37,440 did how this you know came about 257 00:10:37,440 --> 00:10:40,440 basically um so yeah I work at data dog 258 00:10:40,440 --> 00:10:41,800 and one of our Cloud security 259 00:10:41,800 --> 00:10:43,160 researchers Nick forette who I don't 260 00:10:43,160 --> 00:10:44,360 know if you know him or not you probably 261 00:10:44,360 --> 00:10:47,440 do he sort of sponsored a like a hack 262 00:10:47,440 --> 00:10:50,160 week at work like okay let's go try to 263 00:10:50,160 --> 00:10:51,760 break some cloud services and you know 264 00:10:51,760 --> 00:10:53,079 I'd never really done anything like that 265 00:10:53,079 --> 00:10:54,760 before and you know I was like well what 266 00:10:54,760 --> 00:10:56,200 do I do you know do I have to do all 267 00:10:56,200 --> 00:10:59,519 this crazy stuff I'm not a pentester and 268 00:10:59,519 --> 00:11:01,959 he was like well just just go read the 269 00:11:01,959 --> 00:11:05,600 docs like you know for the thing um so I 270 00:11:05,600 --> 00:11:08,120 spent five days you know reading docs 271 00:11:08,120 --> 00:11:09,639 for the service and playing around with 272 00:11:09,639 --> 00:11:12,480 it and on the fifth day I was like wait 273 00:11:12,480 --> 00:11:14,839 a second you're telling me that this 274 00:11:14,839 --> 00:11:17,639 compliance framework thing can can alter 275 00:11:17,639 --> 00:11:20,600 resources it's basically like a cspm 276 00:11:20,600 --> 00:11:22,079 that with remediation and you know it 277 00:11:22,079 --> 00:11:24,600 sort of has like terraform built into it 278 00:11:24,600 --> 00:11:26,440 um that wasn't really on the tin that's 279 00:11:26,440 --> 00:11:28,720 kind of weird you know so then I started 280 00:11:28,720 --> 00:11:30,120 playing around with with it for three or 281 00:11:30,120 --> 00:11:32,920 four more months and you know trying to 282 00:11:32,920 --> 00:11:34,440 understand the intended use of the 283 00:11:34,440 --> 00:11:36,720 service but then also what would happen 284 00:11:36,720 --> 00:11:38,880 if I got a hold of these permissions 285 00:11:38,880 --> 00:11:42,120 these roles and um I wanted to do bad 286 00:11:42,120 --> 00:11:44,720 stuff so you know the moral of the story 287 00:11:44,720 --> 00:11:47,560 here is like you too can do cool 288 00:11:47,560 --> 00:11:51,880 research um just read the docs 289 00:11:51,880 --> 00:11:55,900 so um that was a short talk um any 290 00:11:55,900 --> 00:11:57,959 [Music] 291 00:11:57,959 --> 00:12:01,239 questions yeah 292 00:12:03,800 --> 00:12:08,240 uh sorry I'm super deaf asking if slides 293 00:12:08,240 --> 00:12:10,079 are being released oh yeah definitely 294 00:12:10,079 --> 00:12:11,079 yeah yeah can you repeat the question 295 00:12:11,079 --> 00:12:12,519 for the slides are being released that 296 00:12:12,519 --> 00:12:13,560 was the question are the slides being 297 00:12:13,560 --> 00:12:15,760 released yes and I also wrote uh a blog 298 00:12:15,760 --> 00:12:17,240 post about this on the data dog security 299 00:12:17,240 --> 00:12:18,680 blog I didn't put a link on here 300 00:12:18,680 --> 00:12:21,079 stupidly but it's up on our blog um so 301 00:12:21,079 --> 00:12:22,160 if you want to read about a little more 302 00:12:22,160 --> 00:12:24,880 of the details including stuff about 303 00:12:24,880 --> 00:12:26,639 what you might do as a Defender to sort 304 00:12:26,639 --> 00:12:28,120 of audit for this and what events you 305 00:12:28,120 --> 00:12:30,639 want to care about and Vlogs um for the 306 00:12:30,639 --> 00:12:31,720 stuff 307 00:12:31,720 --> 00:12:34,800 so um any more 308 00:12:34,800 --> 00:12:37,960 questions sweet thanks 309 00:12:37,960 --> 00:12:42,920 [Applause] 310 00:12:42,920 --> 00:12:46,719 everyone thank you thank 311 00:12:47,000 --> 00:12:49,079 you all right thanks Andrew we're going 312 00:12:49,079 --> 00:12:53,680 to um that point the line as usual