Security rules
NGB092: Excessive workflow token permissions
Reads GitHub Actions workflows and reports permissions: write-all (workflow or job level), and workflows triggered by events that process contributor-controlled data (pull_request_target, workflow_run, issue_comment, issues, pull_request_review_comment, discussion, discussion_comment) that declare no permissions at all, so the GITHUB_TOKEN gets the repository default..
| Property | Value |
|---|---|
| Rule ID | NGB092 |
| Category | Supply chain |
| Default severity | medium |
| CWE | CWE-250, CWE-732 |
| Built-in presets | recommended: error, strict: error |
Confidence is reported per finding (high, medium, low) and is independent of severity. See Reading findings.
What it checks
Reads GitHub Actions workflows and reports permissions: write-all (workflow or job level), and workflows triggered by events that process contributor-controlled data (pull_request_target, workflow_run, issue_comment, issues, pull_request_review_comment, discussion, discussion_comment) that declare no permissions at all, so the GITHUB_TOKEN gets the repository default.
Why it matters
Every job receives a GITHUB_TOKEN. If any step is compromised — a script injection (NGB094), a hijacked third-party action (NGB093) or executed PR code (NGB091) — the token's scopes decide the damage: with contents: write an attacker pushes to branches and tags, with actions: write they alter workflows, with packages: write / id-token: write they publish. Least privilege turns a full compromise into a read-only one.
Detection behavior and supported patterns
permissions: write-allat workflow or job level (high severity)- Workflow with a privileged trigger, no top-level
permissions:and at least one job without its ownpermissions:(medium severity, low confidence: the default depends on repository / organization settings) permissions: read-all,{}and explicit scope maps are not reported
Example
on: issue_commentpermissions: write-allSafer alternative
on: issue_commentpermissions: contents: readjobs: triage: permissions: issues: writeRemediation
Set permissions: {} or permissions: { contents: read } at the top of every workflow and grant individual write scopes only to the jobs that need them. Avoid write-all.
False-positive considerations
- Repositories whose default token permission is already read-only are reported for missing
permissions:; adding an explicit block documents the intent and removes the finding.
Known limitations
- The repository / organization default token permission ("Read and write" vs "Read") is not visible; missing
permissions:is therefore low confidence. - Individual write scopes are not judged; whether a job needs
pull-requests: writedepends on what it does.
References
Run it
ngbastion explain NGB092