Sub topic 1
Why Stored Cloud Credentials Are a Liability
Prerequisites
Assume you know basic GitHub Actions syntax, repository secrets, HTTP, JSON, and the purpose of cloud IAM roles.
Long-Lived Credentials Create Risk
A stored cloud credential is a secret such as an access key and secret key. A workflow uses it repeatedly until someone revokes or rotates it.
This creates several risks:
- A secret may be copied into logs, build artifacts, or a compromised runner.
- Anyone who obtains it can use it outside GitHub Actions.
- Rotation requires updating every workflow that uses the secret.
- A broad IAM permission set can expose more resources than one deployment needs.
OpenID Connect, or OIDC, replaces this pattern with a short-lived identity token. The workflow proves who it is, and the cloud provider exchanges that proof for temporary credentials.
OpenID Connect and JWTs in a Nutshell
OIDC is an identity layer built on OAuth 2.0. In GitHub Actions, an identity provider issues a signed JSON Web Token, or JWT. A JWT is a compact token containing claims, which are statements about the requester.
The exchange follows this path:
GitHub Actions as an Identity Provider
GitHub acts as the OIDC provider. A job with the id-token: write permission can request a token. The permission allows token issuance; it does not allow access to cloud resources.
The workflow sends the token to a cloud security service, such as AWS Security Token Service. That service checks the token before issuing temporary credentials.
Token Claims
Claims describe the token's identity and intended use.
| Claim | Meaning |
|---|---|
| `iss` | The issuer, such as GitHub's OIDC URL |
| `aud` | The intended audience, often `sts.amazonaws.com` |
| `repository` | The repository that ran the job |
| `ref` | The Git reference, such as the `main` branch |
| `sub` | The token subject used in trust conditions |
The `sub` Claim: Who Is Asking?
The sub claim identifies the workflow context. For a branch run, it can look like:
repo:octo-org/octo-repo:ref:refs/heads/main
A trust policy can require this exact subject. That restriction prevents a pull request, another branch, or another repository from assuming the same role.
Exercise
Why is a subject restriction safer than trusting every token issued by GitHub?
Show answer
It limits access to a specific repository and workflow context instead of every GitHub Actions job.