Safeguard
Security Guides•

GITHUB_TOKEN, GitHub App token or PAT: which should a workflow use?

Default to the built-in GITHUB_TOKEN with minimum permissions. Use a GitHub App for other repositories. Use a PAT only when nothing else works.

Safeguard Security Team
3 min read

Default to the built-in GITHUB_TOKEN with minimum permissions. When a workflow must reach another repository or the organization, use a GitHub App installation token. Reach for a personal access token last, because it is tied to a person and usually lives longer than the job needs.

What each one is

GITHUB_TOKEN. Created automatically for each workflow run. GitHub says it can only access resources within the workflow's repository.

GitHub App installation token. A token your workflow generates from a GitHub App you registered. You choose the app's permissions at registration, and which repositories it can reach when you install it. GitHub's documented flow uses the actions/create-github-app-token action, with the client ID stored as a configuration variable and the private key stored as a secret.

Personal access token (PAT). A credential belonging to a user account.

Comparison

QuestionGITHUB_TOKENGitHub App tokenPAT
Reaches other repos or the orgNoYes, where installedYes, as the user
Tied to a personNoNoYes
You manage a long-lived secretNoA private keyThe token itself
Permissions setIn the workflowAt app registration and installAt creation

Steps

  1. Start with GITHUB_TOKEN. GitHub recommends setting the default to read-only for repository contents, then granting extra permissions per job.
  2. Need another repo? Register a GitHub App, give it only the needed permissions, and install it on only the needed repositories.
  3. Generate the token inside the job with the app token action, and pass it through the environment.
  4. Use a PAT only as a fallback, with the narrowest scope and expiry available. If the person leaves, the workflow breaks, which is a sign it should have been an app.
  5. Rotate the app private key on a schedule, and remove apps nobody uses.

Common mistakes

  • Using a PAT with broad access because a workflow needed to open a pull request in another repository.
  • Granting write permissions at the top of a workflow, so every job inherits them.
  • Storing the app private key as a repository secret in a repository that untrusted contributors can influence. Keep it in an environment with reviewers where you can.

Quick check

Can a workflow secret hold a PAT safely?

It can hold one, but the PAT still acts as the user and usually lives longer than the job. Prefer an app token or the built-in token.

Is a GitHub App always better than a PAT?

For automation, usually. It is not tied to a person and has narrower reach, but you still have a private key to protect.

Safeguard can enforce policies and gates on pull requests and scan dependencies, whichever credential your workflows use. Try the free 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.