What the demonstration did
Replaying Aqua's AWS CDK staging bucket demonstration / found in June 2024, published in October 2024
- 1
Configured: a predictable bucket name left behind
Date not statedThe staging bucket, named only by account ID and Region under the default qualifier, is deleted while the bootstrap roles still point at its name.
- 2
The attacker takes the freed name
Date not statedBecause S3 bucket names are global, the attacker creates the freed name in the attacker's own account, with public access and a template-rewriting Lambda function.
- 3
The next deploy writes to the attacker's bucket
On the next cdk deploy; date not statedThe file publishing role uploads the CloudFormation template to the attacker's bucket, and the attacker's Lambda function adds an admin IAM role to it.
- 4
Template deployed, account taken
On the same deploy; date not statedCloudFormation deploys the rewritten template with administrator rights, creating the injected role, which the attacker can then assume.
No attack was reported: Aqua Security showed that the victim's next cdk deploy uploads its CloudFormation template to the re-created bucket, that CloudFormation then deploys the rewritten template with administrator rights and creates an injected admin role, and that the attacker can assume that role for full control of the account; a name claimed before bootstrap makes the bootstrap fail instead.
What the CDK staging bucket takeover shows
If your environment was bootstrapped with CDK v2.148.1 or earlier and its staging bucket is gone, any AWS account can create that predictable name, and your next cdk deploy sends its template there to be rewritten and deployed with administrator rights. Run cdk bootstrap again with CDK v2.149.0 or later, so the file publishing role uploads only to buckets in your own account, and use a custom qualifier. A service control policy that denies deleting the staging bucket keeps the name with your account, and a permissions boundary that every new role must carry caps what a rewritten template can grant.
Would the controls have stopped it?
In hindsight, not as a whole. 1 control would have refused a step outright, and 7 controls would have limited one. 2 steps have no cloud-provider control. 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.
- 1
- Prevented
- 7
- Contained
- 2
- 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.
Replaying Aqua's AWS CDK staging bucket demonstration / found in June 2024, published in October 2024
1 · Configured: a predictable bucket name left behind
1 Contained3 on other clouds2 · The attacker takes the freed name
1 Contained1 Not covered3 on other clouds3 · The next deploy writes to the attacker's bucket
1 Prevented1 Contained1 Not covered4 · Template deployed, account taken
4 Contained3 on other cloudsKey facts
- The CDK staging bucket was named cdk-{qualifier}-assets-{account-ID}-{region}; with the default qualifier hnb659fds, only the account ID and the Region varied, per Aqua Security
- The file publishing role's S3 statement had no condition on the account that owns the bucket, so a deploy after the bucket was deleted uploaded the template to whichever account held the name; the CloudFormationExecutionRole had AdministratorAccess and no permissions boundary by default
- Aqua scanned 38,560 account IDs in us-east-1, us-west-2 and eu-west-1, with no scan date given beyond June 2024: 782 accounts (2%) had CDK installed and 81 of them (10%) were vulnerable, with more than 100 vulnerable staging buckets
- AWS confirmed that approximately 1% of CDK users were impacted, per Aqua, which does not say how or when AWS computed the figure
- Aqua reported the issue to AWS on June 27, 2024; AWS merged the fix on July 12, 2024 (CDK v2.149.0, bootstrap template version 21), notified impacted customers on October 15 and added CLI upgrade messages on October 16, 2024
- CDK v2.148.1 and earlier were affected, and an environment bootstrapped with them kept the old role until cdk bootstrap was run again; no source reported exploitation in the wild
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.AWS CDK Risk: Exploiting a Missing S3 Bucket Allowed Account TakeoverAqua Security (Aqua Nautilus) · Oct 24, 2024 · Researchbootstrap naming, staging bucket deletion, bucket reclaim, template injection, admin role creation, scan counts, disclosure timeline, AWS fix, mitigations
- 2.chore: add condition to bootstrap file publish role (#30823)Amazon Web Services (aws/aws-cdk repository) · Jul 12, 2024 · Vendor reportthe fix condition, bootstrap template version 21
- 3.Bootstrap your environment for use with the AWS CDK (bootstrap template version history)Amazon Web Services · undated · Vendor reportbootstrap template version history
- 4.AWS Cloud Development Kit flaw exposed accounts to full takeoverThe Register · Oct 24, 2024 · NewsAWS statements, affected versions, customer notification, mitigation
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.