Sub topic 4
What is inside the token: claims
This chapter assumes you know basic GitHub Actions syntax and have a general idea of cloud IAM roles. It also assumes you can read JSON. You do not need to know how to sign or verify a token yet. Later chapters cover that.
What a claim is
GitHub's OIDC token is a JSON Web Token (JWT). A JWT has three Base64URL-encoded parts separated by dots: a header, a payload, and a signature. The payload is a JSON object. Each key in that object is a claim, a statement that the issuer makes about the token or about the workflow run that requested it.
Claims fall into three groups:
- Registered claims are defined by the JWT and OIDC standards:
iss,aud,sub,iat,nbf,exp, andjti. - Context claims describe the repository, the ref, the event, and the workflow. GitHub adds these, for example
repository,ref, andworkflow. - Identity claims describe who or what triggered the run, such as
actorandrepository_owner.
A cloud provider never sees your workflow file. It sees only these claims. Everything your trust policy can check comes from this payload, so knowing what each claim means is the basis for writing safe policies.
An example payload
This abbreviated payload is 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 registered claims
iss: who issued the token
iss is the issuer. For GitHub.com it is always https://token.actions.githubusercontent.com. A cloud provider uses this value to decide which identity provider signed the token and where to fetch the public keys that verify the signature. If you use GitHub Enterprise Server, or an enterprise with its own issuer URL, the value differs. Check what your account actually issues instead of copying the GitHub.com value.
aud: who the token is for
aud is the audience, the party that is supposed to accept the token. You choose it when you request the token. For AWS it is usually sts.amazonaws.com. A token meant for one service must be rejected by another. This stops a token that leaked to a third-party service from being replayed against your cloud account. The next chapters show how to set the audience when you request a token.
sub: who is asking
sub is the subject. GitHub builds it from the repository and the run context. In the example above it is repo:octo-org/octo-repo:ref:refs/heads/main. This is the claim most trust policies match on, because it identifies a specific repository and branch, tag, pull request, or environment. The following chapter covers its formats in detail.
iat, nbf, and exp: when the token is valid
These are Unix timestamps in seconds.
iatis when the token was issued.nbfis the earliest time the token is valid.expis when it expires.
GitHub tokens are short-lived. A verifier rejects a token outside the nbf to exp window, usually allowing a small clock skew. If your job takes a long time, request a fresh token instead of reusing the first one.
jti: a unique token ID
jti is a unique identifier for the token. It lets a verifier detect replay if it chooses to track seen IDs. Most cloud providers do not require this, and you rarely write policies against it.
The context claims you will use most
GitHub adds many claims about the run. These are the ones that matter most for access decisions.
| Claim | Example value | What it tells you |
|---|---|---|
| `repository` | `octo-org/octo-repo` | Owner and name of the repository |
| `repository_owner` | `octo-org` | The user or organization that owns it |
| `ref` | `refs/heads/main` | The full Git ref that triggered the run |
| `ref_type` | `branch` | Whether the ref is a branch or a tag |
| `event_name` | `push` | The event that started the workflow |
| `workflow` | `deploy` | The workflow name |
| `actor` | `octocat` | The account that triggered the run |
| `environment` | `production` | The deployment environment, if the job uses one |
| `job_workflow_ref` | `octo-org/octo-repo/.github/workflows/deploy.yml@refs/heads/main` | The exact workflow file and ref that is running |
| `runner_environment` | `github-hosted` | Whether the job runs on a GitHub-hosted or self-hosted runner |
Some of these claims have close relatives you may see in real tokens, for example repository_id, repository_owner_id, sha, run_id, run_number, run_attempt, workflow_ref, and head_ref and base_ref for pull requests. Prefer immutable IDs such as repository_id and repository_owner_id when you worry about a repository being renamed or deleted and its name being claimed by someone else. See the security practices chapter for this point.
repository and ref
repository and ref are the same information that sub packs into one string. Many providers let you match the individual claims instead of parsing sub. AWS IAM trust policies, for example, can only match a limited set of claims directly, so sub is the standard way to restrict by repository and branch there. Other providers let you match many claims.
environment
If a job declares an environment, the token carries it, and the default sub changes to the form repo:octo-org/octo-repo:environment:production. Because environments can have required reviewers and branch protection rules, an environment-based trust policy lets GitHub's own approval checks gate cloud access.
job_workflow_ref
job_workflow_ref names the workflow file that is actually running the job, including its ref. In a normal workflow it points to the workflow in your repository. In a reusable workflow it points to the called workflow, which may live in a different repository. A later chapter covers why that makes it a useful way to require that only a trusted, shared workflow can obtain cloud access.
actor
actor is the user who triggered the run. It is useful in logs and audit trails. Be careful when using it for authorization, because it describes the person, not the code that is running. Someone with a valid account can trigger a workflow in many ways.
Seeing the claims for yourself
You can read your own token to learn what it contains. The job needs the id-token: write permission. The environment variables below are set by GitHub inside such a job.
name: inspect-token
on:
workflow_dispatch:
permissions:
id-token: write
contents: read
jobs:
inspect:
runs-on: ubuntu-latest
steps:
- name: Print the claims, not the token
run: |
TOKEN=$(curl -sS \
-H "Authorization: Bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
"$ACTIONS_ID_TOKEN_REQUEST_URL&audience=sts.amazonaws.com" \
| jq -r '.value')
echo "::add-mask::$TOKEN"
echo "$TOKEN" | cut -d '.' -f 2 | tr '_-' '/+' | base64 -d 2>/dev/null | jq .The script does four things:
- It requests a token with the audience
sts.amazonaws.com. - It masks the token in the logs with
::add-mask::. - It takes the second dot-separated segment, which is the payload.
- It converts Base64URL characters to standard Base64, decodes the result, and pretty-prints the JSON.
The base64 -d step may complain about missing padding on some payloads. The 2>/dev/null hides that warning, but if the output is cut off, add = padding characters before decoding.
Claims are statements, not proof
A decoded payload is just JSON. Anyone can write JSON that looks like a GitHub token. A claim has meaning only after the verifier has checked the signature against GitHub's published keys and confirmed iss, aud, and the time window. The chapter on validation covers these checks.
Two consequences follow:
- Your code should not make decisions from a decoded token it has not verified.
- Trust policies should check claims that the cloud provider has already verified, and they should check enough of them to be specific.
Common mistakes
- Treating
actoras proof of safety. It tells you who triggered the run, not what code ran. - Matching only
repository_owner. This allows every repository in the organization to obtain access. - Matching on
subwith a wildcard that is too broad, such asrepo:octo-org/*. This gives the same over-broad access. - Assuming claims are present in every token.
environmentappears only when the job uses one.head_refandbase_refappear only on pull request events. - Hard-coding the issuer for GitHub Enterprise Server or an enterprise-specific issuer. Check the value your account issues.
Summary
- The token payload is a JSON object, and each key is a claim.
- Registered claims (
iss,aud,sub,iat,nbf,exp,jti) say who issued the token, who it is for, and when it is valid. - Context claims (
repository,ref,environment,job_workflow_ref, and others) describe the run. - Claims mean something only after the cloud provider verifies the token.
Exercise
A trust policy checks only that repository_owner equals octo-org. Why is this too permissive, and which claims would you add to restrict access to the main branch of one repository?
Show answer
Every repository in the octo-org organization, and every branch and workflow in them, produces tokens with that owner value, so any of them could assume the role. Add a check on sub (for example repo:octo-org/octo-repo:ref:refs/heads/main) or on repository together with ref. For tighter control, also check aud, and consider job_workflow_ref to require a specific workflow file.
Exercise
You decode a token's payload in a workflow step and see "aud": "sts.amazonaws.com". A colleague says this proves AWS will accept the token. Is that correct?
Show answer
No. Decoding only shows what the payload says. AWS accepts the token only after it verifies the signature with GitHub's public keys, confirms iss matches a configured provider, confirms aud matches, checks the time window, and evaluates the role's trust policy conditions. A matching aud is necessary but not sufficient.