1. Resources
  2. Identity Threats
  3. GitHub

GITHUB_TOKEN and Installation Token Abuse in GitHub Actions

Also known as: GITHUB_TOKEN abuse, Actions installation token theft, Over-permissioned workflow token, id-token write abuse

Code that runs in a GitHub Actions job can use the job's GITHUB_TOKEN and, with id-token: write, request an OIDC assertion, then act as the repository's automation or a cloud role.

Platform
GitHub
Impact
High
Last updated
Attack difficulty
Medium
Detection difficulty
High
Privileges required: Any authenticated identity
Code execution inside a workflow job: write access to the repository, a pull request that a privileged workflow runs, an injectable field, or a compromised action or dependency.
What the attacker gains
The job's installation token with every scope the workflow grants, and with id-token: write a signed assertion that cloud roles trusting the repository accept.

How it works

GitHub creates a separate GITHUB_TOKEN for each job. It is a GitHub App installation access token, an OAuth-style bearer token, scoped to the repository that contains the workflow. Whoever holds it during the job acts as the repository's automation.

Three layers decide what the token can do:

  1. The inherited default. Enterprise, organization and repository settings choose between a permissive default (read and write for most scopes) and a restricted one (read access to contents, packages and metadata).
  2. The permissions key. The workflow, then the job, can change the scopes. When any permission is specified, all the ones that are not listed are set to none. permissions: {} removes everything; write-all grants everything.
  3. Event restrictions. For a pull_request run from a fork the token is read-only. For pull_request_target it has read and write repository permission even when a public fork triggers it.

Two facts make the token easy to abuse. A step does not have to be handed the token: it is available in the github.token context, so every action in the job can use it. And nothing ties the token to the code that was meant to use it, so any command that runs in the job can call the API with it.

A job that declares id-token: write can also ask GitHub's OIDC provider for a signed JWT that describes the run: repository, ref, workflow, environment, actor and run attempt. The permission creates no cloud session on its own. A cloud provider that trusts the issuer https://token.actions.githubusercontent.com exchanges the assertion for credentials when the claims match its trust rule. This is workload identity federation, and the job is the workload identity.

Variants:

  • Over-broad default. An organization left on the permissive default gives every job write access it never asked for.
  • id-token: write reachable by untrusted code. The permission is set at workflow level, so build and test jobs that run third-party code can request the assertion too.
  • Token left in files. A checkout that persists its credentials writes the token into the workspace. A later step that uploads the workspace as an artifact publishes the token with it.
  • Approvals by the bot. Where "Allow GitHub Actions to create and approve pull requests" is on, a token with pull-requests: write can approve a pull request.
  • Reruns. Each attempt of a run gets fresh jobs and fresh tokens. A rerun started by another user is recorded with the same run id, a higher run_attempt and a different triggering_actor.

Prerequisites

  • Code execution in a job. The common routes are a pwn request, a script injection, a compromised action, or plain write access to a branch whose workflows run with privileges.
  • A token worth having: write scopes from a permissive default or a generous permissions block, or id-token: write together with a cloud trust rule that the job's claims satisfy.

Attack steps

For authorized security testing and lab use only. Run these steps against systems you own or have written permission to assess.

1. Map what tokens can do

An administrator, or an assessor working with an administrator's token, reads the defaults from the REST API:

# Default GITHUB_TOKEN permissions and whether Actions may approve pull requests
gh api /orgs/octo-org/actions/permissions/workflow
gh api /repos/octo-org/octo-repo/actions/permissions/workflow
# {"default_workflow_permissions":"write","can_approve_pull_request_reviews":true}

Without it, the workflow files tell the same story. zizmor's excessive-permissions audit flags broad or missing permissions blocks, and artipacked flags checkouts that persist credentials where artifacts can leak them:

zizmor --gh-token $(gh auth token) octo-org/octo-repo
grep -rnE "permissions:|id-token: write|write-all" .github/workflows/

The job's setup log lists the permissions the token actually received for that run, which settles any doubt about inheritance.

2. Use the token from inside the job

The token is a bearer token for the GitHub REST API. From a step that has it in GITHUB_TOKEN (or received it through github.token):

# What the run has produced so far
curl -s -H "Authorization: Bearer $GITHUB_TOKEN" \
  https://api.github.com/repos/octo-org/octo-repo/actions/artifacts

# With contents: write, replace a published release asset
GH_TOKEN="$GITHUB_TOKEN" gh release upload v1.2.3 dist/app.tar.gz --clobber --repo octo-org/octo-repo

What each scope is worth:

Scope What the attacker does with it
contents: write Push commits and tags, create releases, replace release assets
pull-requests: write Open, edit and, where allowed, approve pull requests
actions: write Delete caches, runs and logs; start other workflows
packages: write Publish package versions to the repository's registry namespace
id-token: write Request an OIDC assertion for cloud access

Events caused by the GITHUB_TOKEN do not start new workflow runs, with two documented exceptions: workflow_dispatch and repository_dispatch always do. A pull request that the token opens or updates creates runs that wait for approval. So a token with actions: write can still set off a deployment workflow that accepts manual dispatch.

3. Request the OIDC assertion

