Skip to content
shiporbreak

No streak yet

Sign in

November 11, 2026 路 #56

DockerfileMediumOpen write-up

ADD from the internet

The image installs kubectl. Which line lets a changed or tampered download into production with no error?

FROM alpine:3.20
ADD https://dl.k8s.io/release/stable/bin/linux/amd64/kubectl /usr/local/bin/kubectl
RUN chmod +x /usr/local/bin/kubectl
USER 65534
ENTRYPOINT ["kubectl"]

Next puzzle in UTC

One try. The first answer sticks.

How to fix it

The URL tracks the latest stable release and nothing checks the file. Pin the version and verify a checksum, which ADD supports with --checksum.

stable points to a different kubectl every few weeks, so two builds of the same Dockerfile produce different images. Nothing in the build checks what was downloaded. A compromised mirror, a hijacked DNS record, or a proxy injecting content would pass silently. kubectl is a static Go binary, so musl is not a problem here.

Fix

# syntax=docker/dockerfile:1
FROM alpine:3.20
ARG KUBECTL_VERSION=v1.31.2
ARG KUBECTL_SHA256=<sha256 from dl.k8s.io/release/v1.31.2/bin/linux/amd64/kubectl.sha256>
ADD --checksum=sha256:${KUBECTL_SHA256} --chmod=755 \
  https://dl.k8s.io/release/${KUBECTL_VERSION}/bin/linux/amd64/kubectl /usr/local/bin/kubectl

The build fails if the bytes change. Bump the version and checksum together in a reviewed pull request.

Sponsor this spot

Put your tool on the puzzle
One labeled card, in front of engineers who show up every day from YouTube, TikTok, and Instagram.