SKY-A103 · AI-code defects
CI permission expansion
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_defectswhen the scan has a change to compare. HIGH findings do not block on their own unlessHIGHis added toblock_ai_defect_severitiesunder[tool.skylos.gate]. - Finding type
- review
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
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 release1 committed file the change leaves alone
def next_version(current): major, minor, patch = current.split(".") return f"{major}.{minor}.{int(patch) + 1}"What Skylos leaves alone
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 release1 committed file the change leaves alone
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
name: label pull requests Removed: on: pull_requestAdded: on: pull_request_target jobs: label: runs-on: ubuntu-latest steps: - uses: actions/labeler@v51 committed file the change leaves alone
def label_for(path): if path.startswith("docs/"): return "documentation" return "code"Not flagged
name: label pull requests Removed: on: pull_requestAdded: on: [pull_request, merge_group] jobs: label: runs-on: ubuntu-latest steps: - uses: actions/labeler@v51 committed file the change leaves alone
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
- Runs with
--ai-defectswhen there is a change to compare: in a diff scan (--diffor--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. - Looks only at
.ymland.yamlfiles under a.github/workflows/folder. - On each added line it looks for
permissions: write-all, awritegrant for a token scope such ascontents,packages,id-token,actions,pull-requestsorsecurity-events(block or inline{...}form), and apull_request_targetorworkflow_runtrigger in anon:value or list entry. Comments are stripped first. - A removed line with the same grant or trigger cancels the added one: for
on:and the top-levelpermissions: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. - 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.
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 releaseWhen it can be wrong
- A deliberate grant, such as
id-token: writefor 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 inaction.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.