ci/least-privilege
Workflows declare minimal permissions
| Severity | warning |
| Tiers | 1, 2 |
| Stacks | any |
| Scope | root |
| Kind | expr |
| Source | library v0.1.0 |
| Selected by | fleetlint-recommended@v0.1.0 |
Requirement
Every GitHub Actions workflow sets top-level permissions (normally contents: read), or every job sets its own, and escalates per job only; write-all is never used. Gitea and Forgejo workflows are not checked: their token’s scope is not set by the workflow file. GitLab CI has no equivalent in the file.
Why
The default token has write access to the repo; a compromised action in a read-only workflow can do far less.
Applies when
workflows().exists(w, ci_kind(w) == "github")Check
For each item in:
workflows().filter(w, ci_kind(w) == "github")type(yaml(item)) == map && ("permissions" in yaml(item)
|| ("jobs" in yaml(item) && type(yaml(item).jobs) == map && yaml(item).jobs.size() > 0
&& yaml(item).jobs.all(k, type(yaml(item).jobs[k]) == map && "permissions" in yaml(item).jobs[k])))
&& !("permissions" in yaml(item) && yaml(item).permissions == "write-all") && jobs(item).all(j, j.permissions != "write-all")Fix
Add permissions: { contents: read } at the top of each workflow and widen per job.
Agent instruction: Add top-level permissions: { contents: read } to every workflow lacking it; move any wider permission to the job that needs it and replace write-all with the scopes actually used.
See: https://fleetlint.org/baseline/#security
Generated by fleetlint docs from catalog v0.1.0.