Guide · Cloud AI platforms
GitHub Actions OIDC Trust Policy: Pin the sub Claim
Which sub claim each GitHub Actions job gets, which trust-policy patterns over-allow or break after GitHub's July 2026 switch to owner and repo IDs, and a seven-step move for AWS, Google Cloud and Azure.
Owen Prestwick · Dec 5, 2026 · 9 min read
On this page

A GitHub Actions OIDC trust policy is only as tight as the sub string it matches, and two things catch teams out. The repo:org/repo:* wildcard from GitHub's own AWS example also accepts every pull request run, every branch push and every environment in that repo. And since 15 July 2026, any repository that is created, renamed or transferred gets a new subject format with numeric owner and repo IDs in it, which name-only patterns such as repo:org/* no longer match.
This guide maps which sub each kind of job receives, which common patterns over-allow or quietly break, and the order to move AWS, Google Cloud and Azure trust to the ID-based format without a failed deploy.
Formats and limits below come from GitHub, AWS, Google Cloud and Microsoft documentation, all checked on 5 Dec 2026. Metarix did not call a cloud account; the pattern matches in the diagram reproduce the documented formats with a glob matcher.
Who needs this, and who can skip it
You need it if a workflow on github.com assumes a cloud role through OIDC: aws-actions/configure-aws-credentials, Google's auth action, azure/login, or a HashiCorp Vault JWT role. Moving from long-lived keys to OIDC is still the right call, and it is the cloud half of the advice in How to Stop AI Coding Agents Leaking Secrets. OIDC just moves the risk into one condition string.
You can skip the migration part on GitHub Enterprise Server. GitHub says the immutable format applies to github.com only. Old repositories on github.com also keep the name-only format until someone opts in, renames or transfers them, so nothing changed overnight on 15 July. The change lands the next time a repo is renamed.
Who acts: a repository admin can opt one repo in; an organization admin can opt in the whole org or set an org-wide sub template; and whoever owns the cloud roles has to edit trust policies first. Line those three up before you touch any setting.
What GitHub puts in sub for each kind of job
GitHub builds the default subject from a prefix and a context. The context follows a fixed order in the OpenID Connect reference: an environment wins over everything, then the pull_request event, then the branch or tag.
Scroll the table horizontally on smaller screens.
| Job | Name-only format (older repos) | Immutable format (new, renamed, transferred or opted-in repos) |
|---|---|---|
| Job with environment: prod (any trigger, including a pull request) | repo:octo-org/octo-repo:environment:prod | repo:octo-org@123456/octo-repo@456789:environment:prod |
| pull_request event, no environment | repo:octo-org/octo-repo:pull_request | repo:octo-org@123456/octo-repo@456789:pull_request |
| Push, schedule or manual run on main, no environment | repo:octo-org/octo-repo:ref:refs/heads/main | repo:octo-org@123456/octo-repo@456789:ref:refs/heads/main |
| Tag v2.1.0, no environment | repo:octo-org/octo-repo:ref:refs/tags/v2.1.0 | repo:octo-org@123456/octo-repo@456789:ref:refs/tags/v2.1.0 |
Three details from that table matter for policy writing. A pull_request subject carries no branch name, so a policy that accepts it accepts every PR in the repo. A colon inside a value, such as an environment called production:eastus, is encoded as %3A. And GitHub picked @ as the separator because it cannot appear in GitHub user or repository names, so @123456 is a safe anchor in a pattern.

