SKY-D374 · CI/CD pipelines
Publish workflow started by workflow_dispatch or any-branch push
A workflow that publishes a package can also be started in a way that lets the person starting it choose the code: workflow_dispatch runs any branch they pick, and a push trigger without a branch filter runs on every branch. The publish job has no condition that limits it to the release branch or the release event.
- Languages
- GitHub Actions workflows
- Quality gate
- Full scan: listed, not counted by the gate. Diff scan: counted toward the gate limits. A diff scan counts a finding whose rule and workflow file are not among the merge base's findings, so adding a second route to a workflow that was already reported is not new. A baseline scan counts it like a diff scan when the baseline's
rule_coveragelists it. - Finding type
- review
Why it matters
Anyone who can push a branch can then run the release job on their own code and publish it under your package name. The Nx compromise in 2025 and the @subql release in 2026 used routes like these.
What Skylos flags
name: Releaseon: workflow_dispatch: push: tags: ["v*"]permissions: contents: readjobs: publish: runs-on: ubuntu-latest steps: - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 with: persist-credentials: false - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 with: node-version: 22 registry-url: https://registry.npmjs.org - run: npm ci - run: npm publish --access public env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}What Skylos leaves alone
name: Releaseon: workflow_dispatch: push: tags: ["v*"]permissions: contents: readjobs: test: runs-on: ubuntu-latest steps: - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 with: persist-credentials: false - run: npm ci - run: npm test publish: needs: test if: github.event_name == 'push' runs-on: ubuntu-latest steps: - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 with: persist-credentials: false - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 with: node-version: 22 registry-url: https://registry.npmjs.org - run: npm ci - run: npm publish --access public env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}Why Skylos leaves it alone
workflow_dispatch is still there, so anyone with write access can re-run the tests on a branch they choose. The publish job's if: github.event_name == 'push' excludes that event, and the push trigger only fires for v* tags.
More languages
YAML
Flagged
name: Publish crateon: push: branches-ignore: [gh-pages]permissions: contents: readjobs: publish: runs-on: ubuntu-latest steps: - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 with: persist-credentials: false - run: cargo publish --locked env: CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}Not flagged
name: Publish crateon: push: branches-ignore: [gh-pages]permissions: contents: readjobs: publish: if: github.ref == 'refs/heads/main' runs-on: ubuntu-latest steps: - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 with: persist-credentials: false - run: cargo publish --locked env: CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}Why Skylos leaves it alone
The workflow still runs on a push to any branch, but the publish job only runs when the ref is exactly refs/heads/main.
How Skylos decides
- Runs with
--danger(and-a). Theca9library reads every*.ymland*.yamlfile directly in.github/workflowsand the local composite actions they call. GitLab CI is not checked: which variables a branch can read is a server setting. - Finds the jobs that publish: a publish command (
npm publish,twine upload,cargo publishand others), a publish action, or a publish credential such asNODE_AUTH_TOKENorCARGO_REGISTRY_TOKEN. - Lists the workflow's risky routes:
workflow_dispatch;pushwith no filter, onlybranches-ignore, or*/**branch patterns;pushto other wildcard patterns;repository_dispatch; andpull_request_target,issue_comment,issues,discussionanddiscussion_comment. A local reusable workflow inherits its callers' triggers.pushwith onlytags:or exact branch names is not a route. - Keeps a route open for a publish job unless the job's
if:(or the publish step'sif:) excludes the event (github.event_name == 'push',github.event_name != 'workflow_dispatch') or, for routes where the starter picks the ref, proves one branch (github.ref == 'refs/heads/main'). Tag checks such asstartsWith(github.ref, 'refs/tags/')andgithub.ref_namealone prove nothing. - Reports one finding per workflow, on the line of the first open route's trigger, graded by the routes and by whether each exposed job names a fixed
environment:.
How to fix it
Publish only from protected refs. Remove workflow_dispatch from the publish workflow, or guard the publish job with an event or branch condition, and run it in an environment whose deployment-branch rules or reviewers the registry can rely on.
name: Releaseon:Removed: workflow_dispatch: push: tags: ["v*"]permissions: contents: readjobs: publish: runs-on: ubuntu-latestAdded: environment: npm steps: - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 with: persist-credentials: false - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 with: node-version: 22 registry-url: https://registry.npmjs.org - run: npm ci - run: npm publish --access public env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}When it can be wrong
- A dispatch-started publish job with a tag check (
if: startsWith(github.ref, 'refs/tags/v')) is reported HIGH, because a tag check is not read as proof of a protected ref. - An environment lowers the finding to LOW but does not clear it, since YAML cannot show whether the environment has reviewers or branch rules.
- The flagged example also gets SKY-D340 for
npm publishand SKY-D364 for the stored npm token. They are separate findings.
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
Skylos reads no inline marker for this rule; a
# skylos: ignorecomment on the trigger does not hide it.Accept a reviewed workflow with a baseline:
skylos baseline ., then--baseline. The entry matches the rule and workflow file, not the line. In pull-request CI (SKYLOS_POLICY_BASE), the entry must also be in the base commit's.skylos/baseline.json.[tool.skylos] ignore = ["SKY-D374"]turns the rule off for the whole project.