Skip to main content

SKY-D342 · Deployment and infrastructure

Dockerfile ADD downloads a file without a checksum

High

A Dockerfile ADD that fetches a file from an http:// or https:// URL without --checksum. Docker puts whatever the server returns into the image, and nothing checks that it is the file you expected.

Languages
Dockerfile
Quality gate
counted toward the gate limits (full and diff scans). Reported under security (danger). It counts toward max_high and max_security; the detector never reports CRITICAL.
Finding type
review
Catalog name
Dockerfile remote ADD without checksum
Wrong result? Report itA false positive, a missed case or a confusing message: it goes privately to the founder.

Why it matters

If the download server, the release or the network path is compromised, every image you build afterwards ships the attacker's binary, often as a tool that runs inside production containers.

What Skylos flags

Dockerfile · DockerfileReported on line 5
# syntax=docker/dockerfile:1FROM python:3.12-slim WORKDIR /appADD https://downloads.example.com/grpc-health-probe/v0.4.28/probe-linux-amd64 \    /usr/local/bin/grpc_health_probeRUN chmod +x /usr/local/bin/grpc_health_probe COPY requirements.txt .RUN pip install --no-cache-dir -r requirements.txtCOPY . .CMD ["python", "-m", "app"]

What Skylos leaves alone

Dockerfile · Dockerfile
# syntax=docker/dockerfile:1FROM python:3.12-slim WORKDIR /appADD vendor/grpc_health_probe /usr/local/bin/grpc_health_probeRUN chmod +x /usr/local/bin/grpc_health_probe COPY requirements.txt .RUN pip install --no-cache-dir -r requirements.txtCOPY . .CMD ["python", "-m", "app"]

Why Skylos leaves it alone

ADD is still used, but it copies a file from the build context, which is reviewed with the rest of the repository. Only http:// and https:// sources are downloads.

How Skylos decides

  1. Runs with --danger. Reads files named Dockerfile, Dockerfile.* or *.dockerfile, outside .git, .venv, venv, node_modules, build, dist and cache folders; files over 1 MB and symlinks are skipped.
  2. Joins instruction lines that end in \ and looks at every ADD, in shell form or JSON (["src", "dest"]) form.
  3. Skips options such as --chown and --chmod with their values. An ADD with --checksum (with = or a space) is never reported.
  4. Reports when any source (every word but the last) starts with http:// or https://. Sources built from variables, such as ${PROBE_URL}/probe, are not resolved and are not reported.
  5. Reports HIGH on the line where the ADD instruction starts.

How to fix it

Add --checksum=sha256:<digest> with the digest the project publishes for that release. BuildKit then refuses to build when the download does not match. --checksum needs Dockerfile syntax 1.6 or newer, which the # syntax=docker/dockerfile:1 line selects.

Dockerfile · Dockerfile · the fix, against the flagged file
# syntax=docker/dockerfile:1FROM python:3.12-slim WORKDIR /appRemoved: ADD https://downloads.example.com/grpc-health-probe/v0.4.28/probe-linux-amd64 \Added: ADD --checksum=sha256:9e3fa4a1b0c2d8e7f6a5b4c3d2e1f0a9b8c7d6e5f4a3b2c1d0e9f8a7b6c5d4e3 \Added:     https://downloads.example.com/grpc-health-probe/v0.4.28/probe-linux-amd64 \    /usr/local/bin/grpc_health_probeRUN chmod +x /usr/local/bin/grpc_health_probe COPY requirements.txt .RUN pip install --no-cache-dir -r requirements.txtCOPY . .CMD ["python", "-m", "app"]

When it can be wrong

  • A Git source such as ADD https://github.com/acme/tools.git#v1.2.0 is reported like a file download, although a tag or commit in the URL already pins it.
  • It misses remote sources built from ARG or ENV values, and downloads done in RUN curl or RUN wget without a checksum.
  • Any --checksum value silences it; Skylos does not check that the digest is well formed.

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 the marker on a comment line directly above the ADD. Docker reads # as a comment only at the start of a line; after an instruction it becomes part of the arguments.

    Dockerfile
    # skylos: ignore[SKY-D342] mirror serves signed, immutable releasesADD https://downloads.example.com/probe/v0.4.28/probe /usr/local/bin/probe
  • [tool.skylos] ignore = ["SKY-D342"] turns the rule off for the project.

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