No keys attached: Exploring GitHub-to-AWS keyless authentication flaws
A misconfigured AWS IAM trust policy allowed any GitHub Actions workflow to assume a role and obtain AWS credentials, because a duplicate key in the Terraform policy silently dropped the subject condition. An attacker could then access private CodeCommit repositories, including a UK government account where they could read and potentially push to mirrored private repos.
Christophe Tafani-Dereeper Follow
Published on securitylabs.datadoghq.com
Cloud Security Researcher and Advocate](https://securitylabs.datadoghq.com/articles/?author=ChristopheTafani-Dereeper)
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the Terraform HCL parser silently overwrote a duplicate StringEquals key in the trust policy map, so the condition restricting the JWT subject was lost and only the audience check remained.
Impact
An attacker could assume vulnerable roles and retrieve AWS credentials, potentially accessing private CodeCommit repositories and, in the UK government case, pushing malicious Terraform code that could backdoor infrastructure if later deployed.
What the attacker needed
Target role lacks subject condition; attacker can run a GitHub Actions workflow; network access to AWS STS
The fix
The duplicate StringEquals key was removed so the subject condition applied, and the role's permissions were reduced; GDS also checked audit logs and repository contents.
How it was found
- Search GitHub repositories for AWS role ARNs in workflow files using Sourcegraph.
- Start a GitHub Action that prints its OIDC token request variables and sleeps.
- Exchange the GitHub Action JWT for AWS credentials using sts:AssumeRoleWithWebIdentity.
- Refresh the JWT when it expires and repeat for each target role.
- Use the obtained credentials to access private CodeCommit repositories.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
When a GitHub Actions workflow needs to use AWS, it can prove its identity with a signed token instead of storing long-lived passwords. AWS checks that token against a trust policy to decide which repositories are allowed. Here, a mistake in how the policy was written meant the check on the repository name was silently removed, so any GitHub repository could pretend to be the trusted one and get AWS access.
What is Misconfiguration?
Settings left unsafe: exposed panels, open storage buckets, debug modes, default credentials.