Cloud Security

3 Steps to Replace Static CI Keys With OIDC Federation

November 26, 2026 · 8 min read · By CloudAI Security
3 Steps to Replace Static CI Keys With OIDC Federation

OIDC federation removes the long-lived key from a pipeline by having the runner present a short-lived signed token that the platform exchanges for credentials valid only for that job. AWS, Google Cloud and Microsoft Entra all accept it, and the migration is the same three steps on each: inventory the static keys your pipelines hold, pin each trust configuration to a single repository and environment, then switch the workflow and retire the key on a dated schedule. This guide covers what the token proves, where trust policies usually fail, and how to verify the switch before anything is deleted.

Reviewed November 26, 2026, against the GitHub, AWS, Google Cloud and Microsoft documentation linked at the end. The repository names and subject values below are copied from those pages; the rollout sequence is this site’s own.

What the Token Proves

Every job can request its own JSON Web Token from GitHub’s issuer, https://token.actions.githubusercontent.com, and the token carries claims about the run: the repository, the ref, the actor who triggered it, the run ID and, when the job targets one, the environment name. The platform verifies the token and compares its claims with the trust configuration before it issues anything. The token identifies a workflow run, not a person and not a code review. That distinction decides where federation helps and where it does not.

By default the subject claim is a concatenation of workflow metadata such as the organization, the repository, the branch or the job environment, so a condition on the subject becomes a gate for a specific repository, branch or environment. The format is predictable enough to write down before any platform is configured:

Job contextSubject value
Branch demo-branchrepo:octo-org/octo-repo:ref:refs/heads/demo-branch
Environment Productionrepo:octo-org/octo-repo:environment:Production
Pull request event, no environmentrepo:octo-org/octo-repo:pull_request

Three details change how you read that table. The subject carries the environment name only when the job references an environment, and the branch name only when it does not and the run was not triggered by a pull request. A colon inside a value is written as %3A. The pull request subject is the same string for every pull request run in the repository, so it cannot separate one pull request from another; a deployment role should never trust it.

Repositories created after July 15, 2026 switched to an immutable subject format that also carries the owner and repository IDs, written as repo:octo-org@123456/octo-repo@456789:ref:refs/heads/main, because a recycled repository name could otherwise reproduce an earlier subject value. Older repositories keep the previous format unless they opt in, and the immutable format is not available on GitHub Enterprise Server. Before writing a policy, print the claims your own repository produces with the github/actions-oidc-debugger action; a subject copied from an older tutorial will simply never match.

Inventory the Static Keys

The credentials to retire are the ones with a lifetime measured in months, not the ones a platform issues and refreshes on its own. On each platform the pair looks like this:

PlatformStatic credential to retireWhat replaces it
AWSLong-term access key stored as a pipeline secretIAM role whose trust policy names the OIDC provider
Google CloudExported service account key in JSON formWorkload identity pool and provider, or service account impersonation
AzureApplication client secret or certificateFederated identity credential on a user-assigned managed identity or app registration

Record the old key’s permissions before touching the workflow. The replacement must start with exactly the same rights; redesigning them belongs to a separate review. Mark every key that cannot be replaced this way, such as a token for a registry or an API that cannot validate OIDC tokens, because those need a different control and should not be mixed into this migration.

Pin the Trust Policy

The trust configuration is the entire control. GitHub’s reference warns that a trust configuration with no condition lets untrusted repositories request access tokens for your resources, and each platform expresses the condition differently. The examples in the last column are the vendor’s own:

PlatformObject that holds the trustForm of the condition
AWSIAM role trust policyCondition on the subject key, for example "token.actions.githubusercontent.com:sub": "repo:octo-org/octo-repo:ref:refs/heads/demo-branch"
AzureFederated identity credential on a user-assigned managed identity or app registrationSubject repo:octo-org/octo-repo:ref:refs/heads/demo-branch, with matching issuer and audience
Google CloudWorkload identity pool providerAttribute condition such as (assertion.sub=='repo:octo-org/octo-repo:ref:refs/heads/demo-branch')

The rules that keep the condition tight are the same everywhere:

  • Match the subject exactly. A wildcard on the organization matches every repository in it, including the one someone creates next month.
  • Prefer the environment form for deployment roles, so that the deploy job is gated separately from the test jobs that run on the same branch.
  • Pin the audience when the login action allows it. Google documents this as protection against the confused deputy problem; GitHub’s default audience is the repository owner’s URL, while the Azure login action substitutes api://AzureADTokenExchange.
  • On Azure, write the values exactly: issuer, subject and audience must match the token case-sensitively.
  • On Google Cloud, write an attribute condition in addition to the mapping; the credential is accepted only when the expression evaluates to true.
  • Allow only the expected event names where the provider supports it, because tokens requested for Dependabot update jobs carry dynamic as the event name.

In the workflow, grant id-token: write only to the job that logs in. Without it the token cannot be requested, and the permission itself only enables fetching the token; it does not grant write access to other resources. The request URL and bearer token are available on the runner as environment variables, so any step in the same job can request a token for itself. Keep the login step in a job of its own, with contents: read and nothing else, and move build steps elsewhere.

Switch, Verify, Then Retire

With the trust in place, the workflow needs a single change: the secret step is replaced by the platform’s login action. On AWS the session can be set anywhere from 900 seconds up to the maximum session duration configured on the role, so a deploy job can request a short session instead of the default hour.

  1. Create the role, pool or credential with the permissions recorded during the inventory, unchanged.
  2. Enter the exact subject for one repository and one environment, plus the audience, and save the trust configuration.
  3. Run the workflow from the expected branch, then change one character of the subject and confirm that the login fails. A trust that still passes has no condition.
  4. Check the provider side: on AWS, the CloudTrail entry for the AssumeRoleWithWebIdentity call carries the token subject; on Google Cloud, the mapped subject appears in Cloud Logging.
  5. Set an expiry date on the old key, watch for failures until that date passes, then delete the key. An inactive key that nobody missed is the proof the migration finished.

Federation changes the lifetime of the credential, not its permissions. The role the pipeline assumes still holds whatever rights the key held, so a review of the pipeline’s permissions is a separate task. The cluster side of the same problem, where a static Secret is still stored as a plain object, is covered in the site’s guide to Kubernetes Secrets security controls from storage to pod; the authentication side of the cluster is covered in the guide to auditing Kubernetes anonymous API access without disruption.

What Federation Does Not Fix

The token proves that a workflow in a given repository on a given ref asked for credentials. It says nothing about the code that runs inside the job. A compromised action or a dependency installed by the build can execute in that job and, where id-token: write was granted, request a token for itself. Federation makes that path quieter, because the attacker no longer needs to read a secret from the environment. Treat a change to the workflow file on the deployment branch as a change to the access policy.

Federation also does not reach systems that cannot validate a token: legacy APIs and on-premises services still need a secret. Those keep their own controls, such as a vault lease or a scoped token with a short expiry. Federation removes a class of secret; it does not remove the need to know where every remaining one is used.

Sources

All pages were read on November 26, 2026.