SKY-D340 · Security in code
Package or image published outside a release
Commands such as npm publish, twine upload, cargo publish and docker push put a new version where your users install it from. SKY-D340 reports such a command wherever it is written, unless a GitHub Actions workflow shows that it only runs for a published GitHub release.
- Languages
- GitHub Actions workflows, GitLab CI, Shell, Dockerfile, Python, TypeScript/JavaScript
- Quality gate
- counted toward the gate limits (full and diff scans)
- Finding type
- review
- Catalog name
- Unapproved package or artifact publish
Why it matters
A publish step in an ordinary CI job ships whatever reached the branch, with no person deciding that this is a release. A bad merge, or anyone who can push to that branch or change the workflow, puts code on every machine that installs the next version, using your registry token.
What Skylos flags
name: CIon: push: branches: [main]permissions: contents: readjobs: test-and-publish: runs-on: ubuntu-latest steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 with: persist-credentials: false - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 with: node-version: 22 registry-url: https://registry.npmjs.org - run: npm ci --ignore-scripts - run: npm test - run: npm publish --access public env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}What Skylos leaves alone
name: CIon: push: branches: [main]permissions: contents: readjobs: test-and-publish: runs-on: ubuntu-latest steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 with: persist-credentials: false - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 with: node-version: 22 registry-url: https://registry.npmjs.org - run: npm ci --ignore-scripts - run: npm test - run: npm publish --dry-run --access publicWhy Skylos leaves it alone
npm publish --dry-run packs the package and prints what would be uploaded, without uploading anything. Skylos reads the last dry-run setting before --, so --dry-run false or --no-dry-run would still be reported.
More languages
Shell
Flagged
#!/usr/bin/env bashset -euo pipefailrm -rf distpython -m buildtwine upload dist/*Not flagged
#!/usr/bin/env bashset -euo pipefailrm -rf distpython -m buildtwine check --strict dist/*Why Skylos leaves it alone
twine check only validates the built files on this machine. Shell scripts get no release exception: any twine upload in a script is reported, because Skylos cannot tell who runs the script.
How Skylos decides
- Reads shell commands in GitHub Actions
run:steps, GitLab CI script items, DockerfileRUNinstructions,.sh,.bash,.zsh,.kshand.batsfiles, fixed command strings in Pythonos.system()-style orshell=Truecalls, and fixed strings passed tochild_process.exec()in TypeScript and JavaScript. - Splits each command at
;,&&,||and|, not at line breaks, and looks at how each part starts. - Reports a part that starts with
npm publish,pnpm publish,yarn npm publish,cargo publish,maturin publish,twine upload,gem push,helm pushordocker push, unless the last dry-run setting asks for a dry run. - In a GitHub Actions workflow it skips the step when the workflow's only trigger is
release(with no other options than known activitytypes), or when the step's or job'sif:can only be true forgithub.event_name == 'release'. - One HIGH finding per step, on its
run:line in GitHub Actions and on the command's line elsewhere.
How to fix it
Remove the publish step from the CI workflow and publish from a workflow that only a published GitHub release starts. Give its job an environment with required reviewers, so a person approves each upload.
name: Releaseon: release: types: [published]permissions: contents: readjobs: publish: runs-on: ubuntu-latest environment: npm steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 with: persist-credentials: false - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 with: node-version: 22 registry-url: https://registry.npmjs.org - run: npm ci --ignore-scripts - run: npm publish --access public env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}When it can be wrong
- A publish on a tag push (
push: tags: ['v*']), a common and reviewed release setup, is reported: only thereleaseevent counts as release intent. So is a publish in a workflow that also runs on other events, unless its step or jobif:requires the release event. - Missed: a publish command on a later line of a multi-line
run: |block (only the first line of each;/&&part is read), publishes aftersudo,envor aNAME=valueprefix,uv publish,poetry publish,gh release uploadand publishing actions such aspypa/gh-action-pypi-publish. - The flagged example and the fix also get SKY-D364 for the long-lived
NPM_TOKEN, a separate finding: npm offers trusted publishing, which needs no stored token.
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
In a workflow the marker must be a real YAML comment: at the end of the
run:line or on its own line directly above it, one rule per marker. In other files it goes on the reported line.YAML # skylos: ignore[SKY-D340] main is protected and every merge is a release- run: npm publish --access publicA marker inside a quoted value, such as a step
name:or therun:text itself, is not a comment and does not silence the finding.[tool.skylos] ignore = ["SKY-D340"]turns the rule off for the whole project.