Wiz Details CodeBreach CI Flaw That Enabled Takeover of AWS GitHub Repositories

· Original article ↗

Summary

Wiz researchers say an unanchored CodeBuild filter let them bypass trusted-user checks, steal a GitHub token, and gain admin access to AWS repositories. AWS remediated the issue and says it found no customer or service impact.

Key points

  • Unanchored regex filters in four AWS-owned CodeBuild projects allowed GitHub user IDs containing trusted maintainer IDs to pass actor checks.
  • Researchers automated GitHub App bot creation to obtain a matching ID, then used a pull request to trigger a privileged build.
  • A payload dumped process memory to retrieve the CodeBuild project's GitHub credentials; the token provided repository administrator access.
  • The researchers said the access could have enabled malicious code injection into AWS JavaScript SDK releases and affected related repositories.
  • Wiz disclosed the issue to AWS. AWS anchored the filters, revoked the token, added memory protections, and audited public build environments.
  • AWS said it found no evidence that another actor exploited the flaw and determined there was no impact to customer environments or AWS services.
  • Wiz recommends preventing untrusted pull requests from triggering privileged builds, using build approval gates, and limiting integration-token permissions.

Article Details

Attack Vectors
  • Unanchored ACTOR_ID regular-expression filters let a newly registered GitHub bot account with an ID containing an approved maintainer ID trigger a privileged CodeBuild build from an untrusted pull request.
  • A malicious NPM dependency in the pull request ran in the build environment and dumped process memory to obtain the GitHub token.
  • The obtained token's repository permissions were used to add an attacker-controlled GitHub user as a repository administrator, enabling direct code pushes, pull-request approvals, and access to repository secrets.
Defensive Notes
  • Enable the Pull Request Comment Approval build gate, or use CodeBuild-hosted runners with GitHub workflows to manage build triggers.
  • If using webhook filters, anchor regular expressions with start and end markers so they require an exact match.
  • Use a unique, fine-grained Personal Access Token for each CodeBuild project and restrict it to the minimum required permissions; consider a dedicated unprivileged GitHub account.
  • Prevent untrusted pull requests from triggering privileged builds, and reduce pipeline privileges.
  • AWS reported anchoring the vulnerable filters, revoking the exposed token, adding protections for build processes containing credentials in memory, and auditing public build environments and logs.

MITRE ATT&CK

People

Vendors

Products

Tools

Related Articles