Fix GitHub Actions permissions: write-all & persist-credentials: false
Eliminate over-privileged GITHUB_TOKEN blast radius (GHA017, GHA018)
and stop actions/checkout from caching credentials in .git/config
(GHA020). Audit your private workflows locally—0 bytes uploaded.
0 bytes uploaded · 0 GitHub OAuth · One-time local CLI & automated hardening diff via Polar.sh.
.github/workflows/*.yml files here or paste YAML below to check
GITHUB_TOKEN permissions and generate an offline hardening diff.
Offline Hardened YAML Diff Preview
Vulnerable vs. Least-Privilege Permissions YAML
Setting permissions: write-all hands every build tool and transitive npm/Python postinstall hook
full repository write access. Declare permissions: contents: read at the workflow root, scope write
grants to specific jobs only, and set persist-credentials: false on actions/checkout.
name: Build and Test
on:
pull_request:
branches: [main]
permissions: write-all
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20"
- run: npm ci && npm test
name: Build and Test
on:
pull_request:
branches: [main]
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- uses: actions/setup-node@39370e3970a6d050c480ffad7ff0ed4d3fdee5af # v4.1.0
with:
node-version: "20"
- run: npm ci && npm test
GitHub Actions Token & Credential Rules Checked
| Rule | CWE | Misconfiguration | Least-Privilege Fix |
|---|---|---|---|
GHA017 |
CWE-250 | Missing top-level or job-level permissions: block |
Add explicit permissions: { contents: read } at workflow root. |
GHA018 |
CWE-250 | permissions: write-all granted to workflow or job |
Replace with minimal per-job scopes (e.g., contents: read, packages: write). |
GHA019 |
CWE-269 | High-risk write permission granted on untrusted PR trigger | Keep PR test jobs read-only; isolate write actions into gated workflows. |
GHA020 |
CWE-522 | actions/checkout omits persist-credentials: false |
Set persist-credentials: false so .git/config never stores the token. |
GHA022 |
CWE-269 | id-token: write declared globally at top-level |
Move id-token: write strictly into the single deploy/attestation job that mints OIDC JWTs. |
Enforce Least-Privilege Permissions Across Every Repo Locally
Audit every repository folder in one command with runnerproof-cli --repos-dir and export SARIF
2.1.0 plus an auditor-signed SOC 2 CC8.1 / EU CRA Art. 14 dossier:
Frequently Asked Questions
Why is permissions: write-all dangerous in GitHub Actions?
It grants the runner's GITHUB_TOKEN write access to repository contents, releases, packages,
and deployments—turning any compromised test or dependency into full repository takeover.
Why should actions/checkout always set persist-credentials: false?
Without it, actions/checkout leaves the GITHUB_TOKEN inside .git/config,
allowing any later script or malicious package hook to extract and replay the token.
How should I grant write permissions when only one job deploys?
Set workflow-level permissions: contents: read as a safe default, then add specific write
scopes only inside the single deploy or release job protected by a GitHub environment gate.
Related GitHub Actions Remediation Guides
CVE-2025-30066 & reviewdog Fix
Audit tj-actions/changed-files and reviewdog/action-setup IOCs and auto-pin 40-char SHAs.
Script Injection Remediation
Move ${{ github.event.* }} expressions into safe env: bindings to eliminate shell RCE.
SOC 2 CC8.1 & EU CRA Guide
Generate tamper-evident CI/CD audit evidence packs for SOC 2 CC8.1 and EU CRA Art. 14.