# syntax=docker/dockerfile:1 # # unbound-sec: security-hardened Unbound Docker image (crazymax/unbound replacement) # # Security deltas vs. crazymax/unbound: # - Unbound 1.26.2 (security release; fixes CVE-2026-97206, CVE-2026-96405, # CVE-2026-109125, CVE-2026-50106, CVE-2026-35501) # - no dns-root-hints package -> no curl/nghttp2/zlib/c-ares/brotli in runtime # (fixes CVE-2026-58055, CVE-2026-85091; unbound has root servers built in) # - current Alpine 3.24 expat 2.9.0 (fixes CVE-2026-77214, CVE-2026-93990, # CVE-2026-102633) # - shadow package removed after user creation -> no SUID-root binaries # - hide-identity / hide-version enabled (no version leak via CHAOS queries) # # Improvements adopted from the 10/2026 comparison with other unbound images # (mvance/unbound, klutchell/unbound, madnuttah/unbound — see README): # - source tarballs: SHA256 check + GPG signature (NLnet Labs release key G2) # - base images pinned by digest (reproducible builds) # - binary hardening: --enable-pie --enable-relro-now # - features: --enable-subnet (EDNS Client Subnet), TFO server + client ARG UNBOUND_VERSION=1.26.2 ARG UNBOUND_SHA256=d8ee7aa6bbb3ff1be7d9e57637d0d0ec2f18273a8efff1a0afe2c665858b96f7 ARG LDNS_VERSION=1.9.2 ARG LDNS_SHA256=b524fa21994b6e834200ceb8c27f1b84bda5982fe35706f058196c079db94d5d ARG XX_VERSION=1.9.0 ARG XX_DIGEST=sha256:c64defb9ed5a91eacb37f96ccc3d4cd72521c4bd18d5442905b95e2226b0e707 ARG ALPINE_VERSION=3.24 ARG ALPINE_DIGEST=sha256:71e9b7bae160ba167fa17414401b94cbcdaf3c32feeab9298bd794a2a0614c35 FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION}@${XX_DIGEST} AS xx FROM --platform=$BUILDPLATFORM alpine:${ALPINE_VERSION}@${ALPINE_DIGEST} AS base COPY --from=xx / / RUN apk --update --no-cache add binutils clang curl file gnupg make pkgconf tar tree xz FROM base AS base-build ENV XX_CC_PREFER_LINKER=ld ARG TARGETPLATFORM RUN xx-apk --no-cache add gcc g++ expat-dev hiredis hiredis-dev libevent-dev libcap libpcap-dev openssl-dev perl \ && xx-clang --setup-target-triple FROM base AS unbound-src WORKDIR /src/unbound ARG UNBOUND_VERSION ARG UNBOUND_SHA256 # CACHEBUST: test suite passes a timestamp so integrity verification (SHA256 + # GPG) re-runs on every test run even when the build stages are cached. ARG CACHEBUST RUN set -eux \ && echo "cachebust=$CACHEBUST" \ && curl -sSL "https://unbound.net/downloads/unbound-${UNBOUND_VERSION}.tar.gz" -o unbound.tar.gz \ && curl -sSL "https://unbound.net/downloads/unbound-${UNBOUND_VERSION}.tar.gz.asc" -o unbound.tar.gz.asc \ && echo "${UNBOUND_SHA256} unbound.tar.gz" | sha256sum -c - \ && export GNUPGHOME="$(mktemp -d)" \ && curl -sSL "https://nlnetlabs.nl/downloads/keys/releases-g2.asc" -o "$GNUPGHOME/releases-g2.asc" \ && gpg --no-tty --import "$GNUPGHOME/releases-g2.asc" \ && gpg --batch --verify unbound.tar.gz.asc unbound.tar.gz \ && tar xzf unbound.tar.gz --strip 1 FROM base AS ldns-src WORKDIR /src/ldns ARG LDNS_VERSION ARG LDNS_SHA256 ARG CACHEBUST RUN set -eux \ && echo "cachebust=$CACHEBUST" \ && curl -sSL "https://nlnetlabs.nl/downloads/ldns/ldns-${LDNS_VERSION}.tar.gz" -o ldns.tar.gz \ && curl -sSL "https://nlnetlabs.nl/downloads/ldns/ldns-${LDNS_VERSION}.tar.gz.asc" -o ldns.tar.gz.asc \ && echo "${LDNS_SHA256} ldns.tar.gz" | sha256sum -c - \ && export GNUPGHOME="$(mktemp -d)" \ && curl -sSL "https://nlnetlabs.nl/downloads/keys/releases-g2.asc" -o "$GNUPGHOME/releases-g2.asc" \ && gpg --no-tty --import "$GNUPGHOME/releases-g2.asc" \ && gpg --batch --verify ldns.tar.gz.asc ldns.tar.gz \ && tar xzf ldns.tar.gz --strip 1 FROM base-build AS unbound-build WORKDIR /src/unbound RUN --mount=type=bind,from=unbound-src,source=/src/unbound,target=.,rw <