SKY-D306 · CI/CD pipelines
Insecure workflow commands turned back on
GitHub Actions once let any line printed by a step, such as ::set-env name=X::value or ::add-path::dir, change the job's environment. GitHub disabled these commands in 2020 because printed text is easy to influence. ACTIONS_ALLOW_UNSECURE_COMMANDS: true turns them back on, and SKY-D306 reports it.
- Languages
- GitHub Actions workflows, composite actions
- Quality gate
- counted toward the gate limits (full and diff scans)
- Finding type
- review
- Catalog name
- GitHub Actions insecure commands enabled
Why it matters
With the commands on, anything a step prints can set variables or PATH for later steps: a test name, a log line from a dependency, or the title of an issue echoed to the log. One crafted line, such as one setting NODE_OPTIONS, is enough to run code in the next step with the job's token.
What Skylos flags
name: Linton: [push, pull_request]permissions: contents: readenv: # acme/setup-linter v1 still prints ::add-path:: ACTIONS_ALLOW_UNSECURE_COMMANDS: truejobs: lint: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: persist-credentials: false - uses: acme/setup-linter@v1.2.0 - run: acme-lint .What Skylos leaves alone
name: Linton: [push, pull_request]permissions: contents: readenv: # acme/setup-linter v1 still runs on Node 16 ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: truejobs: lint: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: persist-credentials: false - uses: acme/setup-linter@v1.2.0 - run: acme-lint .Why Skylos leaves it alone
This variable only lets an action written for an old Node.js version run. It does not turn the workflow commands back on, and the rule reads nothing but ACTIONS_ALLOW_UNSECURE_COMMANDS.
How Skylos decides
- Reads the top-level
env:of a file, and in workflows every job's and step'senv:; in composite actions, each step'senv:. - Reports
ACTIONS_ALLOW_UNSECURE_COMMANDSset to true:true,yes,onor1, quoted or not.false, an expression such as${{ vars.LEGACY }}, and any other value are not reported. - One HIGH finding per file, on the first line that contains
ACTIONS_ALLOW_UNSECURE_COMMANDS.
How to fix it
Remove the variable and upgrade the action that still prints the old commands. Current actions write to $GITHUB_ENV and $GITHUB_PATH instead.
name: Linton: [push, pull_request]permissions: contents: readRemoved: env:Removed: # acme/setup-linter v1 still prints ::add-path::Removed: ACTIONS_ALLOW_UNSECURE_COMMANDS: truejobs: lint: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: persist-credentials: falseRemoved: - uses: acme/setup-linter@v1.2.0Added: - uses: acme/setup-linter@v2.0.1 - run: acme-lint .When it can be wrong
- Several jobs or steps that set the variable give one finding, on the first line that names it, even when that line is a comment.
- The examples also get SKY-D292 for actions referenced by a version tag instead of a commit SHA.
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-D306]on the reported line or on the line directly above it, one rule per marker.YAML # skylos: ignore[SKY-D306] removed once setup-linter v2 is outACTIONS_ALLOW_UNSECURE_COMMANDS: true[tool.skylos] ignore = ["SKY-D306"]turns the rule off for the whole project.A baseline works, but it records the absolute file path and the line, so it stops matching when the checkout moves or lines above shift.