Skip to main content

SKY-D337 · Security in code

Package registry or index override

Package installers fetch from a default registry (PyPI, npmjs.org, RubyGems) unless a command points them elsewhere. SKY-D337 reports an install or config command that adds or replaces the registry, so a person can check who runs that registry.

Languages
Dockerfile, Shell, GitHub Actions, GitLab CI, Python, TypeScript/JavaScript
Quality gate
counted toward the gate limits (full and diff scans)
Finding type
review
Wrong result? Report itA false positive, a missed case or a confusing message: it goes privately to the founder.

Why it matters

With pip install --extra-index-url, pip takes the highest version of a name from either index. If your internal package acme-billing is not also reserved on PyPI, anyone can publish acme-billing 99.0 there and your next build installs and runs it (dependency confusion).

What Skylos flags

Dockerfile · DockerfileReported on line 4
FROM python:3.12-slimWORKDIR /appCOPY requirements.txt .RUN pip install --no-cache-dir \      --extra-index-url https://pypi.acme-internal.example/simple \      -r requirements.txtCOPY . .CMD ["python", "-m", "acme_billing"]

What Skylos leaves alone

Dockerfile · Dockerfile
FROM python:3.12-slimWORKDIR /appCOPY requirements.txt .COPY wheels/ /wheels/RUN pip install --no-cache-dir --no-index --find-links /wheels \      -r requirements.txtCOPY . .CMD ["python", "-m", "acme_billing"]

Why Skylos leaves it alone

--no-index turns every package index off, and --find-links /wheels installs only wheels already copied into the image, so no outside index is involved. Skylos looks only for --index-url and --extra-index-url on pip.

More languages

Shell

Flagged

scripts/install-ui.sh · ShellReported on line 3
#!/usr/bin/env bashset -euo pipefailnpm install --registry https://npm.acme-internal.example/ @acme/ui

Not flagged

scripts/install-ui.sh · Shell
#!/usr/bin/env bashset -euo pipefailnpm install @acme/ui
.npmrc · Text
@acme:registry=https://npm.acme-internal.example/

Why Skylos leaves it alone

The project's .npmrc sends only the @acme scope to the internal registry; everything else still comes from npmjs.org, so a public package cannot take an internal name's place. Skylos reads commands, not .npmrc files, and this command names no registry.

How Skylos decides

  1. Reads shell commands in .sh, .bash, .zsh, .ksh and .bats files, GitHub Actions run: steps, GitLab CI script items, Dockerfile RUN instructions (continuation lines joined), fixed command strings in Python os.system()-style calls or shell=True calls, and fixed strings passed to child_process.exec() in TypeScript and JavaScript.
  2. Splits each command at ;, &&, || and |, and looks at the command word of each part (after sudo, nohup, time, command and VAR=value prefixes).
  3. pip, pip3, python -m pip and python3 -m pip: reports an argument that starts with --index-url or --extra-index-url.
  4. npm, pnpm and yarn: reports an argument that is the word registry (any case), as in npm config set registry …, or that starts with --registry. gem: reports an argument that starts with --source.
  5. There is no allowlist: an internal registry is reported the same as an unknown one, and every finding is HIGH. Registry settings in files (pip.conf, .npmrc, PIP_INDEX_URL) are not read.

How to fix it

Install from one index. Mirror your internal packages and their public dependencies behind a single --index-url you own, or scope npm packages with @scope:registry= in .npmrc, and reserve your internal names on the public registry. A reviewed single private index is still reported, so mark it with a reason.

Dockerfile · Dockerfile · the fix, against the flagged file
FROM python:3.12-slimWORKDIR /appCOPY requirements.txt .Added: # skylos: ignore[SKY-D337] single proxy index, owned by platform teamRUN pip install --no-cache-dir \Removed:       --extra-index-url https://pypi.acme-internal.example/simple \Removed:       -r requirements.txtAdded:       --index-url https://pypi.acme-internal.example/simple \Added:       --require-hashes -r requirements.txtCOPY . .CMD ["python", "-m", "acme_billing"]

When it can be wrong

  • A single --index-url pointing at a proxy you own is reported the same as --extra-index-url, although only the extra index mixes two sources.
  • Read-only commands that contain the word registry, such as npm config get registry, are reported.
  • Missed: pip install -i URL, --find-links URL, uv pip install --extra-index-url, registries set in pip.conf, .npmrc or environment variables; and in a GitHub Actions run: | block, or a multi-line GitLab item, an install on a later line, because the block is split only at ;, &&, || and |, not at line breaks.

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 Dockerfile the marker goes on the first line of the RUN instruction or on the line directly above it, one rule per marker. In a shell script it must be a comment on the reported line.

    Dockerfile
    # skylos: ignore[SKY-D337] single proxy index, owned by platform teamRUN pip install --index-url https://pypi.acme-internal.example/simple -r req.txt
  • [tool.skylos] ignore = ["SKY-D337"] turns the rule off for the whole project.

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