Skip to main content
Back
DemonstrationGoogle Cloud
7 min read

Orca Security's Bad.Build demonstration on Google Cloud Build

Environment
A Google Cloud test project Orca Security set up for the demonstration
When
not stated; before the Jul 18, 2023 write-upDisclosed Jul 18, 2023
Entry
A service account that could only create Cloud Build builds submitted builds whose steps ran as the project's default Cloud Build service account.

The Orca Research Pod staged Bad.Build in its own Google Cloud test project: a service account that could only create Cloud Build builds submitted builds whose steps ran as the project's default Cloud Build service account. Acting as that account, the build read the project's IAM policy from audit logs, pulled a production image from Artifact Registry and sent it to an outside server, then pushed back a copy with a web shell that GKE deployed. Google's bulletin GCP-2023-013 removed one log permission from the account and kept its other defaults, a fix Orca called partial.

What the demonstration did

Outside parties
Orca Research Pod
External HTTP server
Internet
Google Cloud APICloud Build
Cloud Build project
Artifact Registry and GKE
Build-creating principal
Default build service account
IAM audit logs
Production repository
GKE deployment
Public LoadBalancer

Replaying Orca's Bad.Build demonstration / published July 2023; the run date is not stated

  1. 1

    Build identity inheritance

    Not dated · before Jul 18, 2023

    A principal that can only create Cloud Build builds submits one, and its steps run as the project's default Cloud Build service account.

  2. 2

    Reading the project's permissions

    Not dated · before Jul 18, 2023

    As that account, the build reads setIamPolicy audit log entries, which carry the project's full IAM policy.

  3. 3

    Artifact Registry access

    Not dated · before Jul 18, 2023

    The build pulls the latest production image from Artifact Registry and sends it to an outside server; the researchers add a web shell and the build pushes it back.

  4. 4

    Automatic deployment

    Not dated · before Jul 18, 2023

    GKE deploys the replaced image, a LoadBalancer exposes it, and the web shell runs commands as root; what triggered the rollout is not stated.

Impact

In Orca's own test project, the build replaced a production image in Artifact Registry, which GKE deployed, and a web shell ran commands in the container as root; the downstream outcomes Orca names (denial of service, data theft, malware distribution) are projected, not demonstrated.

Outcome

What Bad.Build shows about your build identities

One permission to create builds was enough, because every build ran as the project's default Cloud Build service account and acted with its role. On your Google Cloud projects, IAM deny policies on that account refuse the audit log reads and the image pull and push. A Binary Authorization policy admits only images with a required attestation at deploy time, which bounds the deployment only where the build account cannot sign attestations. A deny policy on who may create builds bounds the entry only for principals outside its approved set. Google's June 2023 fix removed one log permission and kept the account's other defaults, and a project whose first build ran before the May–June 2024 change keeps the legacy account as its default.

Would the controls have stopped it?

In hindsight, not as a whole. 3 controls would have refused a step outright, and 2 controls would have limited one. The counts below are control assessments, not attack stages: several can address the same step. The same replay with the controls in place before the incident shows where each phase would have been refused or bounded.

3
Prevented
2
Contained
0
Not covered

How it could have been prevented

The same replay with the controls in place. Green marks where a step is refused, blue where it is bounded, and red where no control reaches it. Open a row to read the control, why it acts, and its caveat.

Outside parties
Orca Research Pod
External HTTP server
Internet
Google Cloud APICloud Build
Cloud Build project
Artifact Registry and GKE
Build-creating principal
Default build service account
IAM audit logs
Production repository
GKE deployment
Public LoadBalancer

Replaying Orca's Bad.Build demonstration / published July 2023; the run date is not stated

1 · Build identity inheritance

1 Contained3 on other clouds

2 · Reading the project's permissions

1 Prevented3 on other clouds

3 · Artifact Registry access

2 Prevented6 on other clouds

4 · Automatic deployment

1 Contained3 on other clouds

Key facts

  • The demonstration started from a service account made for the test that held the Dataflow Developer role, which includes cloudbuild.builds.create; Orca wrote that this was the only permission required
  • Build steps ran as the project's default Cloud Build service account, whose default role was the Cloud Build Service Account role
  • The build read the project's IAM audit log entries; each setIamPolicy event carries the project's full IAM policy
  • The build listed Artifact Registry, pulled the latest image of a repository used for production GKE deployments and sent it over HTTP to a server outside Google Cloud; the researchers added a web shell and the build pushed the image back, GKE deployed it and the shell ran commands as root
  • Google revoked logging.privateLogEntries.list from the Cloud Build legacy service account in bulletin GCP-2023-013 on June 8, 2023 and kept its other default permissions; Google told TechTarget the fix was based on Orca's report, and Orca called it partial on July 18, 2023
  • In May and June 2024, Cloud Build made the Compute Engine default service account the default for projects whose first build runs after the change; no source ties that change to Bad.Build

Sources

Every fact in this breakdown comes from the public reporting below. The replay is a model of that reporting, not a reconstruction of the environment it describes.

  1. 1.
    Bad.Build: A Critical Privilege Escalation Design Flaw in Google Cloud Build Enables a Supply Chain AttackOrca Security · Jul 18, 2023 · ResearchStarting permission and role, builds running as the default Cloud Build service account, audit-log read of the project's IAM policy, Artifact Registry listing, image pull and exfiltration, image modification and push, GKE deployment and web shell, Google's partial fix
  2. 2.
    Cloud Build security bulletins: GCP-2023-013Google Cloud · Jun 8, 2023 · AdvisoryFix date and the private-log listing permission revoked from the Cloud Build legacy service account
  3. 3.
    Orca: Google Cloud design flaw enables supply chain attacksTechTarget · Jul 18, 2023 · NewsGoogle's statement that its June bulletin was based on Orca's report
  4. 4.
    Cloud Build service account changeGoogle Cloud · undated · Vendor reportThe May–June 2024 change of the default build service account and the projects that keep the legacy account

The estate in the replay follows the researchers' description of their own test environment. Verdicts describe what a control does when it is in place before the run. They are not an assessment of any company's security program.

More cloud attack breakdowns

All breakdowns