Jitsumi logo Jitsumi

GitHub Actions OIDC to AWS Denied? Check the New Subject Claim Before Widening Trust

AWS denies GitHub Actions OIDC role assumption? Check the July 2026 immutable subject format, compare aud/sub safely, and keep IAM trust narrowly scoped.

Illustrative paired copper and blue identity plates approaching a narrow validation gate, representing exact GitHub OIDC subject matching.

TL;DR

  • GitHub.com repositories created after 15 July 2026 use immutable IDs in the OIDC subject claim.
  • Inspect selected aud/sub claims from a trusted job; never log the JWT.
  • Match the exact IAM trust policy instead of broadening it.
  • Verify the expected AWS account and role with aws sts get-caller-identity.

An AWS deployment suddenly fails in GitHub Actions at AssumeRoleWithWebIdentity. The AWS role still exists, the workflow has not changed, and the job can request an OIDC token. Before loosening the role's trust policy, compare the actual OIDC `sub` claim against the exact subject AWS expects.

This matters especially in late 2026. GitHub.com repositories created after 15 July 2026 now have default subjects containing *immutable owner and repository IDs*. Older repositories generally retain the name-only format unless they opt in. Repositories renamed or transferred after that date also move to immutable subjects. An IAM trust policy written for repo:example-org/example-app:ref:refs/heads/main will not match repo:example-org@123456/example-app@789012:ref:refs/heads/main. Using * to make the error disappear would weaken access control.

This guide is for maintainers who use GitHub.com Actions and AWS IAM OIDC federation. It covers verifying the token's identity, matching the role trust relationship, and testing the assumed identity without deploying. Examples use synthetic account, owner and repository identifiers. They are based on current primary-source documentation, not a hands-on AWS deployment.

A denied exchange is not always a missing AWS permission

GitHub can issue a short-lived OIDC JSON Web Token (JWT) to an authorized workflow job. AWS Security Token Service (STS) checks whether its issuer, audience and subject satisfy the AWS OIDC identity provider and the target role's trust policy. When they match, STS exchanges the GitHub token for temporary role credentials. The role's separate permissions policy then controls which AWS APIs those credentials can call.

GitHub's AWS OIDC configuration guide names the issuer https://token.actions.githubusercontent.com and the usual audience sts.amazonaws.com. AWS's OIDC IAM-role guidance recommends restricting the GitHub subject claim to the intended organization, repository and branch or deployment environment. AWS rejects role trust policies with no GitHub subject restriction or one that is only a wildcard.

Think of the two policy layers separately. Trust asks who can assume the role; permissions ask what that role may do. An AccessDenied during the *exchange* belongs in the first investigation. An access denial *after* AWS credentials are issued is often an authorization problem for the specific AWS API, not a problem with GitHub's subject.

GitHub's new default subject: names plus immutable IDs

GitHub's OIDC reference says that the previous default used mutable names. A namespace could eventually be recycled. Repositories created after 15 July 2026 use an immutable subject containing owner and repository IDs. Earlier repositories keep the old format unless they opt in. Renames and transfers after the change also cause a transition.

For a job on main without an environment, compare these shapes:

GitHub job context

Example OIDC subject

What the IAM trust policy must match

Legacy default

repo:example-org/example-app:ref:refs/heads/main

Exact repository and branch names.

Immutable default

repo:example-org@123456/example-app@789012:ref:refs/heads/main

Exact names, owner ID, repository ID and branch.

Job referencing production environment

Subject has :environment:production suffix

Exact environment subject, with protected deployment branches.

