Skip to main content
CriticalSecretsOWASP A07:2021CWE-798

How to fix: GitHub PAT in source

ghp_* / gho_* / ghu_* / ghs_* / ghr_* tokens grant repo / user access.

Why it matters

A leaked GitHub PAT gives an attacker access to every repository and organization the token owner can reach, including private repos, source code, CI/CD secrets, and deployment keys. Fine-grained tokens are scoped, but classic PATs are often overprivileged.

ghp_* / gho_* / ghu_* / ghs_* / ghr_* tokens grant repo / user access.

How to fix it

  1. 1Revoke the token immediately via GitHub Settings → Developer Settings → Personal Access Tokens
  2. 2Audit the token's usage in the GitHub security log before revoking
  3. 3Switch to fine-grained tokens with the minimum required scopes and expiry dates

Code examples

Revoke and audit the compromised token

bash
# Check recent usage for the token (replace TOKEN with the actual token)
curl -H 'Authorization: token TOKEN' https://api.github.com/user

# List recent events that may have used the token
curl -H 'Authorization: token TOKEN' https://api.github.com/users/OWNER/events

# Then revoke immediately at:
# https://github.com/settings/tokens

Use GitHub Actions secrets instead of hard-coded tokens

YAML
# .github/workflows/deploy.yml
jobs:
  deploy:
    steps:
      - uses: actions/checkout@v4
        with:
          # Use the automatically-provided GITHUB_TOKEN
          token: ${{ secrets.GITHUB_TOKEN }}
      # Never hard-code a PAT in workflow files
      # If you need a PAT, store it in GitHub Actions Secrets:
      - run: gh release create v1.0.0
        env:
          GH_TOKEN: ${{ secrets.MY_PAT }}

References

Detected automatically by VulnRadar. The check id is secret-github-pat, stable across every scan so you can filter or diff on it.

See every secrets check

Questions

How severe is GitHub PAT in source?
VulnRadar rates this critical severity in the secrets category. The severity is fixed per check, not scored per site, so the same finding is the same severity on every scan.
Does VulnRadar check for this automatically?
Yes. It runs as part of every scan under the check id secret-github-pat, which stays the same between runs so you can filter, diff, or gate CI on it.
Which standards does GitHub PAT in source map to?
It maps to CWE-798. In the OWASP Top 10 it falls under A07:2021.

Missing a check?

The detection set is open. If you know a misconfiguration this does not catch, propose it: the issue template asks for the threat model, how to detect it, the false-positive risk, and a test fixture, which is the same thing a maintainer would have to work out anyway.

Propose a checkHow a check is built

Scan your own site for github pat in source

VulnRadar runs this check and hundreds more against a URL in seconds. No agent to install, just paste a URL.

Or scan this site as a demoRead the docs

How to fix: GitHub PAT in source | VulnRadar