Safeguard
Security Guides•

What does id-token: write do in GitHub Actions?

The id-token: write permission lets a job request an OIDC token. It grants no write access to your repo or cloud. What it does and what to pair it with.

Safeguard Security Team
4 min read

The id-token: write permission lets a GitHub Actions job request an OpenID Connect (OIDC) token from GitHub. It does not grant write access to your repository, packages, or cloud. Without it, the job cannot fetch the token, so keyless cloud login fails. Grant it only to the jobs that need to authenticate.

Definition

OIDC in Actions means each job can receive a signed JWT that describes the workflow: which repository, which branch or environment, which workflow file. A cloud provider checks that token against a trust rule you wrote and, if it matches, returns a short-lived access token. That replaces a stored cloud key.

The permission name is confusing. GitHub's reference says it only allows the workflow to request and use an OIDC token, and that it does not grant write access to other resources. Think of it as "may ask for a badge", not "may edit things".

What happens without it

If a job lacks the permission, the token cannot be requested. In practice you see a login step fail with an error about a missing token request URL or token. The fix is to add the permission, not to add a secret.

How to set it

Set permissions at the job level so only the job that talks to the cloud gets it:

permissions:
  id-token: write
  contents: read

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Cloud login step goes here
        run: echo "login with the provider's official action"

The contents: read line matters. Once you write a permissions block, any permission you do not list drops to none. If you use the checkout action, you need contents: read listed explicitly.

What to pair it with

The permission alone is not the security control. The trust rule on the cloud side is. GitHub's guidance is blunt: you must define at least one condition, so untrusted repositories cannot request access tokens for your resources. A trust policy that accepts any token from GitHub's issuer would let any repository on GitHub try to assume your role.

PieceWhere it livesWhat it controls
id-token: writeWorkflow fileWhether the job can fetch a token
Audience (aud)Token and cloud providerWhich service the token is meant for
Subject (sub) and other claimsCloud trust policyWhich repo, branch, or environment is trusted

Reusable workflows

Reusable workflows owned by the same user, organization, or enterprise expose their OIDC token to the caller's context. For workflows outside your organization or enterprise, GitHub says to set id-token to write explicitly at the caller workflow or job level, so only intended callers receive the token.

Steps to adopt it safely

  1. Add a permissions block with id-token: write and contents: read to the deploy job only.
  2. Create the cloud trust rule first, with conditions on audience and subject.
  3. Replace the stored key with the provider's login action.
  4. Delete the old secret once a successful run proves the new path works.
  5. Check that pull request jobs from forks and Dependabot cannot reach the role.

Try it yourself

Click through it at your own pace, or open it full screen. Watch how a pull request is held until checks pass, then think about which of your own workflow jobs should hold cloud access at all.

Quick check

Does id-token: write let a workflow push to my repository?

No. It only allows requesting an OIDC token. Repository write access comes from the contents permission, which you set separately.

Should I set it at the workflow level or the job level?

Prefer the job level, so only the job that needs cloud access can request a token.

Safeguard can enforce policies and gates on pull requests, so a workflow change that widens permissions can be reviewed before merge. You can run a free scan at gold.safeguard.sh/scan.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.