A policy using repo:example-org/*

Allows a wider family of subjects

Too broad for a narrowly authorized deployment role.

These IDs are illustrative and must not be copied. Your repository may use a customized subject template. Always inspect what GitHub actually issued. The environment is another common mismatch: when a job references environment: production, the default sub reflects the environment instead of the :ref:refs/heads/main suffix. GitHub recommends protecting environment deployment branches and reviewers. See GitHub's environment controls. An unprotected environment does not magically prove that the job came from a trusted branch.

First find the failing layer

Read the first meaningful error in the job, not just the final red status.

Cannot request an OIDC token: Confirm that the requesting job has permissions: id-token: write. This grants permission to *request a token*, not to modify AWS or write to the repository. Also examine whether the workflow's trigger and organizational policies permit the job.

`AssumeRoleWithWebIdentity` denied: Compare the issuer, aud, sub, federated provider ARN and role ARN. A wrong audience or outdated subject may fail before any AWS resource permission is tested.

AWS credentials obtained but a service command fails: Check that resource's authorization and the role's permissions, rather than expanding OIDC trust.

An unexpected AWS account appears: Stop. Verify the target role ARN and the expected account. Continuing with an unintended identity can be more damaging than a failed deployment.

Do not print AWS secrets, the raw GitHub JWT or session tokens to logs. You only need a small set of claims to make the comparison.

Print only selected claims in a trusted test workflow

The following *diagnostic* workflow runs manually and requests an OIDC token for the normal AWS audience. It displays only iss, aud and sub; it does not print the token, assume an AWS role, or deploy anything.

name: Inspect GitHub OIDC identity
on:
  workflow_dispatch:

permissions: {}

jobs:
  inspect:
    runs-on: ubuntu-latest
    permissions:
      id-token: write
      contents: read
    steps:
      - name: Show selected claims only
        uses: actions/github-script@v8
        with:
          script: |
            const jwt = await core.getIDToken('sts.amazonaws.com');
            const payload = JSON.parse(
              Buffer.from(jwt.split('.')[1], 'base64url').toString('utf8')
            );
            core.info(JSON.stringify({
              iss: payload.iss,
              aud: payload.aud,
              sub: payload.sub
            }, null, 2));

GitHub documents core.getIDToken() and the permission requirement in its OIDC reference. This script decodes claims for diagnostic display only. Decoding a JWT does not verify its signature and is *not* an authorization decision. AWS makes the actual trust decision when the role is assumed.

Run the diagnostic only on a trusted branch, with an authorized maintainer. A workflow_dispatch run reflects the selected ref. If your real deployment job declares environment: production, a branch-only diagnostic will have a different subject. Reproduce the same environment context in a trusted, properly protected diagnostic job, or have an authorized administrator inspect the configuration. Remove the diagnostic workflow after recording the relevant values. Avoid allowing unreviewed pull requests to use diagnostic jobs with cloud credentials.

Match the subject in the role's AWS trust relationship

Open the AWS IAM console, select the role named in role-to-assume, and read Trust relationships. Verify that the federated principal refers to your account's GitHub OIDC identity provider and that the audience condition matches sts.amazonaws.com for standard AWS regions.

For an immutable-subject repository using main, without a GitHub environment, the following is a template, not a ready-to-paste policy. Replace all synthetic identifiers with verified values and keep the subject as narrow as your intended deployment boundary:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": {
        "Federated": "arn:aws:iam::123456789012:oidc-provider/token.actions.githubusercontent.com"
      },
      "Action": "sts:AssumeRoleWithWebIdentity",
      "Condition": {
        "StringEquals": {
          "token.actions.githubusercontent.com:aud": "sts.amazonaws.com",
          "token.actions.githubusercontent.com:sub": "repo:example-org@123456/example-app@789012:ref:refs/heads/main"
        }
      }
    }
  ]
}

The GitHub immutable-subject examples and AWS role trust-policy documentation agree on the exact form. StringEquals with the exact observed subject is easier to audit than a broad wildcard. A job with an environment needs a different subject condition. Review current GitHub environment protection rules and supported IAM condition keys before attempting more elaborate restrictions.

A common mistake is to solve a subject mismatch with StringLike and repo:example-org/*. That could let jobs from additional repositories assume a role whose permissions were only intended for one application. The trust policy is a security boundary, not just a string-format setting.

If another team owns the IAM role, share the observed audience and subject, role ARN and controlled workflow context—not the token or access keys—and ask for an authorized trust-policy review.

Confirm the assumed account and role without deploying

After fixing the trust relationship, test with a read-only STS identity operation. This sample expects a real role with the matching trust relationship. Replace the dummy account and role ARN; use a trusted branch, not a fork PR:

name: Check AWS identity
on:
  push:
    branches: [main]

permissions: {}

jobs:
  verify:
    runs-on: ubuntu-latest
    permissions:
      id-token: write
      contents: read
    steps:
      - name: Obtain temporary AWS credentials
        uses: aws-actions/[email protected]
        with:
          role-to-assume: arn:aws:iam::123456789012:role/github-oidc-check
          aws-region: ap-southeast-1
          allowed-account-ids: '123456789012'
      - name: Confirm caller identity
        run: aws sts get-caller-identity

The first step uses the official AWS credentials action to exchange the GitHub OIDC JWT. The action's allowed-account-ids option rejects an unexpected AWS account. Version 6.3.0 was published on 11 September 2026; review and pin Actions dependencies to commit SHAs when your security policy requires it.

AWS's `GetCallerIdentity` API reference confirms that no IAM permissions are needed to return the caller's account and identity. Verify that the output contains the expected account ID and assumed-role ARN. It is not evidence that a subsequent deployment has the necessary S3, ECS or other service permissions. Those must be reviewed separately.

Three fixes that make the security problem worse

Broadening the `sub` pattern: Replacing an exact subject with a wildcard might make a deployment green while authorizing extra workflows. Diagnose the actual token first, then update the precise trust condition.

Changing to `pull_request_target` to get credentials: This event has separate risks when privileged code checks out and executes untrusted PR content. Jitsumi's guide to auditing `pull_request_target` workflows covers that boundary. Keep external contributors' tests and trusted deployments separate.

Reintroducing long-lived AWS keys: Static keys sidestep the federation problem rather than fixing it. OIDC's practical advantage is that you do not have to retain long-lived AWS access keys inside repository secrets.

A short decision table for the next failure

Observation

Most likely layer

Next check

OIDC request fails

GitHub token permissions

Check job-level id-token: write.

AssumeRoleWithWebIdentity fails

IAM trust/provider

Compare exact aud, sub, role and provider ARNs.

Repository was created, renamed or transferred after 15 July 2026

Immutable-subject format

Look for @OWNER-ID and @REPO-ID.

A job uses a GitHub environment

Subject context

Match :environment:NAME; restrict deployment branches.

STS succeeds but deployment fails

IAM role/resource permissions

Inspect the failed AWS API and relevant policy.

STS identity shows an unexpected account

Wrong role/account

Stop; verify ARN and allowed-account-ids.

A successful fix is not merely a green check. It is evidence that the intended GitHub job received the intended AWS role in the intended account, without expanding who else can assume it. Record the exact trust condition and the context it applies to, remove temporary diagnostics, and review any deployment permissions separately.

Sources and further reading

Subscribe

All the new articles in one Monday digest. Unsubscribe with one click.

Share this post

Newsletter

The Monday edit from Jitsumi

All the new articles, in one Monday email. Leave with one click whenever you like.