Sub topic 4
What is inside the token: claims
This chapter assumes you know basic GitHub Actions syntax and have a general idea of what a JWT (JSON Web Token) is. You should also know what an IAM role and trust policy do. Here you will read the claims in a GitHub OIDC token and learn which ones a cloud provider should check.
What a claim is
A JWT has three parts: a header, a payload, and a signature. The payload is a JSON object. Each key in it is a claim, a statement that the issuer (GitHub) makes about the workflow run. The cloud provider trusts these statements only after it verifies the signature, which a later chapter covers.
The payload is encoded, not encrypted. Anyone who holds the token can read it, so treat the token itself as a secret even though its contents are not.
An example payload
This abbreviated payload comes from a push to main. A real token contains more claims, plus the standard iat, nbf, and exp timestamps.
{
"iss": "https://token.actions.githubusercontent.com",
"aud": "sts.amazonaws.com",
"sub": "repo:octo-org/octo-repo:ref:refs/heads/main",
"repository": "octo-org/octo-repo",
"ref": "refs/heads/main",
"event_name": "push",
"workflow": "deploy",
"actor": "octocat",
"job_workflow_ref": "octo-org/octo-repo/.github/workflows/deploy.yml@refs/heads/main"
}The claims that matter most
The claims fall into two groups. Standard OIDC claims describe the token. GitHub-specific claims describe the run.
| Claim | Group | Meaning |
|---|---|---|
| `iss` | Standard | The issuer. For GitHub.com this is `https://token.actions.githubusercontent.com`. |
| `aud` | Standard | The audience, meaning the service the token is meant for. |
| `sub` | Standard | The subject, a string that identifies the workflow run's origin. |
| `iat`, `nbf`, `exp` | Standard | When the token was issued, when it becomes valid, and when it expires. |
| `repository` | GitHub | The `owner/name` of the repository. |
| `ref` | GitHub | The full Git ref that triggered the run. |
| `event_name` | GitHub | The trigger, such as `push` or `pull_request`. |
| `actor` | GitHub | The user who triggered the run. |
| `workflow` | GitHub | The workflow name. |
| `job_workflow_ref` | GitHub | The path and ref of the workflow file that is running the job. |
Claims for the token
iss tells the verifier which provider to fetch signing keys from. aud stops a token meant for one service from being accepted by another. The time claims limit how long a stolen token is useful.
Claims for the run
repository, ref, and event_name describe where the run came from and why it started. sub combines some of these into one string, and the next chapter covers its formats. job_workflow_ref names the workflow file that defines the job. That matters most with reusable workflows, where the caller and the called workflow differ.
How claims become trust decisions
A cloud trust policy compares claims against expected values. In AWS, the policy keys are the provider hostname plus the claim name. For example, token.actions.githubusercontent.com:sub refers to the sub claim.
The flow below shows where claims are produced and where they are checked.
Claims you can trust and claims you should not rely on
GitHub fills in every claim, and the job cannot change them. A workflow author cannot edit repository or ref in the token. This is why the token works as proof of identity.
Some values are still weak signals. actor is the user who triggered the run, and anyone with push access can be that user. workflow is a display name, and an author can change it by editing the file. A policy built only on those claims is easy to satisfy by accident or on purpose. Prefer sub, repository, ref, and job_workflow_ref, which tie the token to a specific repository, branch, and workflow file.
Inspecting a real token
To see the claims for your own runs, decode the payload in a test workflow. Printing a full token to the logs is risky, so decode it in the same step and print only the payload.
TOKEN=$(curl -sS \
-H "Authorization: Bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
"$ACTIONS_ID_TOKEN_REQUEST_URL&audience=sts.amazonaws.com" \
| jq -r '.value')
echo "$TOKEN" | cut -d '.' -f2 | tr '_-' '/+' | base64 -d 2>/dev/null | jq .The job needs id-token: write for this to work, which a later chapter covers. The cut command takes the second dot-separated part, which is the payload. The tr command converts base64url characters to standard base64.
Exercise
A trust policy checks aud equals sts.amazonaws.com and iss is GitHub's issuer. A colleague says this is enough because the token is signed. Which claim would you add to the policy, and why?
Show answer
Add a condition on sub (or on repository and ref). The signature only proves that GitHub issued the token. Every repository gets a validly signed token with the same iss, so without a sub condition any repository could assume the role.