Good afternoon DEF CON. Thank you so much for being here. Welcome to my talk on exploiting AWS service vulnerabilities for initial access. My name is Nick Furchette. I'm a security researcher over at Datadog where I specialize in AWS offensive security. So finding ways to more effectively attack AWS environments and then hopefully how do we detect that behavior or potentially prevent it entirely. As a result of that research sometimes I find vulnerabilities in the underlying AWS services. Some of which we're going to be talking about today. Uh in my free time I'm the creator and maintainer of Hacking the Cloud which is an open source encyclopedia of offensive security techniques that you can use in cloud hacking adventures. Uh if you'd like a Hacking the Cloud sticker come find me after I have quite a few to give away. Now breaking into AWS accounts is a topic that's near and dear to my heart. And I'm sure it is for many of you as well. But I think if we're being honest with ourselves the traditional methods for gaining access to AWS environments are boring. If we were to poll the audience for real world AWS breaches, compromises and other security incidents I guarantee 95% of scenarios would fall into one of three categories. They were either caused by a leaked access key, an exposed S3 bucket or an exploited EC2 instance. These are the stereotypical ways that adversaries gain access to AWS accounts. And to be clear these are very real risks that we do have to contend with but it's nothing you haven't seen before and again these methods are boring. What we're going to be doing instead is kicking it in the door to the cloud and exploiting vulnerabilities in AWS services to get initial access. Particularly by abusing pre-existing trust. What I mean by that is a common design pattern in AWS is to have IAM roles in your account that have a trust relationship back to some AWS service. This enables that service to perform actions and uh do functionality in your account. Today we're going to look at some vulnerabilities that would allow us to hijack that trust relationship and gain access to victim accounts so that from there we can escalate privileges, move laterally, access resources and more. In this session we're going to talk a little bit about how trust is established between IAM roles and AWS services. Then we're going to dive deep on two vulnerabilities as well as a more general misconfiguration that would allow us to take advantage of this. And finally we're going to discuss prevention options. In the absolute worst case scenario of an adversary having a cross tenant zero day in AWS, what options do we have to try and mitigate some of these attacks? Now it's worth noting that the majority of vulnerabilities we're going to be talking about today have been remediated by AWS. So think of this more from the perspective of what can we learn from these vulnerabilities that we can apply to better attack or defend cloud environments. To get us started on the topic of abusing pre-existing trust, we should probably talk about how that trust is established. In AWS, every IAM role is going to have a role trust policy. And this policy determines who or what is permitted to assume a role. Trust policies can trust a variety of identities. Users, roles, AWS organizations, uh identity providers and many others. But where I think it's most interesting is when they trust an AWS service itself. What you see here on the slide is the default trust policy that is associated with roles for the Lambda service. If you were to create a Lambda function today, the role that would be created for you would have this very same trust policy. And what it says is that we're going to allow the Lambda service to assume role with web, or sorry, to assume role. Now, the way this works in practice is every time your Lambda function runs, the Lambda service assumes that role in your account and does whatever it is that you want it to do. This behavior introduces some really interesting questions. Since I already said that this is the default policy, theoretically the majority of roles using Lambda wouldn't have it. And since the trust policy just says that it trusts Lambda, could I do something a little bit sneaky? Could I create a Lambda function in my account but point to or reference a role in a different AWS account? Preferably one that I don't have legitimate access to. Uh could we cause that Lambda service to assume that role in the victim account and carry out whatever operations would be beneficial to us as adversaries? Well, the good news or bad news depending on your perspective is there is something that stops this. And that's called pass role. Any time you are providing a role to an AWS service for it to assume it, you're interacting with pass role. One of the core rules of which is that you can only pass a role within your same AWS account. If you try to pass a role outside of it, you get the error message, access denied, cross account pass role is not allowed. Now, this is a very important security boundary in AWS because without it, theoretically we could just arbitrarily assume role into pretty much any account and access any of the resources associated with it. So this is going to be the goal for the first part of our session today. Finding a vulnerability in the pass role implementation to allow us to weaponize a service against roles that trust it and access resources in victim accounts. So the first vulnerability is a confused deputy vuln in AWS AppSync. If you're not familiar with AppSync, AppSync is a managed GraphQL service offered by AWS. And it allows you to quickly and easily build GraphQL APIs. The way that it works is pretty similar to what I described with Lambda, where you first create an AppSync API in your account, configure it, set your schema, and so on. And then as a part of setting your data source, a role will be created for you that by default has a trust policy back to the AppSync service. Then, when your AppSync API is run, the AppSync service assumes that role and does whatever that API is supposed to do. And again, if you try to pass a role outside of your account, cross account pass role is not allowed. Now, I recognize this is DEF CON and I'm sure many of you are already trying to come up with ways that we can bypass this control. Things like unique encoding schemes, maybe something like HTTP request smuggling or maybe even something more exotic. These are all great ideas and I strongly encourage you to pursue them, but we actually found a much simpler approach to get around this. Through the power of Spongebob memes. See, under normal circumstances, the AWS API is typically case sensitive. And what I mean by that is, if you pass a parameter to the AWS API, it expects it in a very particular casing format. If you don't meet that expectation, you'll get an error. So to demonstrate this with a completely unrelated API, here we're performing secrets manager create secret. And that API expects a name parameter with a capital N. So long as you pass it in that format, 200 OK, everything works, you created a secret. However, if we were to deviate from that format in any way, in this case we've put it to all uppercase, we try to pass that to the API, it complains. 400 bad requests, member must not be null. The reason for this is, well we didn't pass the parameter it was looking for. It might be the right alphabetical characters, but it's not the specific one and so it rightfully so throws an error. While this may sound like a fairly obvious thing to point out, the reason it matters is that by comparison, the AppSync API was a bit of an oddity. It was not case sensitive. We could pass arbitrary parameters of mixed casing and the API would take it totally fine. Presumably somewhere on the back end it was normalizing these values in some way. Now, the parameter you would use to pass a role ARN to the AppSync service was called service role ARN, capital R, capital A. If you try to pass a role outside of your account, once again, cross account pass role is not allowed. But, if we change the casing on that parameter in any way, even on just a single character, in this case we made it all lowercase, and we try to pass a role outside of our account, for some unknown reason, whatever filtering or allow listing or checking that was supposed to occur, either didn't happen at all or completely failed. And so by changing the casing on a parameter, we were able to now arbitrarily specify roles for the AppSync service to try and assume. And so, we were able to break a major security boundary in AWS with Spongebob memes. To put this in another, in another context, what this allowed us to do, was to target any role that legitimately used the AppSync service in any AWS account. We could now provide that role to the service and arbitrarily assume it and access whatever resources were associated with it. This is an example of a cross service confused depi attack, where a lower privileged entity, in this case us, was able to trick or coerce a higher privileged entity, in this case the AppSync service, to do something on our behalf. And this scenario, that was assuming a role in a victim account. It's really important to stress, the thing that makes this possible, the thing that enables this attack, is that pre-existing trust relationship between those IAM roles and the AppSync service. Because the roles trust AppSync and because we found a way to weaponize that service against them, this is the path that allows us to assume those roles in victim accounts. Now, if you've ever done cross tenant attacks in AWS, you know that assuming a role is only half the battle. From here, we have to actually do something useful. If we were in a scenario where, say, we had a vulnerability similar to this, but we were limited to something like S3 list buckets as the only API call we could make, well yeah, it's not great. Um, I wouldn't be very happy of it if I was a defender, but at the end of the day, there's very little risk that could be demonstrated there. The good news for us is that in this scenario, the AppSync service is more than happy to provide. In particular, AppSync allows you to run arbitrary AWS API calls. So you now have the full spectrum of API calls that you can invoke at your choosing. Now for a step by step practical example of how we'd exploit this, as an attacker, we'd create our own AppSync API. Configure it, set the schema, create our data sources and so on. Then we would perform that pass role bypass to specify what role in the victim account we want to assume. And then, under normal circumstances, the AppSync service would assume the role in our account. But because of this vulnerability, it now assumes the role in the victim account and carries out whatever API operation we asked it to perform. The neat thing about this, from a attacker's perspective, is if you've ever done pentesting or red teaming in AWS, you know that one of the challenges you have is that you're trying to find credentials with access to things that you care about. And if you can't find them immediately, how can you move laterally, escalate privileges, find other credentials and things like that? It becomes a bit of a hassle. By comparison, with confused deputy attacks, you can just land as the identity of a production application. If there's a production AppSync API, it has privileges to do whatever that service needs to do. Whether that is upload S3, write to DynamoDB, read from RDS or anything else. Because we land as that role, we have access to whatever privileges are associated with it, and these tend to be fairly beneficial. So no need for weird bloodhound-esque lateral movement paths, you just pass that role and yow you're in. That's how we can do things like this in this screenshot, where we dump the contents of a DynamoDB table, cross tenant in AWS, by asking it to perform the DynamoDB scan operation. If you're interested in this vulnerability and you'd like to learn more, AWS did release a security bulletin for it, and in addition we have a blog post with a ton of additional information on conducting confused deputy attacks in AWS and some things to look out for. Um, the respective QR codes with the arrows will take you to each of those. Now, before we get to our next vulnerability, it's important that we learn a few things about assume role with web identity. Up until this point, we've been talking about plain assume role, which is typically used for AWS to AWS role assumption. As an example, if you have an AWS account and you would like me to assume a role in that account to do something, we'd probably end up using assume role. Now, while this is great, it does have sort of a limitation, in that it requires the entity doing the role assumption to originate from AWS. And unfortunately, there are a variety of use cases in which you might want to have an identity from outside Amazon have the ability to assume role in your account. What do you do? Well, that's where assume role with web identity comes in. The core idea here is that you essentially offload the responsibility of authorizing that role assumption onto an identity provider of your choosing. This can be a private identity provider, one that you or your company own and maintain, or it can be a public identity provider. Think things like Facebook, Amazon, Google, GitHub, and many others. The sort of core idea here is that your external users, whether they be human or machine, interact with the identity provider to generate a JWT, they pass that into the assume role with web identity call, and this enables them to assume a role in your account. Now, before we go any further, I really want to stress that assume role with web identity is a general design pattern. A variety of technologies and services, both native to AWS and outside of it, will use this general design pattern. In the next couple slides, we're going to use GitHub actions as an example, just to sort of explain how this works and talk a little bit more about the underpinnings, but really want to stress, this is not limited to just GitHub actions. To one common problem with CIC pipelines, particularly if they're outside of your cloud provider, if you're using something like GitHub actions, well, how do you authenticate to an S3 bucket if you wanted to upload, say, some sort of build artifact or logs or anything else? Well, we could use assume role with web identity. To set this up, we initially create a trust relationship between our AWS account and an identity provider. Since we're already using GitHub actions, we might as well use GitHub's provided identity provider. Once that trust is established, we then create an IEM role. And, like I said before, all roles have a role trust policy, and in that policy, we specify the identity provider as the entity that's allowed to assume the role. Then, every time our GitHub action job runs, it will retrieve a JWT that has been signed by that identity provider, that JWT is passed to an assume role with web identity call, and thus, that job at that pipeline is able to assume the role in our account and do whatever it wants to do, whether that is upload something to S3 or call any other API calls. Now, throughout that explanation, you might have noticed something a little bit scary and thought, perhaps I misspoke, or maybe I said something wrong. And I assure you, it's just as scary as it sounds. What you see here is the most basic, bare bones, simple trust policy you could possibly write when using assume role with web identity. And what it says is that we're going to allow the GitHub identity provider the ability to assume role with web identity. And that's a really scary thought, because if we think about it, GitHub's identity provider is public. It's global. Anybody has access to it. There's nothing stopping someone from creating their own GitHub account, creating their own GitHub action to generate a JWT signed by that very same provider, and passing that in to the assume role with web identity call, allowing them to access those roles in your account. If you had this trust policy on a role, anybody with access to a GitHub account could have just hijacked it and accessed anything associated with it. That's why any time you use assume role with web identity, with a identity provider that is public or global, you need to also have a condition which restricts specifically who is allowed to assume that role. Again, assume role with web identity is a general design pattern. The specific condition you'll need will differ depending on the service and what specific scenario you're in. To continue using GitHub actions as an example, you need to specify what GitHub repo or what GitHub organization is allowed to assume that role. If you're a heavy AWS user, strongly encourage you to audit your roles that use assume role with web identity for this misconfiguration, because again, if you make this mistake, theoretically anybody could just assume that role in your account, which is not optimal. Um, now the good news to all this is this attack that I just described was very much in vogue last year. A number of security researchers, including my own colleague Christoph, identified that this was a potential issue and raised awareness about it. If you'd like to le- learn a little bit more about the GitHub specific situation, uh, we have a blog post with a ton of details and that QR code will take you there. Uh, now to AWS' credit, they actually did something about this. In particular, they made what was once an optional condition, now mandatory. You can no longer create a role trust policy for the GitHub identity provider that doesn't include a condition. And so, that's good. Kudos to AWS, that's a great change. But, if we were to nitpick it, remember, I said assume role with web identity is used all over the place in a variety of contexts, and they only fixed it specifically to GitHub actions. Any of the other technologies or services that have this very same potential misconfiguration were slash are still vulnerable. So again, definitely encourage you to audit your roles. There is one such service that I'd like to dive a little bit more deeply on, uh, and that is Cognito. Uh, Cognito is a sign in as a service offering from AWS. If you want to store user credentials but you don't want to deal with the hassle of uh, hashing, salting, and things like that, you can pay Amazon a fee and they'll take care of that for you. One of the core features of Cognito is something called an identity pool. And an identity pool is a resource you can create in your account that allows you to distribute short-lived IEM credentials to your users so that they can assume roles in your account. As an example, say you're building a web application and you want your users to be able to upload content to S3 or invoke an API gateway using IEM off, the way you could achieve this is creating a Cognito identity pool, allowing your users to interact with it, to generate tokens, they would then uh, through a library in the client pass that to the assume role with web identity call and assume the role in your account. The good news about Cognito is that they seemingly foresaw the very same attack that occurred with GitHub actions. They do, by default, include a condition to defend against it. Specifically, the condition will restrict which identity pool is allowed to assume a role. And this is very important because if the trust policy looked like this, anyone in the world would be able to assume that role. And we're gonna talk about some reasons why that trust policy might look like this in just a little bit. Uh, the way that we can take advantage of it is slightly different than what we described with GitHub actions. This is mostly an implementation detail specific to Cognito identity pools. Specifically, what we're gonna do is use a uh, Cognito offload. Offloads are essentially like the, essentially the step by step operations uh, that a user would use to generate those credentials. There are two offloads currently supported, an enhanced offload and a basic offload, sometimes referred to as classic. We're gonna focus on classic because that allows us to actually specify the role we wanna assume because the final operation in this chain is assume a role with web identity. Um, the specific step by steps are as an attacker, we're gonna create our own Cognito identity pool. We're gonna, going to then perform get ID and get open ID tokens to generate that JWT. And once we have that JWT, we pass it in an assume role with web identity call and this allows us to assume the role in the victim account. So for our purposes, for the remainder of this talk, we'll refer to this as the Variant 1 Vulnerable Trust Policy. A trust policy tied back to uh, the Cognito service but not including a condition to restrict which identity pool is allowed to assume it. The reason we call this Variant 1 is because there's a Variant 2 as well. You might have noticed there's actually two conditions on the default trust policy associated with roles using Cognito. And this condition is the AMR condition, or the authentication methods references. And this value can be either authenticated or unauthenticated. You might wonder, could we assume a role if this condition was set? And turns out, yeah, absolutely, we totally could. If the value is set to unauthenticated, then literally everything I just said works completely the same, no changes required. If the value is authenticated, then we do have to jump through some extra hoops. In particular, in our attacker controlled account, we have to create a Cognito user pool, configure it alongside the identity pool, and then from there, basically all the same steps apply with some minor changes. All this condition is doing is checking that you are authenticated to an identity pool, not that you are authenticated to a specific identity pool. And since we can just create our own identity pool, we can configure it however we like, so we can add authentication if we need to. Now, earlier you might have noticed that I called this a misconfiguration, and that's because it is. The GitHub action stuff, this Cognito stuff, any of the other myriad of services which have this very same issue, all of these are misconfigurations, not a vulnerability. Had you suffered a breach, compromise, or other security incident as a result of it, well, unfortunately that would be your responsibility as a part of the AWS shared responsibility model. And so you're probably wondering, well Nick, I was promised a second vulnerability, you're calling this a misconfiguration, what gives? Well, uh, this is where things get weird, and we dive into our second vulnerability of the day, the AWS Amplify service exposing IEM roles to take over. Uh, see earlier this year when we noticed this capability in Cognito, one of the first questions we had was, okay cool, I wonder how common this misconfiguration is. And because it could be used for initial access, literally just assume rolling into victim accounts, we wanted to know if we could use publicly available data to find vulnerable roles and notify their owners so they could be fixed. To do this, we used a tool called Sourcegraph. One of the free features of which is essentially like a Google search, but for public GitHub repos. Uh, we we wrote a regular expression to find IEM role ARNs. Threw that into Sourcegraph, got back results, deduplicated them, removed like clearly placeholder ARNs, like account IDs with all one digit or incrementing digits, things like that. Uh, and that left us with a little over 8,000 results. We then tried to assume each role twice. Once authenticated and once unauthenticated. And we let our automation run and pretty much immediately it was clear, something was terribly wrong. Remember, this was across all of public GitHub. Across teams, organi- organizations, individuals and companies. So, why was it then that the overwhelming majority of roles that we found to be vulnerable all had this weirdly specific naming convention? What you see here on the slide are real, re- real roles that we found in the wild that were vulnerable that we have slightly modified the names of so as to respect the anonymity of their owners. Now, what made these roles so weird was that they all ended in either auth role or unauth role. And additionally, they had what appeared to be either a time stamp dating back to 2018 or 2019 or they had a six digit integer. Presumably, these were the newer ones. To make things even more weird, as we were going through the results, we actually found three roles that belonged to AWS themselves. And so at this point, it wasn't clear if this was some sort of, uh, tutorial gone wrong where somebody was demoing how to set this up with OIDC, not realizing that it was vulnerable and letting anybody just assume these roles in anybody's account. Uh, using source graph, we were able to see the name of the file where these roles were being found. And again, the overwhelming majority were found in files called team provider info dot Jason. And through this, this led us ultimately to the culprit. The thing that was causing all these roles to let anybody assume them. Turns out, it was AWS Amplify. Normally, when we're talking about a misconfiguration, we're talking about a mistake, misunderstanding, developers moving a little bit too quickly and breaking things, or not realizing that something is as vulnerable as it actually was. This was a rare circumstance in which an AWS service itself was exposing IEM roles, such that anyone could assume them. The vulnerability was not that you could misconfigure roles, it's that AWS was doing it to you. And fortunately, not just once, they actually did it twice. If you're not familiar with Amplify, Amplify is a uh, web and mobile application framework that lets you build these technologies. Uh, one of the core selling points to Amplify is essentially that uh, by using Amplify, it will abstract away a lot of the underlying infrastructure. So, if you build a web application and you want your users to be able to create accounts, sign up, change their password and so on, your developers don't even need to know what Cognito is. They can simply add authentication through Amplify, and Amplify goes in, creates Cognito resources, configures them, sets them up, and so on. Key emphasis, Amplify configures those Cognito resources. Now, there's two ways you can build an Amplify app or configure them. Uh, they're not mutually exclusive, you can use either or. Uh, there is the studio, which is the web console portal equivalent, and then there is the CLI, which you can run from your local machine, or as a part of your CICD pipeline. Now, typically when we do cloud security research, one of the challenges we often have is, it's not really clear why this vulnerable behavior is occurring. We might be able to see that something has security impacts, but it's not clear what exactly happened or why it's doing this. For example, with the first vulnerability, for some remarkably strange reason, changing the casing on a JSON parameter let us break a major security boundary in AWS. So we run into these types of scenarios fairly frequently. What's neat about this Amplify vulnerability, and why it's personally one of my favorites, is that this is actually a rare instance where we are able to know not only how did this become vulnerable, but when. That's because the Amplify CLI written by AWS is actually open source. And by digging through the commit history, we can see how and when these vulnerabilities were introduced. And we didn't know at the time, but later on in speaking to AWS employees, we came to find out that the Amplify Studio, the web console equivalent, actually uses parts of the CLI as libraries. And that's how I can tell you with confidence that both the Amplify Studio and CLI became vulnerable on or around July 3rd, 2018 to the Variant 2 Vulnerable Trust Policy, allowing anyone in the world the ability to assume these roles. What happened here is that any time you create an Amplify project, two roles are created for your account. An auth role and an unauth role, like we saw previously. Unfortunately, as a part of this commit, the default trust policy associated with those roles was set to this, which would allow anybody in the world to assume them. So if you thought you were building a private, internal only application that required authentication and you were gatekeeping who could create accounts so that you could protect your stuff, well, um, sorry, no you weren't. Anybody could just assume those roles and access whatever was associated with them. Like I said, that was introduced on July 3rd, 2018. A little over a year later, on August 8th, 2019, AWS sort of fixed this issue. Uh, seemingly unintentionally. What they did was they set the default effect to a deny and they removed the condition entirely. This is actually the exact same behavior we see today when creating a new Amplify project. It's really important to stress, though, that what this change did in August of 2019 was make it so that no future roles would become misconfigured. Any that had already been created were still vulnerable and that's how we were able to assume them in 2024. Later on in July of 2020, variant one was introduced to the Amplify CLI in studio. And this one was a bit more complicated than the previous one. What happened here was that, uh, like I said previously, you can add authentication to an Amplify project. If at any time you chose to remove authentication for any reason, that would introduce the variant one policy. Uh, in speaking to developers who were affected by this, it seems the most common reason that this occurred was situations in which, uh, uh, projects started with the built-in Amplify controlled Cognito resources and then at a point, uh, went to Cognito outside of Amplify or to just a different identity provider entirely. Regardless of the reason why, what occurred was that a cloud formation template would run that would start setting the default trust policy to what you see on the slide, which is totally fine. This is the secure trust policy. However, under the line, uh, under the condition for the deletion of the authentication configuration, there was a line to delete the condition off of the trust policy, which left you with this. The variant one vulnerable policy. Whatever identity permissions were associated with this rule, when this exposure occurred, it still had access to. So, if your rule could do something like, uh, read from an S3 bucket, write to a demo deep table, it still had that access. Additionally, at the end of the day, these are just plain IEM rules. And unfortunately, developers love to over-privilege their identities. When we were reacting to this vulnerability and notifying customers so they could mitigate it, we found a number of customers who had highly privileged roles, including some with S3 full access, Kinesis full access, and more. Unfortunately, as a part of this vulnerability, now anyone could have just accessed them and then accessed whatever resources were associated with those accounts. Uh, like I said, that was introduced in July of 2020, and then between then and when we eventually disclosed in 24, more and more rules were becoming misconfigured. One thing I'd really like to stress, uh, that makes this Cognito issue even more extreme, is that Cognito role ARNs are easily discoverable. If we compare this to the first vulnerability we talked about today, a confused deputy vol in some AWS service, an adversary still has to contend with the challenge of finding role ARNs. To be clear, an ARN is not a secret, not in the same way a password or API key is, but it does represent some level of challenge. They would have to brute force them, enumerate them, derive them from IAC, pull them out of build logs, rip them out of GitHub like we did, or a myriad of other ways. Suffice to say, it's something you could do across, say, a small number of organizations, but not something that you could easily scale to the size of the internet. By comparison, the whole point of Cognito is that these roles are supposed to be available to your users. They're basically public. And in addition, they're also deterministic, in the sense that if you know the unauth role, you now also know the auth role by default. And so what an adversary could have done is simply taken advantage of the default domain associated with Amplify apps to suddenly crawl tens of thousands of apps looking for vulnerable roles. And to be clear, the majority should be fine, but undoubtedly some number of them were created between July, or sorry, uh, 2018 and 2019, or who have since changed their authentication configuration since July of 2020. Like I said before, we did disclose this to AWS in January of this year, and AWS released comprehensive fixes in February and April. Uh, they did the same thing they did with GitHub Actions, where you can no longer create these vulnerable trust policies anymore. But in addition, they sort of went above and beyond. Specific to this Amplify issue, they actually made changes to STS so that you can no longer assume a role cross-account in AWS. So even if you had a variant 1 or variant 2 role in your account, somebody from a different account can no longer assume it. If you'd like to learn more about this vulnerability, AWS did release a security bulletin for it, and we have a blog post here with a ton of additional content and information on carrying out these types of attacks, how we found this vulnerability, and more advice on dealing with assume role with web identity. Really quickly though, I did want to mention, um, throughout this talk, we have been focused on creating resources in an attacker account so that we could then victimize a victim account. The reason for doing this is simplicity. If you own the resource, you can configure it, you can set it up however you like, you know it will always be available, you can troubleshoot it, but I wanted to mention it's not strictly required, it's just easier. Specific to the Amplify vulnerability, they fixed cross-account role assumption using identity pools. It's no longer possible for me to use one of my identity pools to assume a role in your account. But they didn't do anything about the same account scenario. And to be clear, I don't really think there's much they could do. Uh, the reason they were able to block cross-account assume role using this is, well that's, that's a very weird thing to do. It's very likely zero if any real organizations were doing this in the wild. And so they said hey, we can just block this off, we can fix this attack vector and we'll mitigate a lot of the risk. But you can still absolutely do this in the same account and this is something that you can still take advantage of today. Um, to be clear, this is more difficult, things are much nicer if you can just bring your own identity pool, but it's definitely something to be aware of if you are penetration duster, red teamer, or you simply use Amplify a lot. The way this would work is that if there is a variant one or variant two role in that account, if there is also a identity pool that is configured with basic authentication or the basic offload, not necessarily associated with Amplify, just any cognitive identity pool with that enabled, you as an external adversary can still interact with that identity pool, generate a JWT, pass it into Sumo with WebIdentity, and still assume one of those variant one or variant two vulnerable roles. Um, in the bottom left hand side, there's a QR code that will take you to a Hacking the Cloud article that will walk you through step by step how you can do this in both authenticated and unauthenticated environments. With the time we have left, I wanted to talk a little bit about what we can do to prevent cross tenant attacks in AWS. To be clear, uh, your time is probably much better spent doing things like deleting old access keys, uh, cleaning up old IM users, following least privilege, and so on, but if you're already doing all those things, or you have the technology and processes in place, it might be helpful to know that we do have some controls that can potentially prevent some of these attacks. In particular, AWS offers us a number of condition keys that allow us to restrict essentially where an adversary is coming from. Sort of similar to what we saw with a Sumo with WebIdentity previously. These conditions allow us to restrict either the ARN, the account, or the organization that is permitted to assume a role. It's really important to stress, these are not included by default, uh, if you were to try to create an instance profile today, it wouldn't automatically add one of these, so you would have to manually attach these conditions to each role you want to assume, or want to protect, and more importantly, make sure that those services are compatible with these condition keys. From some nominal testing, EC2, Lambda, AppSync, all work totally fine, but again, really encourage you to test before you try pushing this into production. To demonstrate how this would work in practice, uh, using source account as an example and tying us back to the first, uh, confused deputy attack we had in AWS, uh, by exploiting this vulnerability, an adversary would be able to assume a role which trusted the absent service. But if we had set a condition key on that trust policy, limiting what AWS account is permitted to assume that role, it would successfully block that adversary. The way we know this is back in the day when this vulnerability was present, we were able to actually test setting that condition key, and it did successfully block an external adversary. So even in that worst case scenario of someone having a cross-tenant zero day in AWS, by setting this condition key, we can block that access. The other reason I like this is from a defense in depth perspective. If pass rule says, under absolutely no circumstance should someone be able to assume a role cross-tenant, well great. We broke that with Spongebob memes. So the next time that happens, or if somebody finds a more inventive way around it, let's have an additional layer of protection to block these types of attacks. You're also unlikely to run into many issues. If it works, it's very unlikely to cause, uh, problems. It's, this is more of a static thing that stays the same over time. So in conclusion, we took a look today at how confused epi attacks can weaponize cloud services against us. We took a look at a very dangerous misconfiguration when using assume role with web identity. And again, I strongly encourage you to audit your roles that use it, because if you make this mistake, theoretically anybody can assume roles in your account. It's an easy mistake to make. AWS actually made it twice. Um, and then we also took a look today at how we can use, uh, condition keys to block confused epi attacks in AWS. If you enjoyed this talk, you can find more of our research at securitylabs.daydoghq.com. If you have any questions, feel free to find me after or reach out to me on social media. Again, my name's Nick Furchette. Thank you all so much.