Skip to main content

SKY-D340 · Security in code

Package or image published outside a release

High

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
Wrong result? Report itA false positive, a missed case or a confusing message: it goes privately to the founder.

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

.github/workflows/ci.yml · YAMLReported on line 20
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

.github/workflows/ci.yml · YAML
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 public

Why 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

scripts/release.sh · ShellReported on line 5
#!/usr/bin/env bashset -euo pipefailrm -rf distpython -m buildtwine upload dist/*

Not flagged

scripts/release.sh · Shell
#!/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

  1. Reads shell commands in GitHub Actions run: steps, GitLab CI script items, Dockerfile RUN instructions, .sh, .bash, .zsh, .ksh and .bats files, fixed command strings in Python os.system()-style or shell=True calls, and fixed strings passed to child_process.exec() in TypeScript and JavaScript.
  2. Splits each command at ;, &&, || and |, not at line breaks, and looks at how each part starts.
  3. Reports a part that starts with npm publish, pnpm publish, yarn npm publish, cargo publish, maturin publish, twine upload, gem push, helm push or docker push, unless the last dry-run setting asks for a dry run.
  4. In a GitHub Actions workflow it skips the step when the workflow's only trigger is release (with no other options than known activity types), or when the step's or job's if: can only be true for github.event_name == 'release'.
  5. 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.

.github/workflows/release.yml · YAML
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 the release event counts as release intent. So is a publish in a workflow that also runs on other events, unless its step or job if: 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 after sudo, env or a NAME=value prefix, uv publish, poetry publish, gh release upload and publishing actions such as pypa/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 public
  • A marker inside a quoted value, such as a step name: or the run: 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.

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