Sub topic 1
Why stored cloud credentials are a liability
Prerequisites
This chapter assumes you know:
- Basic GitHub Actions workflow syntax: jobs, steps, and triggers.
- How repository secrets and environments work.
- The general idea of cloud IAM roles and policies.
- Basic HTTP and JSON.
The pattern most pipelines start with
A deploy job needs to call a cloud API. The usual first solution is to create an IAM user, generate an access key pair, and save it as repository secrets. The workflow then reads those secrets as environment variables.
name: deploy-with-static-keys
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: aws s3 sync ./site s3://example-bucket
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: us-east-1This works, and it is simple. The problems show up later.
Why this becomes a liability
The credential does not expire
An access key is valid until someone deletes or rotates it. If it leaks, an attacker can use it next week or next year. Nothing about the key limits where or when it is used.
The credential is not tied to a context
The key does not know which repository, branch, or workflow is using it. Anyone who obtains the value can use it from any machine. The cloud provider sees only "this key", not "the deploy job on main".
Secrets leak in many ways
- A workflow change on a branch or pull request can print or send the secret. Masking in logs only hides exact matches, so encoding the value defeats it.
- A compromised third-party action runs with the same environment as your job.
- Developers copy keys into local config files, chat messages, or tickets.
- Logs, build artifacts, and caches can capture environment values by accident.
Rotation is manual work
Rotating means creating a new key, updating the secret in every repository that uses it, and deleting the old key. Across many repositories and environments, this is tedious. Teams skip it, and keys stay in use for years.
Ownership and auditing are weak
A shared key hides who or what acted. CloudTrail shows the IAM user, not the workflow run. When the key is reused across repositories, one compromise affects all of them.
What a better design needs
The problems above point to the properties you want from a CI credential:
| Problem with static keys | Property you want |
|---|---|
| Never expires | Short-lived, minutes at most |
| Works from anywhere | Bound to a specific repository, branch, or workflow |
| Must be stored | Nothing stored in GitHub secrets |
| Manual rotation | Issued fresh on every run |
| Weak audit trail | Identity visible in cloud logs |
OpenID Connect (OIDC) federation provides these properties. Instead of storing a secret, the workflow proves who it is each time it runs. The cloud provider checks that proof against a trust policy and returns temporary credentials.
The rest of this tutorial shows how the pieces work: the token format, GitHub's role as the identity provider, the claims inside the token, and the trust policy on the cloud side.
Exercise
A team stores an AWS access key in a repository secret. Name two properties of that key that make a leak more damaging than a leak of an OIDC-issued credential.
Show answer
The key does not expire, so a leaked copy stays usable until someone rotates it. It is also not bound to a repository, branch, or workflow, so an attacker can use it from any machine. An OIDC-issued credential is short-lived and is only issued when the token matches the trust policy.