Kuboid
Open Luck·Kuboid.in
Black Hat2024
Open in YouTube ↗

The GCP Jenga Tower: Hacking Millions of Google's Servers With a Single Package

Black Hat1,730 views33:05about 1 year ago

This talk demonstrates two novel privilege escalation vulnerabilities, CloudImposer and ConfusedFunction, affecting Google Cloud Platform (GCP) services. The researcher shows how misconfigured package installation processes and over-privileged default service accounts allow attackers to gain unauthorized access to internal cloud infrastructure. The presentation highlights the risks of supply chain attacks in cloud environments and provides actionable guidance for securing CI/CD pipelines and service account permissions. The researcher also introduces a new tool, Jenganizer, designed to reveal hidden cloud services and potential attack paths.

How Misconfigured GCP Package Installations Lead to Full Cloud Takeover

TLDR: This research exposes two critical vulnerabilities, CloudImposer and ConfusedFunction, which allow attackers to escalate privileges within Google Cloud Platform by exploiting insecure package installation patterns and over-privileged default service accounts. By manipulating pip configurations and targeting the default Cloud Build service account, an attacker can achieve remote code execution across the cloud environment. Security teams must audit their CI/CD pipelines for the use of --extra-index-url and enforce the principle of least privilege for all service accounts.

Cloud security is often treated as a static perimeter, but the reality is that your infrastructure is only as secure as the weakest link in your automated deployment pipeline. The recent research presented at Black Hat 2024 regarding the "GCP Jenga Tower" proves that even the most sophisticated cloud environments can be compromised through simple, yet devastating, misconfigurations in how they handle dependencies and service identities.

The Mechanics of CloudImposer

Dependency confusion is not a new concept, but its application in managed cloud services like GCP Composer creates a massive blast radius. When a developer or a CI/CD process attempts to install a package, they often use the --extra-index-url argument in pip. The vulnerability lies in how pip handles this flag. It does not prioritize the private registry over the public one; instead, it queries both and installs the package with the highest version number, regardless of its source.

An attacker can identify internal package names used by a company—often leaked through public repositories or inferred from common naming conventions—and upload a malicious package with the same name but a higher version number to PyPI. When the target's build process runs, it pulls the malicious code from the public registry, leading to immediate remote code execution.

The command that triggers this behavior is deceptively simple:

pip install --extra-index-url https://privateregistry.com/simple/ legit-package

If legit-package exists in your private registry at version 0.1, an attacker simply uploads version 0.2 to the public PyPI. pip will happily fetch the malicious version 0.2, executing any post-install scripts defined in the package. This is a classic OWASP A06:2021 – Vulnerable and Outdated Components scenario, but amplified by the automated nature of cloud-native deployments.

ConfusedFunction and Privilege Escalation

While CloudImposer targets the build process, ConfusedFunction targets the identity layer. GCP Cloud Functions often rely on a default service account to manage the deployment lifecycle. This account, by default, is frequently granted broad permissions to interact with other services like Cloud Build, Artifact Registry, and Cloud Storage.

The vulnerability occurs when an attacker with the ability to update a Cloud Function modifies the package.json or requirements.txt file to include a malicious dependency. Because the function deployment process uses the default service account to pull these dependencies and build the container image, the attacker effectively inherits the permissions of that service account.

If the default service account has roles/artifactregistry.writer or roles/storage.objectAdmin permissions, the attacker can use the build process to exfiltrate sensitive data, modify other container images, or even pivot into the underlying Kubernetes cluster managed by Google. This is a direct violation of the Principle of Least Privilege, as the service account is performing actions far beyond what the function itself requires.

Real-World Impact for Pentesters

During a penetration test, you should focus on the CI/CD pipeline rather than just the application code. If you gain access to a repository or a deployment configuration, look for the use of --extra-index-url. If you find it, you have a clear path to dependency confusion.

For privilege escalation, inspect the service accounts attached to your target's Cloud Functions. Use the GCP Log Explorer to search for create or created events. If you see a Cloud Function triggering a Cloud Build process, you have identified a potential ConfusedFunction vector. The impact is often a full compromise of the project, as the service account's permissions are usually sufficient to create new resources or exfiltrate secrets from the environment.

Defensive Strategies

Defending against these attacks requires a shift in how you manage your build environment. First, stop using --extra-index-url for private packages. Instead, use the --index-url argument, which forces pip to look only at the specified registry. If you must use multiple sources, look into Artifact Registry virtual repositories, which allow you to control the priority of your package sources.

Second, audit your service accounts. Every Cloud Function should have a dedicated, custom service account with the absolute minimum permissions required for its operation. Never use the default service account for production workloads. You can use tools like Jenganizer to map out the relationships between your services and identify hidden attack paths that might be created during deployment.

The cloud is a complex, interconnected system. When you pull a single package, you might be pulling the entire Jenga tower down with it. Keep your dependencies locked, your service accounts restricted, and your logs monitored. If you aren't looking at what your build process is doing, you are already behind the curve.

Talk Type
research presentation
Difficulty
advanced
Has Demo Has Code Tool Released


Black Hat USA 2024

121 talks · 2024
Browse conference →
Premium Security Audit

We break your app before they do.

Professional penetration testing and vulnerability assessments by the Kuboid Secure Layer team. Securing your infrastructure at every layer.

Get in Touch
Official Security Partner
kuboid.in