SKY-D341 · Security in code
Tool downloaded from the registry and run unpinned
npx -y tool, pnpm dlx tool and yarn dlx tool download a package from the npm registry and run it straight away, at whatever version is newest that moment. SKY-D341 reports these commands, and package scripts named like install steps, because the code they run is not pinned anywhere.
- 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
- Untrusted package-managed tool execution
Why it matters
If the tool's maintainer account is taken over, the next run of your job executes the attacker's release, with the job's token and secrets. Hijacked npm releases have reached many projects within hours, through installs that always take the newest version.
What Skylos flags
name: Docson: pull_request: paths: ["docs/**"]permissions: contents: readjobs: lint: runs-on: ubuntu-latest steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 with: persist-credentials: false - run: npx -y markdownlint-cli2 "docs/**/*.md"What Skylos leaves alone
name: Docson: pull_request: paths: ["docs/**"]permissions: contents: readjobs: lint: runs-on: ubuntu-latest steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 with: persist-credentials: false - run: npm ci --ignore-scripts - run: npx --no markdownlint-cli2 "docs/**/*.md"Why Skylos leaves it alone
It is still npx, but --no tells it never to download. It runs the copy that npm ci installed from package-lock.json, where the tool and every package it needs have a fixed version and hash.
More languages
Dockerfile
Flagged
FROM node:22-slimWORKDIR /appCOPY package.json pnpm-lock.yaml ./RUN corepack enable && pnpm install --frozen-lockfileCOPY . .RUN pnpm dlx prisma generateCMD ["node", "dist/server.js"]Not flagged
FROM node:22-slimWORKDIR /appCOPY package.json pnpm-lock.yaml ./RUN corepack enable && pnpm install --frozen-lockfileCOPY . .RUN pnpm exec prisma generateCMD ["node", "dist/server.js"]Why Skylos leaves it alone
pnpm exec runs the prisma that pnpm install took from the lockfile. pnpm dlx would fetch the newest release instead.
How Skylos decides
- Reads the same commands as the other command rules: GitHub Actions
run:steps, GitLab CI script items, DockerfileRUNinstructions, shell script files, 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 the command word of each part. npx(aftersudo,nohup,time,commandorNAME=value): reported with-yor--yes, or with any word ending in@latest.npm execwith-yor--yes;pnpm dlxandyarn dlx; andnpm run,pnpm runoryarnfollowed by a script namedbootstrap,install,postinstall,prepareorsetup.- One HIGH finding per command block: in a workflow on the first line of the
run:text, elsewhere on the command's line.
How to fix it
Add the tool as an exact development dependency (npm install --save-dev --save-exact markdownlint-cli2), commit the lockfile, install with npm ci and run it with npx --no, npm exec or a package.json script. Updates then arrive as reviewed lockfile changes.
name: Docson: pull_request: paths: ["docs/**"]permissions: contents: readjobs: lint: runs-on: ubuntu-latest steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 with: persist-credentials: falseRemoved: - run: npx -y markdownlint-cli2 "docs/**/*.md"Added: - run: npm ci --ignore-scriptsAdded: - run: npx --no markdownlint-cli2 "docs/**/*.md"When it can be wrong
yarn install, Yarn's normal dependency install, is reported, becauseinstallis on the list of script names;npm installandpnpm installare not.npx -y tool@1.4.2is reported although the version is fixed, andnpm run setupis reported whatever the script does.- Missed:
npx toolwithout-y, which in CI also downloads because npx assumes yes when no terminal is attached;npm exec toolwithout-y;bunx,uvxandpipx run; and a command on a later line of a multi-linerun: |block.
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
For a one-line
run:the marker must be a YAML comment at the end of the line or on its own line directly above it. In arun: |block, and in other files, put it on the reported line or the line above, one rule per marker.YAML # skylos: ignore[SKY-D341] scaffold only, output is reviewed in the PR- run: npx -y create-vite@5.5.2 demo --template react-ts[tool.skylos] ignore = ["SKY-D341"]turns the rule off for the whole project.