Skip to main content

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

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

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

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

Dockerfile · DockerfileReported on line 6
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

Dockerfile · Dockerfile
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

  1. Reads the same commands as the other command rules: GitHub Actions run: steps, GitLab CI script items, Dockerfile RUN instructions, shell script 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 the command word of each part.
  3. npx (after sudo, nohup, time, command or NAME=value): reported with -y or --yes, or with any word ending in @latest.
  4. npm exec with -y or --yes; pnpm dlx and yarn dlx; and npm run, pnpm run or yarn followed by a script named bootstrap, install, postinstall, prepare or setup.
  5. 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.

.github/workflows/docs.yml · YAML · the fix, against the flagged file
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, because install is on the list of script names; npm install and pnpm install are not.
  • npx -y tool@1.4.2 is reported although the version is fixed, and npm run setup is reported whatever the script does.
  • Missed: npx tool without -y, which in CI also downloads because npx assumes yes when no terminal is attached; npm exec tool without -y; bunx, uvx and pipx run; and a command on a later line of a multi-line run: | 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 a run: | 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.

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