fleetlint Policy for a fleet of repositories
v0.6
Getting started

ci/least-privilege

Workflows declare minimal permissions

Severitywarning
Tiers1, 2
Stacksany
Scoperoot
Kindexpr
Sourcelibrary v0.3.1
Selected byfleetlint-recommended@v0.3.1

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.3.1.