SKY-D342 · Deployment and infrastructure
Dockerfile ADD downloads a file without a checksum
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 towardmax_highandmax_security; the detector never reports CRITICAL. - Finding type
- review
- Catalog name
- Dockerfile remote ADD without checksum
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
# 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
# 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
- Runs with
--danger. Reads files namedDockerfile,Dockerfile.*or*.dockerfile, outside.git,.venv,venv,node_modules,build,distand cache folders; files over 1 MB and symlinks are skipped. - Joins instruction lines that end in
\and looks at everyADD, in shell form or JSON (["src", "dest"]) form. - Skips options such as
--chownand--chmodwith their values. AnADDwith--checksum(with=or a space) is never reported. - Reports when any source (every word but the last) starts with
http://orhttps://. Sources built from variables, such as${PROBE_URL}/probe, are not resolved and are not reported. - Reports HIGH on the line where the
ADDinstruction 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.
# 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.0is reported like a file download, although a tag or commit in the URL already pins it. - It misses remote sources built from
ARGorENVvalues, and downloads done inRUN curlorRUN wgetwithout a checksum. - Any
--checksumvalue 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.