How a 2026 GitHub security upgrade quietly broke every
sam pipeline bootstrap+ GitHub Actions OIDC setup for new repositories — and the five-minute fix once you know where to look.
Published: November 2026 · Tags: AWS SAM, GitHub Actions, OIDC, CI/CD, Security
TL;DR
If your GitHub Actions workflow fails at the "configure AWS credentials" step with:
Error: Could not assume role with OIDC: Not authorized to perform sts:AssumeRoleWithWebIdentity
…and you've already triple-checked that the branch, repo name, audience, and OIDC provider are all correct, the culprit is almost certainly a subject-claim format mismatch:
-
GitHub (for repos created on/after July 15, 2026) now mints an immutable
subclaim that embeds numeric IDs:repo:my-org@123456/my-repo@7891011:ref:refs/heads/main -
AWS SAM CLI (
sam pipeline init --bootstrap) still writes the legacy name-onlysubinto the role's trust policy:repo:my-org/my-repo:ref:refs/heads/main
They never match, so STS denies the handshake. Fix: update the role's trust policy sub to the immutable format. Details below.
The setup: how this is supposed to work
AWS SAM gives you a lovely one-command bootstrap for CI/CD:
sam pipeline init --bootstrap
For GitHub Actions with OIDC, this creates (per environment/account):
- An IAM OIDC identity provider trusting
token.actions.githubusercontent.com - A pipeline execution role your workflow assumes via
sts:AssumeRoleWithWebIdentity - A CloudFormation execution role that actually deploys your stack
- An artifacts bucket
Your workflow then authenticates with no long-lived keys:
permissions:
id-token: write
contents: read
# ...
- name: Assume the pipeline role
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: us-east-1
role-to-assume: ${{ env.PIPELINE_EXECUTION_ROLE }}
role-session-name: deploy
Under the hood, GitHub issues a short-lived JWT (the OIDC token). AWS STS checks that token's claims against the role's trust policy. The two claims that matter:
-
aud(audience) — must equalsts.amazonaws.com -
sub(subject) — must match the repo/branch condition in the trust policy
That sub check is where everything quietly fell apart.
The symptom: everything looks correct, nothing works
Here's the trust policy SAM generated (and that AWS's docs, blogs, and your memory all say is correct):
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Federated": "arn:aws:iam::111122223333:oidc-provider/token.actions.githubusercontent.com"
},
"Action": "sts:AssumeRoleWithWebIdentity",
"Condition": {
"ForAllValues:StringLike": {
"token.actions.githubusercontent.com:aud": "sts.amazonaws.com",
"token.actions.githubusercontent.com:sub": "repo:my-org/my-repo:ref:refs/heads/main"
}
}
}
]
}
The workflow pushes from main. The repo is my-org/my-repo. The audience is the default sts.amazonaws.com. The OIDC provider exists. And yet:
Error: Could not assume role with OIDC: Not authorized to perform sts:AssumeRoleWithWebIdentity
This is the maddening part — the error is identical regardless of which of ~8 root causes you're hitting, and the one you'd never guess looks exactly like the ones you can rule out.
The red herrings (don't waste hours here)
Before the real cause, here's what it is not — each of these looks plausible and costs people hours:
| Suspect | Verdict |
|---|---|
ForAllValues:StringLike is a "broken" operator |
❌ No — this is exactly what SAM ships; it evaluates single-valued sub/aud correctly when they match. |
role-session-name doesn't match something |
❌ No — it's a free-form CloudTrail label; it authorizes nothing. |
Your local aws sso login session is wrong |
❌ No — the runner uses the OIDC token, never your laptop's credentials. |
| OIDC provider missing | ❌ Rule it out with aws iam list-open-id-connect-providers. |
Missing id-token: write
|
❌ Rule it out — it's in the permissions: block. |
Every one of these produces (or is adjacent to) the same Not authorized message, which is why this bug is so disorienting. Stop guessing and look at the actual token.
The 30-second diagnostic: print the real OIDC claims
This is the single most valuable move in any OIDC-vs-AWS debugging session. Add a step before the credentials step that decodes the JWT GitHub actually minted for this run:
# DEBUG: prints the real OIDC claims so we can compare against the trust policy.
- name: Print OIDC claims (debug)
run: |
TOKEN=$(curl -s -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
"$ACTIONS_ID_TOKEN_REQUEST_URL&audience=sts.amazonaws.com" | jq -r .value)
python3 - "$TOKEN" <<'PY'
import sys, base64, json
p = sys.argv[1].split('.')[1]; p += '=' * (-len(p) % 4)
c = json.loads(base64.urlsafe_b64decode(p))
print(json.dumps({k: c.get(k) for k in
['sub','aud','repository','repository_owner','ref','workflow_ref','environment']}, indent=2))
PY
Run it, open the step log, and there it is:
{
"sub": "repo:my-org@123456/my-repo@7891011:ref:refs/heads/main",
"aud": "sts.amazonaws.com",
"repository": "my-org/my-repo",
"repository_owner": "my-org",
"ref": "refs/heads/main",
"workflow_ref": "my-org/my-repo/.github/workflows/prod.yaml@refs/heads/main",
"environment": null
}
⛔⛔⛔Look closely:
Trust policy wants : repo:my-org/my-repo:ref:refs/heads/main
Token actually has : repo:my-org@123456/my-repo@7891011:ref:refs/heads/main
^^^^^^^ ^^^^^^^^
The real sub has @123456 (the owner ID) and @7891011 (the repository ID) baked in. The strings differ, so StringLike returns false and STS correctly denies. Mystery solved.
Detection tip: notice that
repositoryandrepository_ownerstay clean (my-org/my-repo,my-org) — onlysubcarries the IDs. If those two claims look normal butsubhas@-suffixes, you're looking at immutable subject claims.
The real root cause: GitHub's immutable subject claims
In April 2026, GitHub announced immutable OIDC subject claims. Starting July 15, 2026, every newly created repository defaults to a sub claim that embeds permanent numeric IDs instead of (mutable) names:
repo:OWNER@OWNER_ID/REPO@REPO_ID:ref:refs/heads/BRANCH
Why GitHub did this (it's a genuine security win): names can be renamed, deleted, and re-registered by someone else. An attacker who creates a new repo with your old name would previously inherit a sub that still matches your cloud trust policy. Numeric IDs are never reused, so the immutable format closes that rename/re-registration hole. This is a good change.
Why it breaks SAM: sam pipeline bootstrap builds the trust condition from names only. Straight from the SAM CLI source (samcli/commands/pipeline/bootstrap/pipeline_oidc_provider.py):
def get_subject_claim(self) -> str:
org = self.oidc_parameters["github-org"]
repo = self.oidc_parameters["github-repo"]
branch = self.oidc_parameters["deployment-branch"]
return f"repo:{org}/{repo}:ref:refs/heads/{branch}" # <-- legacy, name-only
No @, no IDs. So the moment your repo is on the immutable default, the trust policy SAM writes can never match the token GitHub sends. New repo + fresh bootstrap = broken from the first run, with an error that points you everywhere except the real cause.
As of this writing this is still an open item on the SAM CLI (#4606) — and upgrading SAM does not currently change the generated format.
The fix: align the trust policy to the immutable sub
You have the exact sub from the debug step — just put it in the trust policy. Save this as trust-prod.json:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Federated": "arn:aws:iam::111122223333:oidc-provider/token.actions.githubusercontent.com"
},
"Action": "sts:AssumeRoleWithWebIdentity",
"Condition": {
"ForAllValues:StringLike": {
"token.actions.githubusercontent.com:aud": "sts.amazonaws.com",
"token.actions.githubusercontent.com:sub": "repo:my-org@123456/my-repo@7891011:ref:refs/heads/main"
}
}
}
]
}
Apply it:
aws iam update-assume-role-policy \
--role-name <YOUR_PIPELINE_EXECUTION_ROLE_NAME> \
--policy-document file://trust-prod.json
Re-run the workflow — the sub now matches byte-for-byte and the handshake succeeds. That's it.
Choosing to align (not revert): You could opt the repo back to the legacy name-only format via the
PUT /repos/{owner}/{repo}/actions/oidc/customization/subAPI — but don't. You'd be giving up a security improvement that GitHub is making the default anyway. Align your cloud trust to the immutable format and move forward.
Three things to remember
-
sam pipeline bootstrapwill re-break it. Until #4606 ships, any future bootstrap/re-bootstrap overwrites your trust policy with the legacy name-onlysub. Treat the trust-policy patch as a required post-bootstrap step and document it in your repo. -
Do it for every role/account. Dev, staging, prod — each pipeline execution role needs the immutable
sub(same owner/repo IDs, different branch suffix, different account in theFederatedprincipal). -
Keep the
@IDs, not wildcards. It's tempting to "fix" this withrepo:my-org@*/my-repo@*:..., but that throws away the exact thing that makes immutable subjects secure. Pin the real IDs — they don't change on rename, which is the whole point.
Handy: find your numeric IDs without a workflow run
# Owner (user or org) ID
curl -s https://api.github.com/users/my-org | jq .id
# Repository ID
curl -s https://api.github.com/repos/my-org/my-repo | jq .id
Debugging checklist (steal this)
When AssumeRoleWithWebIdentity is denied and the config looks perfect:
- ✅
permissions: id-token: writepresent? (workflow or job scope) - ✅
aws iam list-open-id-connect-providersshows the provider? - ✅ Provider's
ClientIDListcontainssts.amazonaws.com? - 🔍 Print the token claims (the step above) and diff
sub/audagainst the trust policy character for character. - 🎯 See
@<id>insub? → immutable subject claims → patch the trust policy.
Step 4 is the one that ends the guessing. When two things that "should match" don't, stop reasoning about what the value ought to be and print what it actually is.
Takeaway
This isn't a SAM bug or a GitHub bug — it's a timing gap. GitHub shipped a security hardening; SAM's bootstrap hasn't caught up; and the failure surfaces as the most generic, least-specific error in the AWS catalog. For anyone spinning up a new repo with sam pipeline bootstrap after mid-July 2026, this will bite on the very first deploy. Now you'll recognize it in thirty seconds instead of three hours.
References
- Immutable subject claims for GitHub Actions OIDC tokens — GitHub Changelog (2026-04-23)
- About security hardening with OpenID Connect — GitHub Docs
- Extending OIDC subject claims — aws/aws-sam-cli Issue #4606
- aws-actions/configure-aws-credentials
- When AWS OIDC Failed, I Checked the
subClaim and Fixed the Trust Policy — classmethod
Found this useful? The thirty-second claim-dump trick works for Azure and GCP federation too — the error is always generic, but the token never lies.
Top comments (0)