Agents of Chaos: A Systemic Approach to Finding GCP 0-Days
Transcript
Machine-transcribed by YouTube. Expect errors in names, commands and version numbers.
Morning everyone and welcome to agents of chaos, a systemic approach to finding GCP zero days. I know most of you spend your days thinking about cloud security and how we can improve it. But today I want to offer you a perspective that you might not be as familiar with securing the cloud by finding and disclosing zero day vulnerabilities in the cloud infrastructure itself. My name is Mosha Bernstein and I'm a staff security researcher at Teneal. I'm also a bug hunter with the Google VRP, mostly hacking on Google Cloud, and I'm ranked number 10 in the all-time VRP leaderboard for US researchers. When I'm not researching Google, you'll probably find me traveling and seeing new places.
This is what we're going to go over today. We'll start with a quick introduction where I'll talk about the concept of GCP service agents. I'll then share with you my methodology for using these service agents to find PE vulnerabilities in the cloud. We'll then work through that methodology in two different case studies and then I'll share with you a tool I developed that can help you find these bugs too and finally some key takeaways. So let's talk about GCP service agents. You might be familiar with the concept of service accounts, but service agents are a special kind of service account that are fully managed by Google.
They're called the per product per project service accounts or P4SA for short. They're created and inserted automatically into your cloud project as you use GCP services. What's their responsibility? It's orchestrating the background tasks and cross-ervice communication. What does that actually look like? Let's say we have a GCP user who has access to a service called Cloudr Run. Cloudr Run is a fully managed containerized application service. For Cloud Run to work properly, it needs access to some underlying dependencies of other cloud services like artifact registry, networking, storage, and compute. Behind the scenes, Cloud Run uses the special service agent identity, which comes with permissions for these dependencies out of the box, and it's the one who's responsible for making those calls. Now, let's imagine that the user was compromised in some way. If the user could use their access to CloudRun to gain access and exploit the underlying service agent identity, they would theoretically be able to escalate their privileges to all of these services, too. Now, you might be familiar with some research by people like Seth Art, which map privilege escalation paths in AWS. In Google Cloud, this works a little bit differently. You shouldn't have any privilege escalation paths out of the box. If you find a privilege escalation path where you have permissions for service A and can gain meaningful control over service B, that's most likely a P vulnerability that Google want to know about and fix.
Now, I want to share with you my methodology for finding these types of P vulnerabilities. It's a four-step simple process that's repeatable across the cloud and can be used to find these types of vans. Step number one is picking your target. This might be the most intimidating step since the attack surface for Google Cloud is really vast. But I urge you to search for interesting permissions. Google upload all of the permissions for every single service to their documentation. So you can search for interesting permissions of roles or service agents. You can also try and look at underexplored services. The services we all know and use all the time might have more eyes on them like other researchers or security engineers, but there's lots of services in Google Cloud and some of them might have a little more bugs in them.
And finally, I'm a true believer that the more you use a console, the more you research, the more you just play around with it, the more bugs you'll find just as you go. Once you've picked your target, the second step is to understand the service as deeply as possible. That means use the UI as much as you can. Click every button, change every form, and read the detailed documentation. You should also monitor the network requests in the back end to understand how the API works. Once you understand the service, you may find several powerful primitives that are just features of the service and can be used in a future vulnerability.
Once you know these primitives, step number three is to think like an attacker. If I had access to these features and malicious intent, what would be the missing piece of the puzzle that I needed in order to gain something from this environment? Once you understand that, the final step is to escalate your privileges. That means leverage the findings in order to expand your access. Use your permissions for service A to gain meaningful control over service B. As we said earlier, this is probably a vulnerability in GCP. As you can see, I assigned icons for each of these steps so that you can follow along as we work through this methodology in the two case studies.
So, let's start with the first case study, which is a service called cloud monitoring. Cloud monitoring is part of the observability suite, and it automatically monitors GCP services as you use them. You can visualize the status of these services using dashboards and you can create alerts and notifications to proactively let you know if something happens. So why did I choose cloud monitoring as a target? Well, it's actually part of the core infrastructure of the cloud and it also has access to data from tons of other services. As a bug hunter, this led me to believe that a vulnerability here would be impactful. But also, and I don't know if this is relevant to anyone else here in the room, but I found vulnerabilities there in the past, so I had a good hunch that it was a good target.
Now, cloud monitoring has tons of different features and a very wide scope. So, I want to focus today on only one, which is called uptime checks. Uptime checks are just a way to periodically test your internal services or servers and let you know if something goes wrong. It periodically just sends a HTTP request and if something changes, you can get an alert for it. So, let's use the UI to create an uptime check together so that we understand the features. The first step is choosing a target for your uptime check. This is what the uptime check will actually be testing against. We have full control over this target. We can control the protocol. We can control the resource type which is right now an arbitrary URL. But we can change it to be any number of internal services like cloud run that we discussed earlier. We can also control the target itself by changing the host name or the path. At the bottom, we see more target options.
When we click that, we actually see that we gain full control over the underlying HTTP request too. We can control the method. If we change that to post, we can control the body too. Google allow us to add custom headers if we want or authentication. They actually give us the ability to use the service agent for monitoring to authenticate using these uptime checks. You can tell it's a service agent because of its special email that has gcp-sa in it. This one is the monitoring notification service agent for example.
Once you've picked your target, you can then review the uptime check. That means give it a name and Google suggests that you test it just to make sure that your configuration works properly. So just by using the features of uptime checks, we have access to some pretty powerful primitives. An arbitrary target, full request control, and service agent authentication. At this point, we're only missing one piece of the puzzle to make this a vulnerability. So now it's time to think like an attacker. Who can actually create these uptime checks? When I was looking at the roles for uptime checks, I saw this extremely weak monitoring uptime check configuration viewer role. The only permissions it had were get and list.
When I gave myself this role, I couldn't click the create uptime check button because I didn't have the appropriate permissions. But that's never stopped me. This is just a button. What if I browse to the create URL directly? So that's what I did. And as expected, I got you need additional access. However, it seems there's some kind of race condition here behind the scenes cuz all I needed to do was wait for maybe 1 second and then the creation UI opened. Anyway, [snorts] you can see it here in real time. I'm opening a new tab, typing in the URL, and pressing enter. You'll then see you need additional access for maybe a second and then it disappears and shows the UI anyway.
Blink and you'll miss it just like magic. Okay, so we can access the creation UI as a role that has no permissions to create uptime checks. What does this actually give me? If I try to create an uptime check, I'd get permission denied as expected. However, do you remember that I told you earlier that Google suggests that we test our uptime checks before creating them? What happens if I click test? Well, when clicking test, I actually get a response from my server. This means that a readonly user with no creation permissions can configure an uptime check in whatever way that they want, including using service agent authentication and then test it. So now we have the full picture. Arbitrary target, full request control, service agent authentication, and the final missing piece of the puzzle, weak user invocation. Now that's a full vulnerability.
So how can we actually exploit this? Let's say we have uptime check viewer in a project that is compromised. In that same project, there is a powerful cloud run that updates people's IM permissions. The creators of this tool knew it was very powerful, so they hid it behind strict authorization checks. If the uptime check viewer were to try to call this cloud run directly, they'd obviously get permission denied. However, what if the uptime check viewer were to open the creation UI for uptime checks and then test an uptime check which authenticates as a service agent which invokes the cloudr run. The service agent for monitoring comes with cloudr run invocation permissions out of the box. So theoretically this should work and then escalate the uptime check viewers permissions. So let's see if we can actually get it to work in real life.
We can see here that the attacker only has the monitoring role I told you about earlier in the project.
Sorry, we'll go back. You get to see my taskbar now. Currently [snorts]
in the same project there is an IM updator function that requires authorization and authentication. The uptime check viewer can't click the create uptime check button and they can't call the cloud run directly. But if they browse to the URL directly, they will then get access to the UI. Since they have full control over the target and the underlying request, the attacker can target the authenticated cloudr run and then use service agent authentication. They can also change the underlying HTTP request to use post and put whatever body they want. All the attacker then needs to do is test the uptime check which will send the underlying HTTP request and theoretically grant them elevated privileges. So let's see if that worked.
Going back to the IM page after we got a 200 okay from the cloud run, we actually see that the attacker is an editor in the project. That's the most powerful role in Google Cloud from a completely arbitrary feature of cloud monitoring in a readonly role to the most powerful role. This is the disclosure timeline for this vulnerability. As you can see, Google awarded me $9,000 for it. So even though the vulnerability may seem simple, they clearly value these types of vans very highly. Now let's move on to our second case study which is a feature a service named event arc. Event arc is a fully managed platform for building event-driven pipelines between GCP services. Events arrive in something called a bus which is just a sync for events and then they get ingested by something called a pipeline which applies some kind of logic to them and moves them on to another target. The target can be an arbitrary URL or a bunch of internal cloud services.
So why did I choose event arc as a target? Well, it's a very powerful service that connects a bunch of other services. Also, as powerful as it is, I don't think a lot of people are familiar with event arc. It seems to be a little obscure. And as a bug hunter, this automatically led me to believe that there might be more bugs there. And when I was looking at the documentation for event arc, I saw that it has a highly privileged service agent. So once again, this piqued my interest. So let's go ahead and use the UI once again to create an event arc pipeline. When creating a pipeline, you enroll a pipeline to a bus which essentially tells this any event that arrives in this bus should trigger the pipeline.
Once you choose an enrollment, you can move on to choose the destination. As we saw earlier in cloud monitoring here, it's kind of similar. We have control over the type and the destination. We can also control the underlying request using this message binding feature here. And at the bottom, we have a tick to enable authentication. When we enable it, we see that we gain full control over the underlying authentication. We can control the header, what kind of token it will use, like an OS token or an OIDC token. And we can control the identity using the service account here. Notice that it says service account and not service agent. This is limited to human created service accounts.
So what primitives do we have just by using the features of this service? Arbitrary target, full request control, and service account authentication. This should already be seem familiar to you and your spidey senses should already be tingling and telling us that we're only missing one piece of the puzzle to make this a vulnerability. So now it's time to think like an attacker. Who can actually act as? If you didn't know in Google cloud whenever you want to use a service account you need a special permission that's called the IM service accounts act as when we look at the roles for event arc even the administrator which is the most powerful of them doesn't have this permission built in. When I gave myself this role and no IM service accounts act as permission, I was still able to use event arc as much as I wanted. This led me to believe that you don't actually need this permission in order to use event arc. But what gives? I just told you a second ago that you needed to use service accounts and we saw that you can use service accounts as part of event arc. Well, when we look at the roles a little bit further, we actually find the culprit. It's the service agent who is acting as the service accounts. You can see that the service agent does have this act as permission along with the get access token and get open ID token permissions. This fully correlates to what we saw earlier in the UI where we could choose an arbitrary service account and then choose which token to use. This is actually overly simplified version of the service agents permissions since it's so powerful I couldn't even fit all its permissions on the slide.
Now, seeing how powerful it is and seeing that the service agent is the one who's acting as arbitrary service accounts, I wonder to myself, what if I can trick the agent into acting as itself? This could theoretically give me access to it very powerful permissions, which would be a great escalation of privilege. So, that's what I did. I created a pipeline using an arbitrary service account and in the back end using search and replace, I changed the email of the service account that I chose to the email of the service agent. And guess what? I was able to create a pipeline that authenticates the underlying service agent identity. As I said earlier, you can tell it's a service agent because of the GCP-SA email. So now we have the full picture again. Arbitrary target, full request control, service agent authentication, and the final missing piece of the puzzle, weak user invocation. Now that's another vulnerability.
So how can we actually exploit this? Well, let's say we have an eventark user who's compromised in some way. In their own project, this attacker could create a malicious HTTP server that logs any tokens that it gets. The event arrang
pipeline using the service agent trick I told you. When the pipeline is triggered, the service agent should theoretically browse to the attacker controlled server and then excfiltrate the token back to the user, giving them full control over the project with the powerful service agent identity. So, let's see if this works. Here we can see that in the victim's project, the attacker only has eventark roles. In their own project, the attacker creates this malicious cloud run that excfiltrates any authorization tokens it gets. The attacker then goes to event arc. It doesn't need to create a a sync since one already exists here. So, they go straight ahead and create a pipeline.
When creating a pipeline, they choose arbitrary details like name and region. And then they will enroll this pipeline to the existing sync.
Once enrolled, the attacker can control the destination and they can even target their own malicious cloud run from their own project. They can then enable authentication and choose an arbitrary service account to use there.
In the back end, using search and replace, the attacker can change that service account's email to the service agents email. This will create the pipeline using the underlying service agent identity. Normally users are not allowed to access service agents unless it's a explicit feature. So now all the attacker needs to do is send a request with a message to the bus which will trigger the pipeline.
Once the pipeline is triggered, the service agent authenticates to the attacker's server and the token is exfiltrated. Now from a arbitrary role in a random service that not many people know about once again to full control over a project. This is the disclosure timeline for the second vulnerability. As you can see, Google awarded me $12,000 this time. So using a repeatable methodology across multiple different services, we're able to find bugs that are worth tens of thousands of dollars. That's pretty cool. And now I want to share with you a tool that will allow you to find these kinds of vulnerabilities yourself. It's called Agent Map. It's a tool I developed to help us use these service agents and find privilege escalation vulnerabilities.
Agent Map maps all of the service agent permissions by scraping the Google Cloud documentation. It then visualizes the connected nature between the services using these permissions. Let's imagine that the service agent for service A has access to service B. This allows us to understand that service B is a dependency of service A and you can see that in agentbound. It will also highlight to you the dangerous permissions and privilege escalation paths and allow you to understand what the good points are to continue the research. Now, we don't have much time today, but I still want to show you a quick demo of agent map.
This is what agent map looks like. I hope you can see it. All right. On the left here, we have the data set and a filter. And in the center, we have our graph. Now, I want to show you, it's currently showing you all of the services that we're monitoring, but I want to show you a pre-filtered version which only shows our two case studies. As you can see, the two case studies have the service agents that we saw in our research associated with them. If we click on the monitoring service agent, we actually see all of the dependencies of cloud monitoring by understanding the permissions of this service agent. On the right here, we have additional information. If we scroll down, we can see a full list of the permissions for this service agent, including the run routes invoke permission, which was relevant in our vulnerability. If we go back to the full graph and click on event arc, we actually see something interesting. Several of these dependencies are shared between the two services. This gives us some insight into how the cloud is built. Services are built upon other services. At Tennable, we like to call this the Jenga model, like a Jenga tower.
When we click on event arc, we actually see the same detailed information as earlier, but this time agent map is highlighting to us that four of this agents permissions are escalation relevant. When we scroll back down, we see the three IM service accounts permissions which were relevant for our vulnerability. Now, this is just a teaser, but a map is fully open source and free. So, I hope you check it out for yourself and see how helpful it can be in finding these types of primitives. This is what agent map looks like when I first developed it. So, thank you to Claude for gaining so many capabilities and making it look so much better.
So, what are our takeaways from today? Well, first of all, there's an invisible threat in Google Cloud and it's called service agents. As a bung hunter, these service agents are a great opportunity for us since they come builtin and have usually very privileged permissions. The second takeaway is that the cloud is built on recurring patterns. These recurring patterns allow us to use repeatable methodologies to find similar kinds of bugs across multiple different services. And finally, you can use a tool like agent map to visualize the interconnected nature of the services in the cloud and find further avenues of privilege escalation research. Now it's your turn. Go and find some zero days and feel free to reach out to me and let me know if you found something cool using my methodology. And feel free to check out agent map on GitHub over here.
Thank you so much. [applause]
Do we have any questions?
So the 9,000 and the 12,000
is that I mean I'm looking at full privilege escalation to editor and owner in a in a project, right? Like is that a
reasonable payout amount or that seems a
little low, but I'm not in the bug bammy space. So, >> so the I don't think it's low. I think
it's pretty accurate since the attacker needs a certain amount of privilege to begin with in order to gain yeah that kind of access. Um, all of the bounty amounts for Google are very clearly showcased on their website for the bug hunters website if you want. You can see what each type of privilege escalation what kind of bounty that will give. Google do have some agency and they might flex it a little bit if the exploit exploitability likelihood is low or if it needs some really crazy privileges, but generally within the same project, if the attacker needs some kind of per permissions to get their foot in the door, it will probably be around that $10,000 range. Got it.
Anybody else?
Hey. Um, how how kind of confident or bullish are you about finding more zero days now that uh Mythos is out, Fable is out, all these amazing frontier models are there? And I guess Google are using them themselves, right? Sorry. >> Yeah. Um I was kind of expecting this question honestly and first of all I would like to say that specifically these kinds of vulnerabilities and this kind of methodology where you're kind of using the UI and the back end in tandem I don't find it to be something that AI is quite capable of doing as well as researchers to today. I'm sure that in the next in the very near future it will get better and succeed in these kinds of things. But also you have to remember that we have access to mythos in Fable 2 or whatever LLM or agent you want to use. So I see it as a like empowering
tool that researchers whether in Google or outside of Google can use. And um from my experience with bug bounty hunters, nothing will ever stop them. Like there's always going to be more bugs and they're going to find more new and creative ways to find those bugs and um disclose them. So hopefully it's not, you know, something that'll ever stop us. >> All right. Well, thank you very much. >> Yeah. Thank you. [applause]





