In a CI/CD pipeline, what is OIDC workload-identity federation, and what does the pipeline actually exchange for a cloud credential?
answer
- no secret at rest, only trust
- the CI platform signs, the cloud verifies
- issuer, audience, subject
- token traded for temporary credentials
- public keys fetched from JWKS
basics
~20 sOIDC federation replaces a stored cloud key with a trust relationship. The CI platform mints a short-lived signed identity token describing the specific run; the cloud verifies its signature and claims against a trust policy and hands back temporary credentials.
solid answer
~50 sInstead of storing a long-lived cloud access key as a CI variable, the CI platform acts as an OpenID Connect identity provider. At job time it mints a JSON Web Token signed with its private key, whose claims describe that run — issuer, audience, and a subject claim encoding things like the repository, branch or environment, plus a short expiry. The job presents that token to the cloud's token-exchange endpoint. The cloud fetches the issuer's public keys from its published JWKS endpoint, verifies the signature and expiry, checks the audience is the one it expects, and then matches the subject claim against the condition attached to the role. If it matches, it returns temporary credentials, typically valid for an hour or less. Nothing durable is stored on either side: the secret becomes a trust configuration, and the design work moves into the subject condition and the role's permissions.
code
json · 7 lines{
"iss": "https://ci.example.com",
"aud": "my-cloud-sts",
"sub": "repo:acme/payments:ref:refs/heads/main",
"iat": 1730000000,
"exp": 1730000600
}go deeper
Be able to say plainly that the pipeline gets a short-lived token from the CI platform, trades it for temporary cloud credentials, and that no cloud key is stored anywhere.
Walk the exchange end to end and name the three things the cloud verifies — issuer, audience, subject — plus the signature check against the issuer's published keys and the short expiry.
Show you treat the trust configuration as access control: distinct audience per relying party, a narrow subject condition, and a role whose permissions are scoped to what that pipeline deploys.
Own the honest limit: federation removes the secret at rest but not the ability of code running inside a trusted job to obtain the credential, so it must be paired with controls on who can change pipeline definitions.
## The problem federation solves A pipeline that deploys needs to authenticate to something outside itself — a cloud account, a registry, a package index. The traditional answer is to create a service account, generate a long-lived access key, and paste it into the CI platform's secret store. That key is a bearer credential: whoever holds the bytes *is* the service account, from any network, until a human rotates it. It sits in the CI platform's database, in the environment of every job that references it, and in the memory of every process that job starts. Because CI systems typically hold deploy-grade permissions across an estate, and because pipeline definitions are editable by anyone who can open a merge request, that store is one of the highest-value targets in most organisations. A leaked key is usually discovered late, and rotation is a coordinated change across every pipeline that used it. ## What "federation" means here Federation means two parties trust each other without sharing a secret. The CI platform runs an OpenID Connect identity provider: it publishes a discovery document (conventionally at `/.well-known/openid-configuration`) which points at a `jwks_uri` serving its public signing keys. On request from inside a job, it mints a JSON Web Token signed with the matching private key. The token's claims describe *that run*, not a person: ```json { "iss": "https://ci.example.com", "aud": "my-cloud-sts", "sub": "repo:acme/payments:ref:refs/heads/main", "iat": 1730000000, "exp": 1730000600 } ``` Platforms add their own claims alongside the standard ones — repository, ref, environment name, workflow or pipeline identity, run id. The token lives for minutes and is worthless unless some relying party has been configured to trust that issuer. ## The exchange, step by step 1. The job asks the CI platform for an identity token, naming the audience it wants the token minted for. 2. The job presents the token to the cloud's token-exchange endpoint. On AWS this is `sts:AssumeRoleWithWebIdentity`; the other major clouds have equivalent workload-identity or federated-credential features. 3. The cloud fetches the issuer's JWKS over TLS and verifies the token's signature, expiry, and that the issuer is one it has been configured to trust. 4. The cloud checks the `aud` claim matches the audience registered for that trust configuration. 5. The cloud evaluates the condition attached to the role: does the `sub` claim match the pattern the administrator pinned? 6. On success it returns short-lived credentials — usually an hour or less — carrying only that role's permissions. No step in that flow involves a value that was stored anywhere before the job started. ## What it buys and what it does not It buys: no cloud secret at rest in CI; a theft window measured in minutes rather than months; an identity per pipeline run rather than one shared robot account; and an audit trail that names the repository and branch rather than "the CI user". It does not buy least privilege. The role's permission set is unchanged by how you authenticated to it; a federated role with administrator rights is still an administrator. It does not protect you from a pipeline that is itself compromised: an attacker who can execute a step in a trusted context can request the token and receive exactly the same credentials — federation removes the *stored* secret, not the *ability to obtain* a credential from inside the build. And it only applies to relying parties that implement it; plenty of third parties still accept nothing but an API key. ## Where the real design work sits Two fields carry almost all of the security value. The **audience** stops a token minted for one relying party being replayed at another. If every relying party accepts the same generic audience, a token you hand to a minor service can be forwarded to your cloud. Set a distinct audience per relying party and pin it in the trust configuration. The **subject** decides *which runs* may assume the role. This is where teams get it wrong most often, and it deserves treating as a first-class access-control decision rather than a copy-paste from a quickstart: a subject condition that names only the repository lets any branch in that repository assume the role, which is a very different grant from what most people believe they configured. ## What to say in an interview Name the three verified things — issuer, audience, subject — say the token is short-lived and describes the run, and be explicit that the outcome is temporary credentials rather than the token itself being usable against the cloud API.
- If the identity token is not itself a cloud credential, what stops an attacker who captures one from using it?Two things: lifetime and binding. The token expires in minutes, so a captured token is usually already dead. And it is only accepted by a relying party configured to trust that issuer, for the audience it was minted for, when its subject matches the pinned condition. Capturing it inside a job is still serious — but so is capturing the credentials that job already holds.
- Does adopting OIDC federation mean you no longer need a secret store at all?No. Federation covers relying parties that implement it. Most estates still have third parties that accept only an API key, plus break-glass credentials. Those still need a secret store, tight scoping, and rotation. Federation shrinks the set of long-lived secrets rather than eliminating the concept.
- What does the cloud do if the CI platform rotates its signing key?Nothing special. The cloud fetches keys from the issuer's published JWKS endpoint and selects by key id, so a rotated key is picked up on the next fetch. That is the point of publishing keys rather than exchanging them: the relying party never holds a copy that must be updated by hand.
saying these in an interview costs you the question
- Thinks the identity token is itself the cloud credential.
- Says federation makes role permissions unnecessary.
- Believes the token must be stored as a CI secret.
- Cannot name what the cloud verifies before issuing credentials.
- Claims OIDC prevents a compromised pipeline from getting credentials.