Skip to main content

SKY-A103 · AI-code defects

CI permission expansion

High

A GitHub Actions workflow gets a token whose rights are set by its permissions: block, and some triggers run with the base repository's secrets. SKY-A103 reports a change that adds a write permission, permissions: write-all, or a pull_request_target or workflow_run trigger.

Languages
GitHub Actions workflows
Turned on by
skylos . --ai-defects --diff origin/main (or -a) on a change
Quality gate
counted toward the gate limits (full and diff scans). Counts toward max_ai_defects when the scan has a change to compare. HIGH findings do not block on their own unless HIGH is added to block_ai_defect_severities under [tool.skylos.gate].
Finding type
review
Wrong result? Report itA false positive, a missed case or a confusing message: it goes privately to the founder.

Why it matters

A token that can write to the repository, publish packages or mint cloud credentials turns any mistake in that job into a supply-chain risk. An agent that hits a permission error often fixes it by widening the permission, and the one-word change is easy to miss in review.

What Skylos flags

A change: the first version of these files is committed, then the edit below is made without committing, and Skylos reviews it as a diff scan (--diff).

.github/workflows/release.yml · YAML · changed
name: release on:  push:    tags: ["v*"] permissions:Removed:   contents: readAdded:   contents: write jobs:  publish:    runs-on: ubuntu-latest    steps:      - uses: actions/checkout@v4      - run: make release
1 committed file the change leaves alone
release/version.py · YAML
def next_version(current):    major, minor, patch = current.split(".")    return f"{major}.{minor}.{int(patch) + 1}"

What Skylos leaves alone

A change: the first version of these files is committed, then the edit below is made without committing, and Skylos reviews it as a diff scan (--diff).

.github/workflows/release.yml · YAML · changed
name: release on:  push:    tags: ["v*"] permissions:Removed:   contents: writeAdded:   contents: write  # the release job pushes the version tag jobs:  publish:    runs-on: ubuntu-latest    steps:      - uses: actions/checkout@v4      - run: make release
1 committed file the change leaves alone

release/version.py: same as in the flagged example.

Why Skylos leaves it alone

The change touches the contents: write line but only adds a comment. The removed line held the same permission, so nothing was widened.

More languages

YAML

Flagged

A change: the first version of these files is committed, then the edit below is made without committing, and Skylos reviews it as a diff scan (--diff).

.github/workflows/labels.yml · YAML · changed
name: label pull requests Removed: on: pull_requestAdded: on: pull_request_target jobs:  label:    runs-on: ubuntu-latest    steps:      - uses: actions/labeler@v5
1 committed file the change leaves alone
app/labels.py · YAML
def label_for(path):    if path.startswith("docs/"):        return "documentation"    return "code"

Not flagged

A change: the first version of these files is committed, then the edit below is made without committing, and Skylos reviews it as a diff scan (--diff).

.github/workflows/labels.yml · YAML · changed
name: label pull requests Removed: on: pull_requestAdded: on: [pull_request, merge_group] jobs:  label:    runs-on: ubuntu-latest    steps:      - uses: actions/labeler@v5
1 committed file the change leaves alone

app/labels.py: same as in the flagged example.

Why Skylos leaves it alone

The workflow gained a trigger, but merge_group runs with the same rights as pull_request. Only pull_request_target and workflow_run run with the base repository's secrets and token.

How Skylos decides

  1. Runs with --ai-defects when there is a change to compare: in a diff scan (--diff or --diff-base), or in a full scan of a Git checkout with uncommitted changes. It reads the Git diff of each changed file against the base.
  2. Looks only at .yml and .yaml files under a .github/workflows/ folder.
  3. On each added line it looks for permissions: write-all, a write grant for a token scope such as contents, packages, id-token, actions, pull-requests or security-events (block or inline {...} form), and a pull_request_target or workflow_run trigger in an on: value or list entry. Comments are stripped first.
  4. A removed line with the same grant or trigger cancels the added one: for on: and the top-level permissions: anywhere in the file, for other lines only when one line was replaced by one line. So moving or commenting a line is not reported.
  5. Reports each new grant or trigger on its added line, with severity HIGH.

How to fix it

Keep the workflow's token read-only and grant write only to the one job that needs it, for the one scope it needs. If the release must push a tag, give that job contents: write and leave every other job at contents: read.

.github/workflows/release.yml · YAML · the fix, against the flagged file
name: release on:  push:    tags: ["v*"] permissions:Removed:   contents: writeAdded:   contents: read jobs:  publish:    runs-on: ubuntu-latest    steps:      - uses: actions/checkout@v4      - run: make release

When it can be wrong

  • A deliberate grant, such as id-token: write for trusted publishing, is reported. That is intended: the finding asks a reviewer to confirm it.
  • Moving a job-level grant to a different job in a multi-line edit is reported again, because only one-line replacements are compared for job-level blocks.
  • Workflows outside .github/workflows/, such as composite actions in action.yml, are not read.
  • In a repository with no source file Skylos analyses (only workflows and YAML, say), the scan takes a shorter path that does not run this rule, so nothing is reported.

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

  • An inline # skylos: ignore[SKY-A103] comment does not silence it in Skylos 5.6.0: the inline-ignore lookup does not match this rule's findings in workflow files.

    YAML
    contents: write  # skylos: ignore[SKY-A103] release pushes the tag
  • [tool.skylos] ignore = ["SKY-A103"] turns the rule off for the project.

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