1 00:00:00,720 --> 00:00:01,880 Yeah, yeah, yeah. 2 00:00:01,880 --> 00:00:02,860 What's up? 3 00:00:03,240 --> 00:00:04,280 Good to go? 4 00:00:04,500 --> 00:00:05,260 Okay. 5 00:00:06,120 --> 00:00:08,080 So, hi everybody. 6 00:00:08,340 --> 00:00:16,860 Today's talk is called Ohm IDC, where we're going to learn and see how we can abuse IDC set ups in the context of CI. 7 00:00:17,760 --> 00:00:19,700 This is extremely exciting for me. 8 00:00:19,700 --> 00:00:24,380 That's my first time speaking in the con, so thank you very much for showing up. 9 00:00:24,440 --> 00:00:26,940 And thank you very much for having me. 10 00:00:27,240 --> 00:00:29,700 That was the first voice breakdown, so it's fine. 11 00:00:30,300 --> 00:00:33,880 Okay, by the way, if Adnan and John are here, thank you for the build up. 12 00:00:33,880 --> 00:00:36,400 I hope I'll satisfy that. 13 00:00:37,400 --> 00:00:39,480 So, I'll present myself. 14 00:00:39,480 --> 00:00:40,660 My name is Aviad Hachami. 15 00:00:40,660 --> 00:00:42,540 This is my Twitter handler. 16 00:00:42,700 --> 00:00:45,280 I do security research at Palo Alto. 17 00:00:45,720 --> 00:00:47,980 I do CI domain mainly. 18 00:00:48,260 --> 00:00:50,640 I welcome you to check my latest publication. 19 00:00:50,820 --> 00:00:56,800 This is Azure CLI information leakage with 8.6 core somehow. 20 00:00:56,980 --> 00:01:00,380 But it probably affected all your ASG usages. 21 00:01:00,580 --> 00:01:05,060 I also do bug bounty, I DJ, I do graph theory, and FPV drones. 22 00:01:05,060 --> 00:01:06,620 Not necessarily in this order. 23 00:01:08,260 --> 00:01:08,960 Okay. 24 00:01:09,780 --> 00:01:14,140 So, before we go into the agenda, I want to try and convince you why you should listen. 25 00:01:15,620 --> 00:01:30,560 So, first thing first, if you are completely new to this world or you have like a rough idea of what OIDC is, I hope you get today the full context of what's up with that, what's up internally, and how does it play. 26 00:01:31,160 --> 00:01:35,400 If you're already a user , I hope you're going to learn some pitfalls and misconfiguration. 27 00:01:35,540 --> 00:01:37,760 I hope I'm going to save you some weekends. 28 00:01:38,120 --> 00:01:44,380 And if you're a bounty hunter, like most of us here, I hope you're going to get some new ideas for exploitation. 29 00:01:45,940 --> 00:01:46,840 All right. 30 00:01:47,240 --> 00:01:52,640 So, with that, let's go into the overview. 31 00:01:52,800 --> 00:01:53,080 Okay. 32 00:01:53,080 --> 00:01:57,120 For those of you who are familiar with this topic, hold on tight for a sec. 33 00:01:57,580 --> 00:02:01,060 After this, we're going to move into no configs. 34 00:02:01,060 --> 00:02:04,360 This is just a word term I set up. 35 00:02:04,600 --> 00:02:07,700 I'm going to explain about it soon enough. 36 00:02:07,700 --> 00:02:19,420 We're going to move into advanced configurations, misconfigurations, and we're going to learn what happens when the CI vendor makes a misconfig and why do we care about the CI vendor in that context. 37 00:02:20,280 --> 00:02:21,360 All right. 38 00:02:21,360 --> 00:02:24,920 So, first things first, let's begin with an OIDC overview. 39 00:02:25,400 --> 00:02:42,420 So, when I actually rehearsed this talk to some of my friends, some of them are good researchers, I used terms like workflow, job, the CI config, et cetera, et cetera, and they said at some point, this is nice, but I'm not sure how CI works. 40 00:02:42,420 --> 00:02:51,100 So, in the case you're like my friend and you slept under a rock for the past ten years, I'm going to show you what CI is in one slide so we can move on. 41 00:02:52,320 --> 00:02:54,240 So, extremely quickly, what is CI? 42 00:02:54,240 --> 00:03:06,820 Assuming you're a developer, you perform some Git operation, maybe push, pull requests, et cetera, this was pushed to your VCS provider, GitHub, GitLab, you name it, and it was reflected in your online repository. 43 00:03:06,820 --> 00:03:07,600 So far, so good. 44 00:03:07,600 --> 00:03:20,280 Now, since you've configured your CI provider, because this is what we care about, then the VCS provider notified the OCI provider that something happened using a web hook with payload, nothing special here. 45 00:03:20,660 --> 00:03:28,980 In turn, the CI provider spinned a machine for you, it can be any OS according to your configuration, aka workflow. 46 00:03:30,120 --> 00:03:32,300 These machines do whatever you want. 47 00:03:32,300 --> 00:03:39,220 It can be lints, builds, compilations, and since we're in 2024, they also push to your cloud environments. 48 00:03:39,220 --> 00:03:43,980 It can be GCP, AWS, Docker Hub, basically everything out there. 49 00:03:44,630 --> 00:03:46,260 This is CI, welcome. 50 00:03:46,720 --> 00:03:50,380 So, something I want to emphasize is that those are all split entities, okay? 51 00:03:50,380 --> 00:03:56,480 We're going to come into that later on, we're going to show this diagram again, but I want you to remember that these are split entities. 52 00:03:57,120 --> 00:03:57,780 Cool. 53 00:03:57,880 --> 00:04:02,320 Our problem space is this small arrow, welcome to the OIDC and CI niche. 54 00:04:02,320 --> 00:04:11,400 This small arrow, which basically makes us ask an important question, we're in a machine-to-machine world, so how does authentication happen, right? 55 00:04:11,400 --> 00:04:14,060 How can we access Docker Hub, for example? 56 00:04:15,920 --> 00:04:18,940 An easy answer, right, will be to hard-code your secrets. 57 00:04:18,940 --> 00:04:21,600 This is great for my bug bounty, please do that. 58 00:04:22,020 --> 00:04:23,840 But, yeah, continue. 59 00:04:23,980 --> 00:04:25,860 The second option will be secrets, right? 60 00:04:25,860 --> 00:04:28,380 This is a feature by the CI providers, etc. 61 00:04:28,560 --> 00:04:31,900 But we all know that at some point or another it's going to leak, right? 62 00:04:31,900 --> 00:04:37,100 We're going to see some article saying company whatever was leaked was breached because of a leakage. 63 00:04:37,760 --> 00:04:39,840 So we don't want to do that anymore. 64 00:04:40,940 --> 00:04:43,180 And then OIDC comes in to help. 65 00:04:43,180 --> 00:04:52,400 So OIDC is open identity, this is initials for open identity, something I forgot because I'm stressed obviously, but that's fine. 66 00:04:52,400 --> 00:04:55,880 But what I want to emphasize is that it's a simple OAuth extension. 67 00:04:55,880 --> 00:04:59,000 I believe most of you know what OAuth is at this point in time. 68 00:04:59,000 --> 00:05:03,640 If you're on YouTube and you're not familiar with, pause now, go learn OAuth, come back. 69 00:05:04,140 --> 00:05:05,960 Yeah, it's the basics. 70 00:05:05,960 --> 00:05:15,140 So OIDC comes in to help and going to help us solve this whole credentials problem and it's going to allow us to use something called identities that we're going to see in a second. 71 00:05:15,740 --> 00:05:17,740 So what is this OIDC flow? 72 00:05:17,740 --> 00:05:21,600 We're going to learn the vanilla version and then the CI version because they're a bit different. 73 00:05:21,740 --> 00:05:24,040 This is just a slide taken from Microsoft. 74 00:05:24,440 --> 00:05:31,500 You are all familiar with the try to log in, go to the identity provider, get like the token, come back, exchange it. 75 00:05:31,500 --> 00:05:33,380 But now we see something different. 76 00:05:33,380 --> 00:05:37,560 Instead of access token and refresh token, we're relying on something called ID token. 77 00:05:37,560 --> 00:05:38,320 Welcome. 78 00:05:38,700 --> 00:05:44,120 So we're going to learn what ID tokens are in a second, but I just want to plug in some terminology. 79 00:05:44,260 --> 00:05:48,260 This is the auth n part, the authentication where you actually put credentials. 80 00:05:48,660 --> 00:05:53,920 And this is the auth z part where you actually authorize someone to access something. 81 00:05:53,920 --> 00:05:58,680 Regardless of their authentication state, obviously they should be authenticated by this point in time. 82 00:05:59,820 --> 00:06:01,560 So ID tokens. 83 00:06:01,980 --> 00:06:10,260 Standard JWTs, base 64, we're going to decode them and we're going to get the header which we don't care about for the sake of this talk. 84 00:06:10,260 --> 00:06:17,440 I'll just add that this is how you verify the integrity of an incoming ID token, but I'm not going to touch this any further. 85 00:06:17,700 --> 00:06:18,820 Don't care symbol. 86 00:06:19,300 --> 00:06:34,080 And the second part is the actually ID token body and we're going to dive into the contents of it in a sec, but for the purpose of this slide, I want you to remember that ID tokens, the body of it is a simple dictionary where each key is called claim. 87 00:06:34,080 --> 00:06:37,280 So now onwards I'm going to say the token claims something. 88 00:06:37,280 --> 00:06:37,800 Okay? 89 00:06:38,040 --> 00:06:38,760 Good. 90 00:06:39,480 --> 00:06:42,740 So let's conclude the OIDC in the vanilla version of it . 91 00:06:42,780 --> 00:06:47,960 It's an OAuth extension and it allows us to rely on short-lived tokens that are based on identity. 92 00:06:47,960 --> 00:06:48,480 That's it. 93 00:06:48,480 --> 00:06:50,700 TLDR of the whole magic. 94 00:06:51,180 --> 00:06:51,620 Right. 95 00:06:51,620 --> 00:06:53,620 So let's put it in the context of CICD. 96 00:06:54,460 --> 00:07:01,940 If I'm bringing back this small snippet here, right, and I told you this is our problem space, we have two important questions now. 97 00:07:01,940 --> 00:07:03,740 First, this is a machine. 98 00:07:03,740 --> 00:07:04,740 How does it authenticate? 99 00:07:04,740 --> 00:07:06,880 We no longer have credentials. 100 00:07:06,880 --> 00:07:08,200 So how do we log in? 101 00:07:08,840 --> 00:07:13,220 Second question is, assuming this ID token, how do we verify it? 102 00:07:13,220 --> 00:07:15,860 What do we verify it and who does this for us? 103 00:07:15,860 --> 00:07:16,460 Okay? 104 00:07:16,920 --> 00:07:18,780 So let's address these questions. 105 00:07:19,440 --> 00:07:23,040 This is the diagram that you all saw like a few slides ago. 106 00:07:23,260 --> 00:07:26,120 And if I'm going to call her back, who's in charge of what? 107 00:07:26,120 --> 00:07:32,100 And we see that the only entity that is in charge of the CI machine is the CI provider. 108 00:07:32,160 --> 00:07:32,600 Right? 109 00:07:33,760 --> 00:07:40,400 So what actually happens behind the scene, and again I'm going to pop up this question, how do we get the credentials? 110 00:07:41,160 --> 00:07:45,440 The CI provider reacts in accordance to our configuration. 111 00:07:45,440 --> 00:07:46,000 Right? 112 00:07:46,020 --> 00:07:50,060 And when we were configured, we were authenticated to the CI provider. 113 00:07:50,120 --> 00:07:55,220 So in a sense you can say that when a CI executes, the machine runs on our behalf. 114 00:07:55,420 --> 00:07:57,800 Hence, it's associated with our identity. 115 00:07:57,860 --> 00:07:59,820 And this is important to remember. 116 00:07:59,820 --> 00:08:04,760 A CI invocation is in the context of the owner of the CI integration. 117 00:08:05,080 --> 00:08:10,300 So in the context of CICD, the CI vendor also gets to be the identity provider. 118 00:08:10,300 --> 00:08:13,440 It's the only one that can give this machine who it is. 119 00:08:13,500 --> 00:08:13,800 Okay? 120 00:08:13,800 --> 00:08:15,420 Otherwise it's just an ephemeral machine, right? 121 00:08:15,420 --> 00:08:16,360 Nobody knows what it is. 122 00:08:16,360 --> 00:08:18,420 Like why should I give you access to something? 123 00:08:18,820 --> 00:08:21,340 So this is the first question answered. 124 00:08:22,140 --> 00:08:28,380 Now the second question was, assuming I do have this ID token, who authorizes this and how exactly? 125 00:08:28,980 --> 00:08:32,300 So, I'm going to close the global protect. 126 00:08:32,500 --> 00:08:39,760 So, um, I'm going to bring back this ID token and this, the auth Z part is actually composed of 2 components. 127 00:08:39,760 --> 00:08:45,440 The first is the ID token and this is an example ID token that is shipped by, uh, GitHub's identity provider. 128 00:08:45,440 --> 00:08:47,980 Most of these, uh, examples are going to be on GitHub. 129 00:08:47,980 --> 00:08:49,420 I really like you folks. 130 00:08:49,600 --> 00:08:56,880 Um, so, and if you look at the contents, you see various claims like, uh, the git sha, the repository name, run ID, et cetera, et cetera. 131 00:08:56,880 --> 00:08:58,780 So that's, like, claims. 132 00:08:58,980 --> 00:09:03,380 And the most important for us to remember is, to note, sorry, is the sub. 133 00:09:03,380 --> 00:09:04,820 Sub short for subject. 134 00:09:04,840 --> 00:09:07,080 And this is the default property to assert. 135 00:09:07,200 --> 00:09:14,360 When the, uh, basically when we check those claims, it's called assertion, um, and this is the default property to assert. 136 00:09:14,700 --> 00:09:19,460 Now, if we actually dissect this for a second, we know the following. 137 00:09:19,460 --> 00:09:24,960 The repo, short for repository, contains the value of the repository claim, okay? 138 00:09:24,960 --> 00:09:31,400 And the ref, right, the ref prefix contains the value of the git ref coming from the ref claim. 139 00:09:31,400 --> 00:09:36,760 So, we can actually see that there's a format behind the scenes and we're going to come back to that later on. 140 00:09:37,380 --> 00:09:47,100 So, an ID token, in the context of CI, I'm going to summarize that, contains information about the git event that triggered the pipeline, uh, alongside other vendor information. 141 00:09:47,100 --> 00:09:52,080 And we're going to see later on what this other vendor information, where exactly does it bite us. 142 00:09:53,020 --> 00:09:58,540 The second part, the second component of the AuthZ, is the something called identity federation. 143 00:09:58,540 --> 00:10:02,300 As the name implies, it, uh, it federates identities coming in. 144 00:10:02,300 --> 00:10:07,020 Um, this is an example configuration, uh, for AWS specifically. 145 00:10:07,140 --> 00:10:09,040 And the file is pretty simple. 146 00:10:09,140 --> 00:10:14,740 Um, you have the identity name, just a string, the identity provider, this is usually the URL of it. 147 00:10:14,740 --> 00:10:19,220 Um, and then you set up conditions for who can claim to be this identity. 148 00:10:19,540 --> 00:10:22,920 Um, then we see what claims we assert, right? 149 00:10:22,920 --> 00:10:25,160 We have the sub, does it work? 150 00:10:25,160 --> 00:10:25,820 Okay. 151 00:10:25,820 --> 00:10:29,400 We have the sub and then we have the odd, odd short for audience by the way. 152 00:10:29,400 --> 00:10:32,640 And then we see that there, we can define the comparators, right? 153 00:10:32,640 --> 00:10:36,200 We can do string like or string equals and set the values. 154 00:10:36,200 --> 00:10:38,760 Okay, so this is roughly, this is how it goes. 155 00:10:39,560 --> 00:10:43,400 So, per the question, how exactly do we authorize someone? 156 00:10:43,400 --> 00:10:50,980 Then we have this entity called identity federation and it's going to assert tokens claims coming, uh, from, uh, CI machines. 157 00:10:51,060 --> 00:10:52,480 In this case, obviously. 158 00:10:52,940 --> 00:10:57,360 Alright, so now that we know that the CI provider is also the identity provider, right? 159 00:10:57,360 --> 00:10:58,540 This is something new. 160 00:10:58,620 --> 00:11:01,920 And we also know that this, uh, we have this federation. 161 00:11:02,080 --> 00:11:07,100 Then let's redraw the, the OIDC flow in the context of CI. 162 00:11:08,340 --> 00:11:11,460 So in the context of CI, we actually have this diagram. 163 00:11:11,460 --> 00:11:14,460 Now the CI provider also gets to be the identity provider. 164 00:11:14,460 --> 00:11:18,700 So it hosts both, uh, like both the CI and itself, the identity. 165 00:11:18,700 --> 00:11:22,120 And also we see on the cloud provider, we have the federation. 166 00:11:22,560 --> 00:11:24,060 So the flow is as follows. 167 00:11:24,060 --> 00:11:29,600 You ask for an ID token, you get an ID token, you go to your cloud, you say I want to access. 168 00:11:29,600 --> 00:11:31,440 The clouds verify the integrity. 169 00:11:31,440 --> 00:11:33,040 This is done using the header. 170 00:11:33,300 --> 00:11:37,720 And then it's going to assert the incoming token against its policies. 171 00:11:37,720 --> 00:11:41,840 And assuming everything was fine, you're going to get a set of short-lived credentials. 172 00:11:41,980 --> 00:11:44,040 This, this microphone hiccups, right? 173 00:11:44,320 --> 00:11:44,980 Right? 174 00:11:45,140 --> 00:11:46,200 Uh, oops. 175 00:11:46,260 --> 00:11:47,800 The mic hiccups. 176 00:11:48,060 --> 00:11:49,300 It doesn't work. 177 00:11:49,380 --> 00:11:50,180 Roughly. 178 00:11:50,180 --> 00:11:51,060 Halfway. 179 00:11:51,220 --> 00:11:51,640 Okay. 180 00:11:51,640 --> 00:11:52,920 I'll say take care of that. 181 00:11:53,320 --> 00:11:54,280 Okay. 182 00:11:54,480 --> 00:11:57,080 Um, I'm going to plug back in the terminology. 183 00:11:57,080 --> 00:11:58,840 This is the auth N bit. 184 00:11:58,860 --> 00:11:59,260 Okay? 185 00:11:59,260 --> 00:12:01,360 And this is the auth Z bit. 186 00:12:02,040 --> 00:12:05,900 Now, since the flow is different, what does it imply? 187 00:12:06,220 --> 00:12:10,660 I'm going to border this square and let's zoom in. 188 00:12:10,860 --> 00:12:19,360 Since everything here happens within the CI provider, if we are able to trigger a CI pipeline, we basically granted the owner's identity. 189 00:12:19,360 --> 00:12:19,920 Okay? 190 00:12:19,920 --> 00:12:27,420 Now, you can limit that using, you can limit that using specific, uh, uh, orders we'll see later on. 191 00:12:27,420 --> 00:12:32,320 But if you're able to trigger a CI machine, you're basically passed the auth N part. 192 00:12:32,320 --> 00:12:32,960 Okay? 193 00:12:33,400 --> 00:12:39,280 This leaves us with the auth Z part to guard everything basically, cause we have the CI machine running. 194 00:12:39,400 --> 00:12:47,700 And in a sense, if we're able to trigger a CI pipeline, all that stands between us and accessing a target's resources is just the policy pattern matching, right? 195 00:12:47,700 --> 00:12:51,680 So, you can see on the bottom part, examples for, uh, sub-claims. 196 00:12:51,680 --> 00:12:58,320 It can begin with repo, a multi-banana Zurich, um, the name of the, uh, uh, repository, the git ref. 197 00:12:58,320 --> 00:13:01,220 And on the right-hand side, you can see an example of assertion. 198 00:13:01,220 --> 00:13:07,460 For example, repo colon star and where star will expand to everything using pattern matching. 199 00:13:08,640 --> 00:13:09,180 Okay? 200 00:13:09,180 --> 00:13:12,620 So, this was the summary for, uh, OIDC in the context of CI. 201 00:13:12,620 --> 00:13:13,600 This is how it works. 202 00:13:13,600 --> 00:13:14,900 This is the whole magic. 203 00:13:15,420 --> 00:13:24,720 So, in the context of CI, we can say that it is done by asserting incoming ID tokens from CI machine using an identity federation in exchange for credentials. 204 00:13:25,360 --> 00:13:26,280 That's it. 205 00:13:26,700 --> 00:13:27,460 Easy. 206 00:13:27,960 --> 00:13:28,480 Cool. 207 00:13:28,480 --> 00:13:30,420 We can move on to the no configs. 208 00:13:30,420 --> 00:13:31,960 And let's have some fun. 209 00:13:31,980 --> 00:13:36,100 So, no configs is basically when there is no one at the door. 210 00:13:36,100 --> 00:13:43,040 If you think about the auth Z as the bouncer, if the bouncers allows anyone into the club, then anybody can get in, right? 211 00:13:43,320 --> 00:13:48,900 So, a no config is a state, uh, where the federator is asserting lax rules, if any. 212 00:13:48,940 --> 00:13:52,660 Um, and they will, it will authorize almost any ID token. 213 00:13:52,660 --> 00:13:53,020 Okay? 214 00:13:53,020 --> 00:13:54,220 What does it mean? 215 00:13:54,400 --> 00:13:56,980 So, let's take a look at these three snippets. 216 00:13:56,980 --> 00:14:01,680 These are snippets from the identity federation example you just saw, but different assertions. 217 00:14:01,680 --> 00:14:04,740 So, the first one, we have, uh, an asterisk, right? 218 00:14:04,740 --> 00:14:07,680 Using pattern matching and gonna expand to anything. 219 00:14:07,680 --> 00:14:09,800 Obviously, you didn't check anything here. 220 00:14:09,800 --> 00:14:12,260 Um, second option, repo column stars. 221 00:14:12,260 --> 00:14:13,580 So, everything begins with repo. 222 00:14:13,580 --> 00:14:15,660 There's nothing specific to your account here. 223 00:14:15,660 --> 00:14:17,740 So, again, you didn't check anything. 224 00:14:17,920 --> 00:14:24,800 And the last one is everything that begins with my org and something to note, there's no slash between the org and the stars. 225 00:14:24,800 --> 00:14:30,440 So, if you open a GitHub organization called my org one, it will satisfy this as well. 226 00:14:30,760 --> 00:14:31,400 Cool. 227 00:14:31,400 --> 00:14:34,740 Now, this was already talked about in, uh, in, uh, two talks. 228 00:14:34,740 --> 00:14:39,260 One by, uh, Rojan of Tinder and one by Christoph that maybe sits in the audience here. 229 00:14:39,260 --> 00:14:40,440 So, hi Christoph. 230 00:14:40,860 --> 00:14:45,500 Um, I also talked about it, uh, on the latest, um, b-sides. 231 00:14:45,500 --> 00:14:49,500 And basically, I, I really, I highly recommend watching these talks. 232 00:14:49,500 --> 00:14:52,940 They explain exactly how those misconfigs look like, okay? 233 00:14:52,940 --> 00:14:55,840 And how to hunt for them and how to exploit them. 234 00:14:55,840 --> 00:15:02,300 I'm not gonna talk about, uh, when there's no config kind of situation, um, and yes, go ahead and watch them. 235 00:15:03,200 --> 00:15:08,560 So, since we're not talking about the no config situation, what happens when I have partial configs? 236 00:15:08,560 --> 00:15:10,280 How safe are they, if at all? 237 00:15:10,660 --> 00:15:11,960 Let's zoom in. 238 00:15:11,960 --> 00:15:15,220 So, the first one we're gonna assert everybody in the org name, right? 239 00:15:15,220 --> 00:15:16,400 Repo colon org name. 240 00:15:16,400 --> 00:15:20,480 Let's say I can say anybody in Palo Alto can access this identity. 241 00:15:20,480 --> 00:15:21,140 Is this okay? 242 00:15:21,140 --> 00:15:22,160 Is this safe? 243 00:15:22,160 --> 00:15:25,240 What about everybody in Palo with respect to a branch? 244 00:15:25,440 --> 00:15:29,900 So, the answer is, the first one is potentially unsafe, so does the second one. 245 00:15:29,900 --> 00:15:33,320 We're gonna see later how we can exploit and abuse such cases. 246 00:15:33,520 --> 00:15:36,580 And the workflow example is actually the worst. 247 00:15:36,580 --> 00:15:37,860 This is very bad. 248 00:15:37,860 --> 00:15:41,880 If you configure using the workflow, you're exploited immediately, okay? 249 00:15:41,880 --> 00:15:43,360 And we're gonna see how. 250 00:15:43,360 --> 00:15:47,780 And another thing you gotta ask yourself, how come this claim begins with workflow? 251 00:15:47,780 --> 00:15:49,560 All you've seen was repo colon. 252 00:15:49,560 --> 00:15:51,000 How come we're at workflow colon? 253 00:15:51,000 --> 00:15:52,260 What happened here? 254 00:15:53,080 --> 00:15:58,840 Alright, so let's move to misconfiguration when you do some configurations but they're insufficient. 255 00:15:59,380 --> 00:16:03,760 Uh, we're gonna see some pitfalls for advanced configurations including a demo. 256 00:16:03,760 --> 00:16:06,740 And then we're gonna see how you can abuse, uh, pipelines. 257 00:16:06,740 --> 00:16:11,720 This is partially what Adnan, uh, talked about in the, in the last talk. 258 00:16:11,720 --> 00:16:17,340 Um, but we're gonna see how we can abuse lax policies and access, uh, um, various identities. 259 00:16:17,340 --> 00:16:18,780 So, misconfigs. 260 00:16:19,640 --> 00:16:21,960 We're gonna start with a short demo. 261 00:16:22,160 --> 00:16:26,160 Um, and just click here. 262 00:16:26,540 --> 00:16:36,340 Okay, so what you see here is a video that was uploaded by, uh, JFrog explaining to their customers how to configure OIDC in front of, uh, JFrog. 263 00:16:36,340 --> 00:16:38,640 So you can access the artifactory, x-ray, etcetera. 264 00:16:38,740 --> 00:16:41,980 So this is a great feature by the way, nothing bad to say about them. 265 00:16:41,980 --> 00:16:49,500 And what we see in this example is how they configure the identity provider on JFrog's side and how they configure the identity. 266 00:16:49,500 --> 00:16:53,440 Here we see the example, uh, claims GitHub allows us to rely upon. 267 00:16:53,440 --> 00:16:59,220 And we can see on the right hand side that they instruct us to assert workflow equals JFrog NPM. 268 00:16:59,220 --> 00:17:00,940 This is according to their video. 269 00:17:01,400 --> 00:17:04,200 Alright, um, I'm a naive user. 270 00:17:04,200 --> 00:17:05,660 I'm gonna copy paste that, right? 271 00:17:05,660 --> 00:17:08,620 Uh, I just learned OAuth and, and OIDC. 272 00:17:08,620 --> 00:17:13,600 So, this is me creating the same identity provider at JFrog. 273 00:17:13,600 --> 00:17:20,240 Um, just naming it my provider, etcetera, etcetera, nothing fancy, and some arbitrary, arbitrary identity. 274 00:17:20,520 --> 00:17:22,280 And I'm gonna do the same instruction. 275 00:17:22,280 --> 00:17:26,080 I'm gonna assert that the workflow equals core pre-usable workflow. 276 00:17:26,080 --> 00:17:28,200 This is coming from my corporation. 277 00:17:28,440 --> 00:17:29,020 Alright. 278 00:17:29,860 --> 00:17:34,500 Uh, I'm gonna save it, uh, and then I'm gonna copy the snippet. 279 00:17:34,500 --> 00:17:35,760 This is for GitHub Actions. 280 00:17:35,760 --> 00:17:40,120 Uh, for those of you who are unfamiliar somehow with this product, this is GitHub's CI. 281 00:17:40,440 --> 00:17:47,480 Um, once I saved it, I'm gonna go to my leaking pond repository and I'm gonna create a new GitHub Actions file. 282 00:17:47,480 --> 00:17:48,880 I'm gonna commit everything. 283 00:17:48,880 --> 00:17:53,720 If you are unfamiliar with how the workflows of GitHub Action looks like, then this is it. 284 00:17:53,720 --> 00:17:54,520 This is the recipe. 285 00:17:54,520 --> 00:18:03,860 And all you gotta know for the sake of this demo is that assuming a success, the machine invocation as a whole will be successful, otherwise it will fail. 286 00:18:04,600 --> 00:18:09,340 So, uh, I've committed the CI reacts to my Git event, so it fires. 287 00:18:09,420 --> 00:18:17,460 Um, we're gonna see a machine being run and then we're gonna see that this account, as the video instruct us, was indeed able to access GitHub. 288 00:18:17,460 --> 00:18:19,200 Now let's exploit that, okay? 289 00:18:19,200 --> 00:18:22,460 We're gonna use this special technique called copy-paste. 290 00:18:22,720 --> 00:18:33,240 I'm gonna copy the exact same workflow configuration file and I'm gonna commit it to my own private, uh, uh, account, which I was told that it's not safe to do at DefCon, but whatever. 291 00:18:33,340 --> 00:18:40,960 Um, gonna do a special commit message cause it's important for nothing and in reaction the CI will trigger again. 292 00:18:41,180 --> 00:18:50,300 Now what we will see, uh, we're gonna go into this logs, we're gonna count 1, 2, 3, worker's gonna pick it up, and we were able to successfully access the same account, right? 293 00:18:50,300 --> 00:18:51,580 From a different account. 294 00:18:51,660 --> 00:18:53,040 Amazing, magic. 295 00:18:54,080 --> 00:18:55,320 What happened? 296 00:18:55,640 --> 00:18:55,920 Right? 297 00:18:55,920 --> 00:18:56,980 What happened here? 298 00:18:58,020 --> 00:19:04,880 On JFrog's end, we defined the identity federation to be something, whatever the name of the provider, but workflow. 299 00:19:04,880 --> 00:19:08,180 I'm gonna set the workflow to be corp usable workflow, correct? 300 00:19:08,180 --> 00:19:08,820 Good. 301 00:19:09,740 --> 00:19:20,940 When my token showed up and said hi, I'm coming from a repository, et cetera, et cetera, and the workflow is called corp usable workflow, so the federation said yeah, it's the same claim, get in. 302 00:19:21,340 --> 00:19:24,440 And you gotta ask yourself where is this value coming from? 303 00:19:24,440 --> 00:19:27,340 And the answer is, as always, user input. 304 00:19:27,620 --> 00:19:32,580 So you can just, this is the name of the workflow, you can put any string there and yeah. 305 00:19:33,020 --> 00:19:36,140 So, copy paste for the win. 306 00:19:36,880 --> 00:19:41,720 And we can see by showing one example that not all claims are safe, right? 307 00:19:41,720 --> 00:19:45,540 I've showed you once, this is sufficient to say that not all are safe. 308 00:19:45,540 --> 00:20:04,740 If we look into the RFC of OIDC, then basically we're instructed to have five required claims, issuer, subject, audience, expiration, and issued at, let's translate them to an attacker point of view, the URL of the provider, the target, just a string that you can modify if you have an RC in the case of odd, 309 00:20:04,740 --> 00:20:09,540 expiration time for the OIDC token is roughly four minutes and nobody cares when it was issued. 310 00:20:11,040 --> 00:20:16,100 On top of these five claims, we have a plethora of other custom claims. 311 00:20:16,100 --> 00:20:20,420 These are given by the CI vendors, which get to be the identity providers, right? 312 00:20:20,820 --> 00:20:26,180 For example, GitHub supplies with various claims, but all of these are unique to GitHub, right? 313 00:20:26,580 --> 00:20:31,740 Repository owner, runner, environment, run number, whatever, whatever, these are all GitHub unique. 314 00:20:31,800 --> 00:20:34,380 If we go to Circle, they have their own world, right? 315 00:20:34,380 --> 00:20:39,520 Workflow ID, VCS origin, whatever, and GitLab has their own stuff, right? 316 00:20:39,520 --> 00:20:41,540 Nobody, like, what's going on? 317 00:20:41,760 --> 00:20:44,540 So it adds up to a lot of confusion. 318 00:20:44,540 --> 00:20:56,320 If you're a DevOps for a company and you're trying to set up using custom claims, you can get lost really quickly, because you have so many and there's almost zero instructions on which values are safe in this context. 319 00:20:57,280 --> 00:21:08,140 So if you'd like to avoid a situation like I just showed, a rule of thumb for using custom claims coming from the vendor is to remember that they're provided regardless of their strength. 320 00:21:08,140 --> 00:21:11,080 By strength, I mean how hard they are to fraud. 321 00:21:11,140 --> 00:21:14,440 So check where the values come from, okay? 322 00:21:15,220 --> 00:21:26,520 Now, a hidden pitfall of this behavior, or this basically behavior, is the custom claim format feature, okay? 323 00:21:26,520 --> 00:21:38,120 So as the name suggests, it's a custom format, and it comes to answer a problem where some federators do not assert custom claims directly, like we saw with JFrog asserting workflow. 324 00:21:38,120 --> 00:21:39,660 Some just don't want to do that. 325 00:21:39,660 --> 00:21:40,380 Why? 326 00:21:40,420 --> 00:21:40,900 I don't know. 327 00:21:40,900 --> 00:21:42,020 It's just a JSON. 328 00:21:42,420 --> 00:21:49,140 But therefore, some identity providers allow reformatting the structure of the subclaim to contain custom claims values, okay? 329 00:21:49,140 --> 00:21:50,600 What do I mean by that? 330 00:21:51,160 --> 00:21:53,400 Consider the top option. 331 00:21:53,400 --> 00:21:54,740 This is what you're familiar with. 332 00:21:54,740 --> 00:21:56,680 It begins with repo and then the ref, right? 333 00:21:56,680 --> 00:21:57,720 The git ref. 334 00:21:57,880 --> 00:22:09,920 But now you can put actor ID, this is in GitHub's world, so now you can put actor ID and repository ID, and it will be later populated with the values with respect to where this was fired from, where the CI ran from. 335 00:22:10,640 --> 00:22:17,700 So something that can be easily missed with this feature is that the claims order is critical, all right? 336 00:22:17,700 --> 00:22:18,740 Let's see why. 337 00:22:19,000 --> 00:22:21,960 Consider this format and this claim. 338 00:22:21,960 --> 00:22:26,680 So we're going to have repo, my org, and then the name of the workflow, Makat Shemesh, fine. 339 00:22:26,880 --> 00:22:29,860 So we all know by now that this is very unsafe, right? 340 00:22:29,860 --> 00:22:31,840 I just showed you how it can be abused. 341 00:22:32,940 --> 00:22:34,820 But this one is actually safe. 342 00:22:34,820 --> 00:22:35,880 The prefix is safe. 343 00:22:35,880 --> 00:22:36,140 Why? 344 00:22:36,140 --> 00:22:42,020 Because GitHub will actually put the name of the organization and repository, you can't just fake that, at least not in this talk. 345 00:22:42,100 --> 00:22:43,720 But you can't just fake that. 346 00:22:43,720 --> 00:22:45,240 So this is fine. 347 00:22:45,240 --> 00:22:50,440 This is an example of fine, although it relies on unsafe claim for the second half of it. 348 00:22:50,440 --> 00:22:53,600 If you flip it, however, then you're done with, okay? 349 00:22:53,820 --> 00:22:55,540 So let's see how. 350 00:22:57,260 --> 00:23:17,320 In order to abuse such a case, basically all you have to do is create a workflow, name it everything after the workflow prefix, go to your favorite CI provider, change the sub claim to be workflow only, and they will grant you with a pretty and beautiful signed token that has the exact same claim like the other organization asserts. 351 00:23:17,320 --> 00:23:22,620 And obviously you can put whatever my org in Palo Alto, Microsoft, you can just write whatever. 352 00:23:23,920 --> 00:23:28,040 So a rule of thumb for this feature is that the claims order is critical. 353 00:23:28,040 --> 00:23:30,780 I haven't seen even one manual page that mentions that. 354 00:23:30,780 --> 00:23:35,540 When you use custom claims, they just let you use it, but they don't tell you what not to do. 355 00:23:35,540 --> 00:23:37,380 So the order is critical. 356 00:23:38,100 --> 00:23:45,980 In order to help everybody here to either escape from these bugs or to exploit them, I've created this tool. 357 00:23:46,160 --> 00:23:51,560 You can scan the QR code to get the latest zero click for your Android. 358 00:23:52,520 --> 00:23:58,060 But basically it allows you to enlist all the GitHub possible custom claims with information about the strength of each one. 359 00:23:58,060 --> 00:23:59,720 This is a nice guide I composed. 360 00:23:59,760 --> 00:24:08,880 It can check your sub claim format for safety, and it will allow you to modify the sub claim if you want to attack with it or you just want to fix it for your organization or repository. 361 00:24:08,880 --> 00:24:11,400 There is some hierarchy option, so it's interesting. 362 00:24:12,140 --> 00:24:13,700 This is how the tool looks like. 363 00:24:13,700 --> 00:24:20,220 All you've got to bring is your favorite GitHub token with admin permissions, not necessarily of your organization, but yeah. 364 00:24:21,080 --> 00:24:30,260 And for example, in the inspect mode, you can see that these are the claims, and they're not safe because it's set right, so go ahead, get a zero click, and yeah. 365 00:24:31,240 --> 00:24:32,180 Okay. 366 00:24:32,800 --> 00:24:34,340 Now this is behind us. 367 00:24:34,340 --> 00:24:39,520 And let's move into pipeline abuses that can lead to OIDC abuse. 368 00:24:39,520 --> 00:24:44,680 Basically misconfigs that lead to abuses, abusage, sorry, of lax policies. 369 00:24:44,740 --> 00:24:47,000 So we saw that this was very bad, right? 370 00:24:47,000 --> 00:24:49,960 We now know why this sucks. 371 00:24:50,320 --> 00:24:51,660 But what about these two? 372 00:24:51,660 --> 00:24:56,440 We did just say that, for example, saying everybody in Apollo is fine, right? 373 00:24:56,440 --> 00:24:57,420 Or not? 374 00:24:57,840 --> 00:24:59,700 So let's abuse those. 375 00:25:00,440 --> 00:25:02,220 The answer is pretty simple. 376 00:25:02,220 --> 00:25:07,180 Poison pipeline execution, which is the most common entry vector for CIs, right? 377 00:25:07,180 --> 00:25:08,540 And lax policies. 378 00:25:08,540 --> 00:25:10,640 So let's explain for a second. 379 00:25:10,640 --> 00:25:16,700 Uh, a PPE is a pull request from a fork that will trigger a vulnerable CI execution in the context of the target, right? 380 00:25:16,700 --> 00:25:18,100 We're all familiar with this by now. 381 00:25:18,100 --> 00:25:19,180 I hope so. 382 00:25:19,280 --> 00:25:28,800 Um, the second bit , the lax policies, um, they will allow a token from the same, uh, from the targeted organization , sorry, to slip through lax policies. 383 00:25:28,800 --> 00:25:29,340 Okay? 384 00:25:29,340 --> 00:25:30,400 Now what do I mean by that? 385 00:25:30,400 --> 00:25:31,820 Let's see how it plays. 386 00:25:32,460 --> 00:25:33,340 Demo. 387 00:25:33,880 --> 00:25:37,600 In order to demo that, we have to define a few entities, right? 388 00:25:37,600 --> 00:25:40,560 Let's begin with the identity federation on the resource side. 389 00:25:40,560 --> 00:25:42,300 So we're gonna set up something like this. 390 00:25:42,300 --> 00:25:47,000 We wanna assert that the audience equals, uh, the Amazon AWS thing. 391 00:25:47,060 --> 00:25:54,000 Um, and we wanna assert that all the identities coming in from the banana multi organization are okay to go in. 392 00:25:54,300 --> 00:25:55,580 This is the federation. 393 00:25:55,580 --> 00:25:58,680 If you put it, by the way, on AWS, it's gonna look something like this. 394 00:25:58,680 --> 00:26:04,960 And although AWS did some changes in order to enforce more strict policies, they will allow you to do that. 395 00:26:04,960 --> 00:26:06,700 This is fine by AWS. 396 00:26:08,040 --> 00:26:09,620 Now for the git part. 397 00:26:09,620 --> 00:26:11,380 Let's see what's our setup. 398 00:26:11,960 --> 00:26:18,360 We have this organization called banana multi and we have two, uh, basically pipelines including the git repo itself. 399 00:26:18,400 --> 00:26:19,860 And let's explain. 400 00:26:19,860 --> 00:26:27,420 So the upper one, um, is a pipeline that is configured to connect using OIDC to an S3 role that is, uh, an admin. 401 00:26:27,420 --> 00:26:30,360 Um, this policy is the policy that we just saw. 402 00:26:30,360 --> 00:26:31,640 So it's lax. 403 00:26:31,660 --> 00:26:33,280 Um, and this is our target. 404 00:26:33,280 --> 00:26:48,100 The second pipeline is called any updateser and, uh, it contains, it's connected to a vulnerable pipeline and then it's using an OIDC token again to access a restricted S3, uh, uh, bucket or a role and we obviously cannot use that. 405 00:26:48,980 --> 00:26:51,100 So let's see our attack vector. 406 00:26:51,100 --> 00:26:52,000 Pretty simple. 407 00:26:52,000 --> 00:27:06,460 We're gonna fork the any updateser and we're gonna, uh, um, basically invoke the CI machine of the, the CI workflow, sorry, of, uh, and we're gonna invoke the vulnerable CI workflow and we'll try to access the other accounts. 408 00:27:06,620 --> 00:27:10,000 Um, the workflow, by the way, looks something like this. 409 00:27:10,000 --> 00:27:15,280 It has to react to pull request, maybe pull request or pull request target for the GitHub world. 410 00:27:15,500 --> 00:27:19,940 Um, and you have to specify that you want an ID token that the workflow has to say. 411 00:27:21,140 --> 00:27:23,700 Um, the pipeline is gonna check out the fork. 412 00:27:23,700 --> 00:27:25,400 This is the head for the pull request. 413 00:27:25,400 --> 00:27:28,720 Uh, we're gonna skip the part where it actually assumed the AWS role. 414 00:27:28,720 --> 00:27:30,560 We don't, we can't use that so we don't care. 415 00:27:30,800 --> 00:27:38,960 And then there's an invocation of a file from the file system which was just cloned from the fork and yeah, we have RCE. 416 00:27:39,900 --> 00:27:42,600 So what we need to do now is make the fork pull request. 417 00:27:42,600 --> 00:27:46,400 This is what's called IPP, indirect points of pipeline execution. 418 00:27:46,700 --> 00:27:49,280 And this is the exploit script. 419 00:27:49,280 --> 00:27:51,400 Don't rush and, and, and take pictures. 420 00:27:51,400 --> 00:27:53,080 It's just chat GPT. 421 00:27:53,100 --> 00:28:04,860 Um, but basically all you have to do before you make this exploit code, you have to, uh, to do some recon and collect various id- accounts that are, are connected through using OIDC. 422 00:28:04,860 --> 00:28:05,360 Okay? 423 00:28:05,360 --> 00:28:08,280 I'm not gonna talk about it in this talk but this is something you have to do. 424 00:28:08,280 --> 00:28:12,680 In this example, I'm having 2 roles at the top that I'm gonna try to exploit. 425 00:28:13,520 --> 00:28:14,640 Let's see it in action. 426 00:28:14,640 --> 00:28:18,580 So this is the prepare.sh file that is gonna be invoked at some point. 427 00:28:18,620 --> 00:28:19,900 Uh, this is my fork. 428 00:28:19,900 --> 00:28:21,200 Any updates sir? 429 00:28:22,060 --> 00:28:24,100 And I'm gonna open a pull request. 430 00:28:24,220 --> 00:28:25,880 So, uh, hello it's me. 431 00:28:25,880 --> 00:28:27,060 The diff is the same file. 432 00:28:27,060 --> 00:28:28,340 Nothing but this file. 433 00:28:28,340 --> 00:28:33,500 And I'm gonna open the pull request and it's gonna invoke the CI in response to the trigger. 434 00:28:35,100 --> 00:28:35,900 Cool. 435 00:28:35,900 --> 00:28:38,920 3 seconds from now we're gonna see the machine logs. 436 00:28:38,940 --> 00:28:41,820 1, 2, 3, as I promised. 437 00:28:42,020 --> 00:28:51,280 And, uh, now in the logs we will see in the prepare step that it, we will see the output of my script and if we're successful we'll see sets of credentials. 438 00:28:51,460 --> 00:28:55,540 And I wouldn't be here if it would work so, yeah, we have sets of credentials. 439 00:28:55,540 --> 00:29:00,000 So we were able to assume a role that was not allocated to the pipeline we were running at. 440 00:29:00,000 --> 00:29:04,520 Well we were not able to assert others but again you can just spray OIDC tokens. 441 00:29:04,540 --> 00:29:06,260 So this is a very nice technique. 442 00:29:06,260 --> 00:29:12,720 You can just collect tokens, find vulnerable pipelines and start spraying for, to find the logs policies internally, right? 443 00:29:12,720 --> 00:29:14,620 You're already past the auth end. 444 00:29:14,620 --> 00:29:15,900 You have the credentials. 445 00:29:16,200 --> 00:29:17,620 So give it a shot. 446 00:29:19,880 --> 00:29:21,100 1 second. 447 00:29:22,100 --> 00:29:24,800 Okay, uh, some nice disclosure. 448 00:29:24,800 --> 00:29:35,540 I was able to, this is by the way from last year already and, and I was able to find this, uh, a month ago in Azure and this allowed to access basically all the identities that had Azure slash star. 449 00:29:35,540 --> 00:29:37,140 So, yeah, nice technique. 450 00:29:37,240 --> 00:29:41,280 Um, the rest did not allow disclosure but you're out there. 451 00:29:42,880 --> 00:29:49,700 Cool, so rule of thumb in order to avoid this type of stuff, one is for the CI, please follow the best practices. 452 00:29:49,700 --> 00:29:57,360 We're 2024, um, we, my team, we've released plenty of guides on how to, uh, harden your pipelines. 453 00:29:57,360 --> 00:29:58,620 Please do so. 454 00:29:58,740 --> 00:30:10,020 The second thing, uh, pursue, uh, policies that are not with wildcards as much as you can or, uh, use other claims that are safe in order to assert identities. 455 00:30:11,720 --> 00:30:17,220 Okay, this brings us to our last topic of the day and this is when, when the vendor misconfigures. 456 00:30:17,220 --> 00:30:24,620 Now that you know that the vendor, the CI vendor is also the identity provider, now they have to put, to give more attention to the details, right? 457 00:30:24,620 --> 00:30:29,120 They have various products at their hand now and they have to be very careful. 458 00:30:29,120 --> 00:30:36,840 So, this is a disclosure for, uh, Circle CI, um, and basically if you're unfamiliar with Circle, they're a great CI product. 459 00:30:36,860 --> 00:30:44,180 Um, they provide various machines, right, in order for you to run your workloads and they're super nice and professional folks on a personal level. 460 00:30:44,180 --> 00:30:44,880 Okay? 461 00:30:45,440 --> 00:30:56,620 When I looked into, oh, just to explain, uh, Circle, sorry, um, this is you, you perform git push, you're all familiar with this diagram by now, well, you notify Circle with a payload and they did your CI thing for you. 462 00:30:56,740 --> 00:31:04,760 Now, when GitHub notifies Circle, by the way, they do that with the web hook and the payload is everything that was, that is in your git context. 463 00:31:04,760 --> 00:31:12,460 So, in a way, and just to add to the confusion, Circle can supply you with a super set of claims on top of GitHub's claims, if you think about it. 464 00:31:12,460 --> 00:31:16,040 Just to add to the confusion from earlier, I see your faces, so yeah, it's confusing. 465 00:31:16,760 --> 00:31:21,360 Um, okay, so when I looked into Circle's CI system state, I noted the following. 466 00:31:21,360 --> 00:31:28,180 First, pipelines reacted to fork pull request if and only if, there's no typo, uh, the project is configured to do so. 467 00:31:28,180 --> 00:31:29,840 Now, this is actually a good limitation, right? 468 00:31:29,840 --> 00:31:32,820 We don't want anybody on the internet to run machines for us. 469 00:31:32,820 --> 00:31:35,680 Putting aside security, someone's gotta pay for that. 470 00:31:36,480 --> 00:31:42,900 Okay, but second thing that I noted is that pipelines were triggered, uh, on a workflow change, even from a fork . 471 00:31:42,960 --> 00:31:43,380 Okay? 472 00:31:43,380 --> 00:31:44,500 And this is not good. 473 00:31:44,500 --> 00:31:44,760 Why? 474 00:31:44,760 --> 00:31:51,760 This implies every pull request can be an RCE, you can just commit, basically pull request a malicious workflow. 475 00:31:52,460 --> 00:31:58,020 Okay, doesn't look good, but the third part was the, the cherry on top. 476 00:31:58,020 --> 00:32:02,400 An IDC token was always granted to the machine regardless of anything. 477 00:32:02,400 --> 00:32:05,160 And this is credentials mishandle and misuse. 478 00:32:05,160 --> 00:32:05,940 Okay? 479 00:32:06,120 --> 00:32:13,480 So, combining those, I was granted an ID token in the context of any Circle CI project that allowed fork pull requests. 480 00:32:13,540 --> 00:32:13,800 Okay? 481 00:32:13,800 --> 00:32:14,640 What does it imply? 482 00:32:14,640 --> 00:32:15,700 What does it mean? 483 00:32:15,840 --> 00:32:22,480 Is that I was able to access OIDC gated resources of any Circle CI organization that allowed fork pull requests. 484 00:32:22,480 --> 00:32:22,680 Right? 485 00:32:22,680 --> 00:32:26,760 That's basically everybody on Circle that has pull requests and OIDC. 486 00:32:27,420 --> 00:32:28,480 Nice amount. 487 00:32:29,400 --> 00:32:33,580 Um, the attack flow is pretty simple, you just saw a demo of that using, uh, another file, right? 488 00:32:33,580 --> 00:32:39,160 The prepare, so I'm not gonna show the same thing, all you've, you had to do basically is, uh, pull request the workflow. 489 00:32:39,160 --> 00:32:40,360 So, I'm not gonna show that. 490 00:32:40,360 --> 00:32:42,460 I will talk about the disclosure, however. 491 00:32:43,440 --> 00:32:49,340 So, in order to show Circle CI that this was indeed a bug, I looked for instances in the wild to support my case. 492 00:32:49,560 --> 00:32:53,120 Um, it wasn't long ago until I found this file. 493 00:32:53,120 --> 00:32:55,060 Now, this was by a company called Darklang. 494 00:32:55,060 --> 00:32:57,060 Anybody here familiar with those folks? 495 00:32:57,140 --> 00:32:57,640 Hands up? 496 00:32:57,640 --> 00:32:58,260 No? 497 00:32:58,280 --> 00:32:59,020 Okay. 498 00:32:59,760 --> 00:33:03,840 Um, just to explain this file, this is an identity federation for, uh, GCP. 499 00:33:03,840 --> 00:33:09,260 And even though you don't know this, this cell language, uh, GCP's language, you can understand the mapping here, right? 500 00:33:09,260 --> 00:33:18,600 We know that CircleCI.com, we know this is the provider, and we know project ID is the claim, and we're gonna map it to project, audience to organization ID, and sub to sub, right? 501 00:33:18,600 --> 00:33:20,480 We now know what these claims are. 502 00:33:20,800 --> 00:33:27,020 Um, per the condition, the condition was that any one of these three project IDs is okay to access. 503 00:33:27,920 --> 00:33:38,000 And something that I cared but then didn't care for the exploitation was that the issue URL and the allowed audience had to be the organization, uh, ID. 504 00:33:38,000 --> 00:33:43,640 Now this is fine as long as you create a pull request within the organization, Circle will just provide you with the ID, right? 505 00:33:43,640 --> 00:33:45,300 You're in the context of the organization. 506 00:33:45,300 --> 00:33:47,940 So this part is fine, we don't need to care about that. 507 00:33:49,040 --> 00:33:56,920 Um, so basically, a fork PR to any of those projects, uh, which indeed they allowed fork PRs, uh, granted access to their clouds. 508 00:33:56,920 --> 00:33:58,340 That was it, as simple. 509 00:33:58,340 --> 00:34:02,300 Okay, just detect the misconfig, pull request, enjoy the cloud account. 510 00:34:02,900 --> 00:34:08,820 So good summary and me, I'll disclose to the company so they can fix it and meanwhile, meanwhile I'll go to Circle. 511 00:34:09,260 --> 00:34:18,900 I went to DarkLang's, uh, Discord asking for, uh, bug bounty cause I like it, and but there was none, so I was told to DM, um, DM someone. 512 00:34:18,960 --> 00:34:25,140 Um, this is the someone, PBigger, I don't know if someone is familiar with this name, but yeah, we're gonna see exactly how you are familiar. 513 00:34:25,220 --> 00:34:35,960 But, um, yeah, he told me DM me, which I did, I sent, uh, I sent them everything and I also added the line, the reason, at the bottom, sorry, the reason is not safe, it's not because of you, it's because of a bug in Circle, right? 514 00:34:35,960 --> 00:34:38,460 I mean, you're fine, just defend yourself, it's them, not you. 515 00:34:39,080 --> 00:34:41,920 Um, I also asked them to not disclose right now. 516 00:34:41,920 --> 00:34:46,120 I don't know who is aware of that, I don't want anybody to exploit, I'm, uh, white hat at that point. 517 00:34:46,360 --> 00:34:49,720 Uh, I don't want anybody to exploit, um, so don't talk to anybody. 518 00:34:49,720 --> 00:34:54,120 Um, PBigger replied that he was investigating and then he confirmed it and blocked all access. 519 00:34:54,120 --> 00:34:57,460 By the way, this is exactly where OIDC kicks in. 520 00:34:57,460 --> 00:35:04,060 By ticking one box, he was able to kill all the GitHub, uh, basically all the, um, OIDC connections coming from Circle. 521 00:35:04,060 --> 00:35:05,680 Okay, this is very powerful. 522 00:35:05,680 --> 00:35:09,260 No rotations needed, no credential changes, just one box. 523 00:35:09,560 --> 00:35:18,660 Um, he was fixing that, we were, we continued chatting, later on he said again that he was very happy to seal it, to which I replied, no problem. 524 00:35:18,840 --> 00:35:26,420 To which he replied, uh, by the way, I sent a note to the security folks at CircleCI, I wasn't sure if you knew, but I founded Circle. 525 00:35:28,840 --> 00:35:29,560 Yeah. 526 00:35:30,420 --> 00:35:35,680 So, just a random dude on Discord, right? 527 00:35:36,420 --> 00:35:45,480 So, a good advice here would be to attempt to not disclose directly to the board member or the CEO, it can be a bit awkward and odd. 528 00:35:46,040 --> 00:35:46,960 So, yeah. 529 00:35:46,960 --> 00:35:57,800 This was, uh, June 23, Circle since then fixed this bug and sealed it, and now if you look into their OIDC page, you see this message, what about forks, and basically, uh, you have to opt in now. 530 00:35:57,800 --> 00:36:00,680 Like in GitHub, I told you you have to set up ID token, right? 531 00:36:00,680 --> 00:36:12,020 This is the same thing, you have to opt in, this is done in a different manner, but the same idea, you have to opt in in order to provide a fork, a machine that is running for a fork pull request, an OIDC token. 532 00:36:12,420 --> 00:36:16,040 Um, this changes this state and now we have a proper handling. 533 00:36:16,100 --> 00:36:19,780 You can see that, um, part two is still there. 534 00:36:19,800 --> 00:36:25,260 Uh, some integrations in Circle still react to that, so enjoy the misconfig. 535 00:36:26,460 --> 00:36:29,640 Um, and this is roughly, this is our conclusions and takeaways. 536 00:36:29,640 --> 00:36:32,500 So, first of all, I hope that now you know what OIDC is. 537 00:36:32,500 --> 00:36:33,900 It's not that hard, right? 538 00:36:33,900 --> 00:36:39,600 I was talking to folks before and they were giving me weird faces, like, yeah, I know, know OIDC, know. 539 00:36:39,600 --> 00:36:43,220 So, I hope you know it now, relax, it's fine, it's chill, okay? 540 00:36:43,540 --> 00:36:47,940 Um, plus you already learned OAuth, this is the big thing to, to swallow here. 541 00:36:48,280 --> 00:37:02,760 Um, second thing, and this is actual takeaways, so for in using OIDC and CI, do the following, uh, learn the origin of each claims, I've provided the tool for GitHub again, but, um, learn the claims for your identity providers, uh, pursue policies without wildcards, 542 00:37:02,760 --> 00:37:09,260 and always think, always think, which other identities can satisfy my conditions? 543 00:37:09,780 --> 00:37:13,860 Last bit, please harden your pipelines, sometimes it's too easy. 544 00:37:14,280 --> 00:37:15,360 That's it. 545 00:37:15,820 --> 00:37:16,880 So, yeah. 546 00:37:17,080 --> 00:37:18,960 Um, and yeah, but that's basically it. 547 00:37:18,960 --> 00:37:20,240 Thank you very much. 548 00:37:20,240 --> 00:37:23,980 Um, yeah, I'm here for questions, if there are any. 549 00:37:28,580 --> 00:37:29,620 Questions? 550 00:37:30,480 --> 00:37:31,280 Beers? 551 00:37:31,280 --> 00:37:31,800 Shots? 552 00:37:31,800 --> 00:37:32,480 No? 553 00:37:33,100 --> 00:37:34,180 See you around.