SKY-D312 · CI/CD pipelines
JavaScript install runs dependency scripts in CI
npm ci, npm install, yarn install, pnpm install and bun install can run each dependency's lifecycle scripts, such as postinstall, while installing. SKY-D312 reports such an install in a workflow run: block that does not pass --ignore-scripts.
- Languages
- GitHub Actions workflows, composite actions
- Quality gate
- counted toward the gate limits (full and diff scans)
- Finding type
- review
- Catalog name
- GitHub Actions JavaScript install scripts
Why it matters
A compromised dependency's postinstall script runs inside the job, where it can read the job's token, secrets and OIDC token. Several npm attacks stole publish tokens from CI exactly this way, then used them to release infected versions of other packages.
What Skylos flags
name: Releaseon: push: tags: ["v*"]permissions: contents: readjobs: publish: name: Publish to npm runs-on: ubuntu-latest timeout-minutes: 15 environment: npm permissions: contents: read id-token: write steps: - uses: actions/checkout@v4 with: persist-credentials: false - uses: actions/setup-node@v4 with: node-version: 22 registry-url: https://registry.npmjs.org - run: npm ci - run: npm run build - run: npm publish --provenance --access publicWhat Skylos leaves alone
name: Releaseon: push: tags: ["v*"]permissions: contents: readjobs: publish: name: Publish to npm runs-on: ubuntu-latest timeout-minutes: 15 environment: npm permissions: contents: read id-token: write steps: - uses: actions/checkout@v4 with: persist-credentials: false - uses: actions/setup-node@v4 with: node-version: 22 registry-url: https://registry.npmjs.org - run: | npm ci --ignore-scripts npm rebuild esbuild - run: npm run build - run: npm publish --provenance --access publicWhy Skylos leaves it alone
Install scripts are off, and the one dependency that needs its build step is rebuilt by name. npm run build runs the project's own script from package.json, which is reviewed with the repository; the rule only looks at installs.
How Skylos decides
- Reads workflow files under
.github/workflowsand composite actions (action.yml,action.yaml). Everyrun:block is checked, in any job, whatever its trigger or permissions. - Reports a line that starts (after spaces) with
npm,pnpm,yarnorbunfollowed byciorinstall, unless--ignore-scriptsappears later on that same line. - Takes only the first match in each
run:block. Reports MEDIUM on the first line of the file that contains the matched text, such asnpm ci; blocks whose match has the same text give one finding there.
How to fix it
Install with --ignore-scripts. If a dependency really needs its install step (a native module, esbuild), run npm rebuild <name> for that package only, after reviewing it.
name: Releaseon: push: tags: ["v*"]permissions: contents: readjobs: publish: name: Publish to npm runs-on: ubuntu-latest timeout-minutes: 15 environment: npm permissions: contents: read id-token: write steps: - uses: actions/checkout@v4 with: persist-credentials: false - uses: actions/setup-node@v4 with: node-version: 22 registry-url: https://registry.npmjs.orgRemoved: - run: npm ciAdded: - run: npm ci --ignore-scripts - run: npm run build - run: npm publish --provenance --access publicWhen it can be wrong
- Only the command line is read.
ignore-scripts=truein.npmrcornpm config set ignore-scripts trueis not seen, and Bun, or pnpm from version 10, which skip dependency scripts unless the project trusts the package, are still reported. --ignore-scriptsanywhere later on the line, even in a#comment, clears it. Installs that do not start the line (cd web && npm ci),npm iand a bareyarnare missed.- Location: the finding goes to the first line containing the same text, so after an earlier
npm ci --ignore-scriptsa later plainnpm ciis reported on the earlier, safe line.
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-D312] <reason>on the reported line or on the line directly above it, one rule per marker. In a multi-linerun:block the marker can be a shell comment.YAML run: | # skylos: ignore[SKY-D312] test job, no secrets or write token npm ci[tool.skylos] ignore = ["SKY-D312"]turns the rule off for the whole project. A baseline also works, but it records the absolute file path and line, so it stops matching when the checkout moves or lines above the finding change.