Keyless CI/CD with OIDC
Short-lived cloud credentials for pipelines
Pipelines used to deploy with long-lived cloud keys stored as CI secrets. With OpenID Connect (OIDC), the CI platform gives each job a signed identity token, and the cloud exchanges it for credentials that last minutes. There is no stored key to leak, but the trust policy must be precise.
Intermediate · 5 steps
| Standard | OpenID Connect |
|---|---|
| AWS call | AssumeRoleWithWebIdentity |
| Also on | Azure workload identity federation, GCP Workload Identity |
| Token issuer | token.actions.githubusercontent.com |
| Key check | Trust policy on the "sub" claim |
| Credential lifetime | Minutes to an hour |
Step by step
The job asks for an identity token Signed by the CI platform
When the deploy job starts, it requests an OIDC token from the CI platform. The token is signed and says exactly which repository, branch and workflow is running, and which cloud it's meant for.
Exchange it for cloud credentials AssumeRoleWithWebIdentity
The job sends the token to the cloud's security token service and asks to assume the deploy role. The cloud verifies the token's signature against the CI provider's published keys, then checks the role's trust policy.
The trust policy decides Exactly which repo and branch
The trust policy only allows tokens whose subject is the
mainbranch ofacme/shop. This token matches, so STS returns credentials valid for one hour, and the job deploys. Nothing long-lived was ever stored.A too-broad trust policy Wildcards trust everyone
If the condition had been
repo:acme/*or, worse, missing, any repository in the organisation (or on the platform) could assume the production role. Here a job in an experimental repo tries, and is rejected because the subject doesn't match.Production approvals People still decide
For production, the trust policy can require a deployment environment instead of a branch, and that environment needs a reviewer's approval. The result: short-lived credentials, issued only to the right workflow, only after a human approves.
Security notes
- Restrict the trust policy to the exact repository and branch or environment
- Check the audience claim as well as the subject
- Give each pipeline role only the permissions that deployment needs
- Protect the production environment with required reviewers
- Remove old long-lived keys once OIDC works
More in DevSecOps.
Packets
| No. | Time | Source | Destination | Protocol | Info | Size |
|---|