In a job with id-token: write, the runner exposes a request URL and a request token. Any step can call it and choose the audience the receiving provider expects (the example asks for the Microsoft Entra audience):

curl -s -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
  "$ACTIONS_ID_TOKEN_REQUEST_URL&audience=api://AzureADTokenExchange"

The response contains the JWT. Its sub claim depends on the job: repo:octo-org/octo-repo:environment:Production when the job references an environment, repo:octo-org/octo-repo:pull_request for a pull request event without one, otherwise repo:octo-org/octo-repo:ref:refs/heads/main or the tag form.

4. Exchange it at the cloud provider

The assertion goes to the provider that trusts the repository: AWS STS AssumeRoleWithWebIdentity, the Google Cloud Security Token Service, or the Microsoft identity platform for an application with a federated identity credential. The trust rule decides the outcome. A rule that matches repo:octo-org/octo-repo:*, or only the organization, accepts an assertion from any branch or pull request job. The provider pages cover the exchange: AWS, Google Cloud and Microsoft Entra ID.

Impact

A write-capable token lets the attacker change what the repository ships: source, tags, releases and packages. A token that can approve pull requests defeats a single-reviewer rule. An OIDC assertion accepted by a broad trust rule gives temporary credentials for a cloud role, often a deployment role with wide rights. None of this needs a stored secret, which is why removing long-lived secrets from Actions does not remove the risk by itself.

OPSEC and artifacts

  • Acting inside the job. The token dies with the job, so the attacker's API calls come from the runner's address during the run, and they look like the workflow's own calls. What remains is the result: a commit, tag, release, approval or deleted run made by the Actions bot at a time when the workflow had no reason to make it.
  • Sending the token out. A payload can post the token to an outside host and use it from there while the job is kept alive. The API calls then come from an address that is not a runner.
  • Printing instead of sending. Where logs are public, a payload can print encoded secrets to the job log and read them later. The log holds the encoded values until it is deleted.
  • OIDC requests. The request is a call from the runner to GitHub's OIDC provider, and the workflow file alone does not show whether it happened. The trace an investigator can rely on is on the receiving side: AssumeRoleWithWebIdentity in CloudTrail, ExchangeToken in Google Cloud Data Access logs, or a service principal sign-in in Microsoft Entra ID, each with success or failure.
  • Run records. The run export keeps id, run_attempt, event, head_sha, actor and triggering_actor; the job export adds runner_id and each step's name and conclusion. A failed run can still contain a step that published something before the failure.

Detection

SELECT eventTime, requestParameters, userIdentity, errorCode
FROM <event data store id>
WHERE eventSource = 'sts.amazonaws.com'
  AND eventName = 'AssumeRoleWithWebIdentity'
  AND recipientAccountId = '111122223333'
  • Reruns. A successful exchange belongs to one attempt. Compare actor with triggering_actor to see who started a rerun, and do not credit an earlier attempt's approval to a later one.

Mitigation

  • Set the default token to read-only at enterprise or organization level and turn off "Allow GitHub Actions to create and approve pull requests".
  • Declare permissions in every workflow, start from contents: read or permissions: {}, and add write scopes on the single job that needs them. This is least privilege applied to automation.
  • Grant id-token: write per job, not per workflow, and only on deployment jobs that reference a protected environment with required reviewers and branch restrictions.
  • Bind cloud trust to the environment or the exact ref. Match the full sub claim, and where the provider supports it also job_workflow_ref, instead of the repository or organization alone. The workload identity federation guide for Google Cloud shows the attribute conditions.
  • Keep the token off disk. Set persist-credentials: false on checkouts that do not need to push, and never upload the whole workspace as an artifact.
  • Do not replace the token with a broader one. A personal access token stored as a secret is long-lived and usually wider than the job needs. If one is unavoidable, follow the personal access token security guide.

Detection rules for this attack

Log events to collect

FAQ

What is the GITHUB_TOKEN in GitHub Actions?

It is a GitHub App installation access token that GitHub creates at the start of every job. It is limited to the repository that contains the workflow, carries the permissions the workflow and job declare, and expires when the job finishes.

Can an action read the GITHUB_TOKEN if the workflow does not pass it?

Yes. The token is available in the github.token context, so an action can use it even when the workflow never passes it as an input or environment variable. Limiting the token's permissions is the control, not withholding it from a step.

Does id-token: write give a job access to my cloud account?

Not by itself. The permission only lets the job request a signed OIDC assertion from GitHub. The cloud provider's trust configuration decides whether that assertion becomes credentials. If the trust accepts the whole repository or organization, any job that can request the assertion can assume the role.

Can a stolen GITHUB_TOKEN be used after the job ends?

No. The token expires when the job finishes or at its maximum lifetime. An attacker has to use it from inside the running job, or keep the job alive. Secrets and cloud keys taken in the same job have their own lifetimes.

References

Techniques, tactics and threat groups: MITRE ATT&CK® Enterprise v20.1. © The MITRE Corporation. This work is reproduced and distributed with the permission of The MITRE Corporation. Last updated 2026-11-29.

Does this attack work in your environment?

Forestall maps every identity and the attack paths between them across Active Directory, Entra ID and cloud, read-only and agentless.