Patterns that over-allow or break
Scroll the table horizontally on smaller screens.
| Pattern (StringLike unless noted) | What it accepts | Risk |
|---|---|---|
| repo:octo-org/octo-repo:* | Every branch, every pull request run and every environment in the repo (name-only format) | Over-allows: a PR job can assume the deploy role. Stops matching once the repo moves to the immutable format |
| repo:octo-org/* | Every repo in the org, any context (name-only format) | Over-allows across repos. Stops matching for any repo created or renamed after 15 Jul 2026 |
| repo:octo-org* | Also octo-org-test, octo-organic and any other owner starting with that string | Over-allows across owners. It keeps working after the format switch for the wrong reason |
| repo:octo-org/octo-repo:ref:refs/heads/main (StringEquals) | Push, schedule or manual runs on main only | Fails for jobs that use an environment, and after a rename |
| repo:octo-org@123456/octo-repo@456789:environment:prod (StringEquals) | Only jobs using the prod environment in that exact repo | Tight. Pair it with deployment branch rules on the environment |
AWS blocks the worst case. IAM refuses to save a trust policy for GitHub's provider if token.actions.githubusercontent.com:sub is missing or is only * or ?. It does not stop repo:octo-org*, and the AWS guide warns that without an org or repo in sub, workflows outside your control can assume the role.
Google Cloud has a similar rule: its deployment pipelines guide says a GitHub provider must use an attribute condition that limits tokens to your organization. Its sample condition checks assertion.repository_owner, a name. The same page warns that name fields invite cybersquatting after a repo or org is deleted, and tells you to use the numeric _id fields instead. Follow the warning, not the sample.
Move a role to the ID-based subject in seven steps
- Print the claims you actually get. Run GitHub's actions-oidc-debugger once in the job that deploys, with
id-token: writeset on that job. It prints the decoded claims, includingsub,repository_idandrepository_owner_id. Do not echo the raw token in a log. - Look up the two IDs.
gh api repos/octo-org/octo-repo --jq '.owner.id, .id'returns the owner ID and the repo ID. Write them into the role's documentation; they never change, even if the names do. - Decide what the role should accept. One role per environment is the cleanest. Use
environment:prodfor deploys and protect that environment with required reviewers or deployment branch rules. Use aref:refs/heads/mainsubject only for jobs without an environment. - Add the new subject next to the old one. In AWS, a condition key with a list of values matches any of them, so a role can accept both formats during the move (example below). In Azure, add a second federated credential with the immutable subject.
- Opt the repo in. A repo admin uses the toggle in the repository's OIDC settings, or
PUT /repos/{owner}/{repo}/actions/oidc/customization/subwithuse_immutable_subjectset to true (REST reference). Read the current template with aGETon the same endpoint first, so you do not reset a custominclude_claim_keystemplate by accident. Org admins have the same switch at org level. - Run the deploy job and confirm. The debugger output should show the
@form. In AWS, CloudTrail records eachAssumeRoleWithWebIdentitycall, so you can see which subject was accepted. - Remove the name-only value. Leaving it in keeps the cybersquatting gap open: if the org name is ever freed and claimed, the old string matches again.
AWS trust policy during the move
"Condition": { "StringEquals": { "token.actions.githubusercontent.com:aud": "sts.amazonaws.com", "token.actions.githubusercontent.com:sub": [ "repo:octo-org/octo-repo:environment:prod", "repo:octo-org@123456/octo-repo@456789:environment:prod" ] }}
The audience sts.amazonaws.com is what the official AWS action sends. Account IDs and repo IDs here are placeholders. After step 7, the list shrinks to the second line.
Google Cloud condition with IDs
Map the claims first: google.subject=assertion.sub, plus attribute.repository_id=assertion.repository_id and attribute.repository_owner_id=assertion.repository_owner_id. Google requires a mapping for every field a condition uses. Then set a provider condition such as:
assertion.repository_owner_id=='123456' && assertion.repository_id=='456789' && assertion.ref=='refs/heads/main'
The provider condition does not depend on the sub format, so the opt-in in step 5 does not break it. IAM bindings can: a binding to principal://.../subject/SUBJECT names the full sub string and stops matching after the switch. Bind with principalSet://.../attribute.repository_id/456789 instead. One limit to check: google.subject cannot exceed 127 characters. GitHub's documented example of a custom template with job_workflow_ref comes to 139 characters once immutable IDs are added, so map google.subject to a shorter value if you use templates like that.
Azure federated credentials
Microsoft's federated credential docs say the subject must match exactly, wildcards are not supported, and a failed match is rejected without a helpful error. An app or user-assigned managed identity can hold at most 20 federated credentials. Moving to the new format means one more credential per subject for a while, so count before you add. Microsoft also documents a flexible federated credential with claim-matching expressions, still marked preview as of 5 Dec 2026.
Mistakes to check before you ship
- Pinning a branch on a job that uses an environment. The subject becomes
environment:NAME, so aref:refs/heads/maincondition never matches and the deploy fails with an access-denied error from the cloud. - Accepting `pull_request` on a deploy role. Any PR run in the repo gets that subject. If you are also reworking
pull_request_targetworkflows, see pull_request_target Blocked? Fix Each Workflow Safely. - Renaming a repo on a Friday. After 15 July 2026, a rename or transfer switches the subject to the immutable format. Add the new value to every trust policy before the rename.
- Reusable workflows from another org. GitHub's reference says the caller must set
id-token: writeexplicitly in that case. For central deploy workflows, asubtemplate that includesjob_workflow_reflets the cloud check which reusable workflow asked. - Dependabot jobs. Their tokens carry
event_nameset todynamic. If your provider can checkevent_name, allow only the events you expect. - Repo groups by property. Since April 2026 GitHub can put repository custom properties in the token as
repo_property_*claims (changelog). That beats a wildcard over repo names for a group of repos.
Our take
Do two things this week. Search your cloud accounts for trust policies that use repo: with a * or contain :pull_request, and rewrite each deploy role to one environment in one repo, written in the immutable format. Then opt that repo in on purpose, with both values in place, instead of waiting for a rename to do it for you.
GitHub's switch to owner and repo IDs is the right fix for recycled names, but it only protects roles whose conditions use those IDs. Google Cloud users can mostly avoid the sub string with ID conditions and attribute-based bindings; AWS and Azure users need the two-value move above. If your CI also still uses personal access tokens for GitHub itself, GitHub Apps can now replace enterprise PATs, which is the same idea on the GitHub side. Background on the platform: GitHub Actions and GitHub.
Sources
- GitHub Docs: OpenID Connect reference, checked 5 Dec 2026
- GitHub Changelog: Immutable subject claims for GitHub Actions OIDC tokens, 23 Apr 2026, edited 10 Jun 2026
- GitHub Docs: REST API endpoints for GitHub Actions OIDC, checked 5 Dec 2026
- GitHub Docs: Configuring OpenID Connect in Amazon Web Services, checked 5 Dec 2026
- AWS IAM User Guide: Create a role for OpenID Connect federation (GitHub section), checked 5 Dec 2026
- Google Cloud: Configure Workload Identity Federation with deployment pipelines and attribute limits, checked 5 Dec 2026
- Microsoft Learn: Configure an app to trust an external identity provider, checked 5 Dec 2026
- GitHub: actions-oidc-debugger, checked 5 Dec 2026
- GitHub Changelog: Actions OIDC tokens support repository custom properties, 2 Apr 2026
Tools covered in this guide
Frequently asked questions
- Do existing GitHub repositories switch to the immutable sub format automatically?
- No. Repositories created before 15 July 2026 keep the name-only format until a repo or org admin opts in, or until the repository is renamed or transferred. New repositories created after that date use the immutable format from the start. The change applies to github.com, not GitHub Enterprise Server.
- Can I remove the owner and repo IDs from the sub claim with a custom template?
- No. GitHub's reference says that for repositories using immutable subject claims, the owner ID and repo ID are always included in the repo segment, even when you customize the claim with include_claim_keys.
- Does id-token: write give a workflow write access to my repository?
- No. GitHub documents it as the permission to request the OIDC token only; it does not grant write access to other resources. Set it on the deploy job rather than the whole workflow so other jobs cannot mint a token.
- Why does my AWS role fail with an access-denied error after a repository rename?
- After 15 July 2026 a rename or transfer moves the repository to the immutable sub format, so a trust policy written for repo:owner/name no longer matches. Add the repo:owner@OWNER-ID/name@REPO-ID value to the condition, confirm a run, then remove the old one.
More in Cloud AI platforms
Follow Metarix
Digital media intelligence hub
AI SaaS · developer workflows · architecture