Skip to main content

SKY-D291 · CI/CD pipelines

GitHub Actions missing or broad token permissions

High

The catalog lists HIGH, but the detector grades each finding. HIGH: a write-all grant, or a workflow-level write on actions, attestations, contents, deployments, id-token, issues, packages, pages or pull-requests. MEDIUM: no permissions at all, a read-all grant, or write on any other scope.

Every workflow job gets a GITHUB_TOKEN, and its permissions: block says what that token may do. Without one, the job gets the repository's default, which can be read-write. SKY-D291 reports workflows that leave the token at the default, and grants that are broader than the jobs need.

Languages
GitHub Actions workflows
Quality gate
counted toward the gate limits (full and diff scans)
Finding type
review
Catalog name
GitHub Actions excessive permissions
Wrong result? Report itA false positive, a missed case or a confusing message: it goes privately to the founder.

Why it matters

Any step can read the token: a compromised action, a dependency's install script, or a test that runs pull request code. With write access it can push commits, move release tags or approve its own changes, so one bad dependency becomes a change to your default branch.

What Skylos flags

.github/workflows/ci.yml · YAMLReported on line 1
name: CIon:  push:    branches: [main]  pull_request:jobs:  test:    runs-on: ubuntu-latest    steps:      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2      - run: make test  lint:    runs-on: ubuntu-latest    steps:      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2      - run: make lint

What Skylos leaves alone

.github/workflows/ci.yml · YAML
name: Releaseon:  push:    tags: ["v*"]permissions:  contents: writejobs:  release:    runs-on: ubuntu-latest    steps:      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2        with:          persist-credentials: false      - run: make dist      - run: gh release create "$GITHUB_REF_NAME" dist/*        env:          GH_TOKEN: ${{ github.token }}

Why Skylos leaves it alone

contents: write sits at the workflow level, but only one job inherits it, so it is already as narrow as a job-level grant. Skylos reports a workflow-level write only when two or more jobs inherit it.

How Skylos decides

  1. Reads workflow files under .github/workflows. A job's own permissions: replaces the workflow's completely, so workflow-level values are judged only by the jobs that inherit them (jobs without their own block).
  2. No workflow-level permissions: and at least one job without its own: one MEDIUM finding on line 1, naming those jobs. When every job declares its own, nothing is reported.
  3. Workflow-level read-all or write-all with at least one inheriting job: MEDIUM for read-all, HIGH for write-all.
  4. Workflow-level scopes set to write with two or more inheriting jobs: one finding per write scope, graded by scope (see the severity note). With one inheriting job it is not reported.
  5. A job's own read-all (MEDIUM) or write-all (HIGH) is reported on that job. A job's own list of scopes, writes included, is never reported.

How to fix it

Declare a read-only default at the top and grant writes only on the job that needs them.

.github/workflows/ci.yml · YAML · the fix, against the flagged file
name: CIon:  push:    branches: [main]  pull_request:Added: permissions:Added:   contents: readjobs:  test:    runs-on: ubuntu-latest    steps:      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2      - run: make test  lint:    runs-on: ubuntu-latest    steps:      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2      - run: make lint

When it can be wrong

  • A missing block is reported even when the repository or organization already sets the default token to read-only. Skylos cannot see that setting.
  • read-all is reported, although it grants no write access, because it reads more than most jobs need.

Seeing a case that isn't listed here? Report the wrong result so the rule can be fixed. Don't paste company code: describe the shape of it.

How to silence it

  • Put skylos: ignore[SKY-D291] on the reported line or the line directly above it. A missing block is always reported on line 1, so that marker goes on the first line of the file.

    YAML
    # skylos: ignore[SKY-D291] org default token is read-onlyname: CI
  • A baseline (skylos baseline ., then --baseline) also hides it. The entry is the rule, the absolute file path and the line, so it stops matching when the checkout moves to another path.

  • [tool.skylos] ignore = ["SKY-D291"] turns the rule off for the whole project.

From the Skylos rule handbook, Skylos 5.8.0 (commit 5b880b0). All rules.