|
|
před 1 měsícem | |
|---|---|---|
| conf.d | před 1 měsícem | |
| config | před 1 měsícem | |
| docs | před 1 měsícem | |
| test | před 1 měsícem | |
| .dockerignore | před 1 měsícem | |
| .gitignore | před 1 měsícem | |
| CHANGELOG.md | před 1 měsícem | |
| Dockerfile | před 1 měsícem | |
| README.md | před 1 měsícem | |
| build.sh | před 1 měsícem | |
| docker-compose.yml | před 1 měsícem | |
| entrypoint.sh | před 1 měsícem |
Security-hardened Docker image for Unbound (validating,
recursive, caching DNS resolver). Direct drop-in replacement for
crazymax/unbound — same port, same /config drop-in mechanism, same
healthcheck — with the security findings from the 10/2026 audit of
crazymax/unbound:latest fixed.
Full reference of all deviations from vanilla Unbound 1.26.2 (build flags, config defaults, packaging): docs/vanilla-deviations.md.
Audit results for crazymax/unbound:latest (Unbound 1.26.1, Alpine 3.24.1,
built 2026-09-17):
| Finding | Severity | Fix in this project |
|---|---|---|
| Unbound 1.26.1 behind security release 1.26.2 (CVE-2026-96405 Medium DoS, CVE-2026-109125 Medium, CVE-2026-50106 Medium, CVE-2026-35501 Low, CVE-2026-97206 High) | Med/High | Build Unbound 1.26.2 (CVE-2026-97206 not reachable anyway: DoQ not compiled) |
| expat 2.8.4: CVE-2026-77214, CVE-2026-93990 (High), CVE-2026-102633 (Medium) | High | Current Alpine 3.24 expat 2.9.0 |
| nghttp2 1.69.0: CVE-2026-58055 (Medium) | Medium | curl-stack removed (see below) |
| zlib 1.3.2: CVE-2026-85091 (Medium) | Medium | zlib gone with curl-stack |
| No cosign signatures on image | Info | build.sh signs with cosign (keyless, GitHub OIDC) |
| SUID-root binaries (shadow package: passwd, chsh, chfn, chage, expiry, gpasswd) | Low | shadow removed after user creation — no SUID binaries |
| NoNewPrivs not set, writable root fs | Low | compose template: no-new-privileges, read_only + tmpfs |
| Identity/version leak via CHAOS queries | Info | hide-identity, hide-version |
Key attack-surface reduction: the dns-root-hints package (used by no one in
this image — Unbound has root servers built in) pulls in curl, nghttp2, zlib,
c-ares, brotli and friends. It is dropped, so the runtime image carries none
of that stack.
Docker Hub query + source analysis of the most relevant alternatives
(2026-10-23): mvance/unbound (22.9M pulls), klutchell/unbound
(12.8M), sapcc/unbound (5.8M), mailcow/unbound (25.5M),
madnuttah/unbound (distroless, security-focused),
alpinelinux/unbound (official Alpine package image).
| Aspect | unbound-sec | mvance | klutchell | madnuttah |
|---|---|---|---|---|
| Unbound version | 1.26.2 | 1.21.1 (2024-10) | 1.26.2 | 1.26.x |
| Base | Alpine 3.24, digest-pinned | Debian bookworm | Alpine 3.24.2, digest-pinned | distroless (FROM scratch) |
| Tarball SHA256 + GPG | yes | SHA256 only | SHA256 only | SHA256 + GPG |
| Base image digest pin | yes | no | yes | no (own buildenv image) |
| Non-root, no SUID | yes | yes | yes | yes |
| EDNS Client Subnet | yes | yes | yes | yes |
| TFO | yes | yes | yes | yes |
| DNSCrypt (libsodium) | no | no | yes | yes |
| DoH (nghttp2) | no | yes | yes | yes |
| DNSTAP (protobuf-c) | no | yes | no | yes |
| cachedb (hiredis) | yes | no | yes | yes |
| Binary PIE + RELRO-now | yes | no | no | yes |
| Port | 5053 (crazymax-compat) | 53 | 53 | 53 |
Adopted (no runtime-dependency cost, all test-covered):
--enable-pie --enable-relro-now (explicit binary hardening)--enable-subnet (EDNS Client Subnet — multi-WAN/split-horizon capable)--enable-tfo-server --enable-tfo-client (TCP Fast Open)Deliberately NOT adopted (surface-area trade-offs against this project's minimal-runtime goal):
FROM scratch final stage (klutchell/madnuttah) → manual .so copying,
no apk-based updates; our Alpine final stage already has 12 packagesFeatures adopted above were taken as ideas from the following projects; no code was copied verbatim (our Dockerfile, config, entrypoint and tests are written from scratch). Ideas are not copyright-protected, so no attribution is legally required — the list below documents provenance. All referenced projects use permissive licenses, which would additionally allow code reuse.
| Project | License | What we learned from it |
|---|---|---|
| crazymax/unbound | MIT | port 5053 / /config drop-in contract, xx cross-compile layout (the image we replace) |
| mvance/unbound | MIT | tarball SHA256 pinning, feature set (ECS, TFO) |
| klutchell/unbound | BSD-3-Clause | digest pinning of base images, SHA256 verification in Dockerfile |
| madnuttah/unbound | MIT | GPG verification of tarballs (NLnet Labs key), --enable-pie --enable-relro-now |
Upstream (built, not referenced): Unbound and ldns — BSD-3-Clause.
2310…DF45 pinned in the Dockerfile) for both tarballs; base images
pinned by digest. Note: APK packages come from the mutable Alpine
repository, so builds are reproducible w.r.t. sources and base images,
not w.r.t. the exact package set at build timedrill (used by the healthcheck)unbound (uid/gid 1500), zero effective capabilitiesdnssec-root package,
auto-trust-anchor-file in persistent /var/unbound (RFC5011 state —
learned keys, rollover — survives restarts)tls-cert-bundle set)drill -p 5053 unbound.net @127.0.0.1*.conf include) —
identical to crazymax/unbound./build.sh # build + cosign keyless sign (GHCR/Hub) — see below
# or plain:
docker build -t unbound-sec:latest .
docker compose up -d
The compose template enables: read_only root fs, tmpfs for /tmp and
/run/unbound, no-new-privileges, cap_drop: ALL, CPU/memory/PID
limits. It publishes no ports — the resolver runs inside a shared
Docker network (e.g. the Pi-hole network). Publish on a specific host
address only if you need LAN access (see the comment in
docker-compose.yml).
Drop-in configs go into ./conf.d/ (mounted to /config), the RFC5011
root trust anchor persists in a named volume (/var/unbound).
Minimal (no hardening flags, still non-root):
docker run -d -p 5053:5053/udp -p 5053:5053/tcp -v ./conf.d:/config:ro unbound-sec:latest
Drop any *.conf file into /config (mounted from ./conf.d/) — it is
included by the base config (lexicographic order). The base config itself
lives in ./config/ and is baked into the image at /etc/unbound/ —
keep it out of /config, otherwise the include becomes recursive.
Examples:
# /config/forward-records.conf — DoT forwarding
# The #name suffix pins the TLS certificate identity; without it unbound
# accepts any certificate signed by a trusted CA (any forwarder on the
# path could impersonate the upstream).
forward-zone:
name: "."
forward-tls-upstream: yes
forward-addr: 1.1.1.1@853#cloudflare-dns.com
forward-addr: 1.0.0.1@853#cloudflare-dns.com
# /config/cachedb.conf — Redis auxiliary cache
cachedb:
backend: "redis"
secret-seed: "default"
redis-server-host: redis
redis-server-port: 6379
Config changes require a container restart. Full reference: unbound.conf(5).
The whole test suite runs inside Docker (runner = docker:cli container with
the socket mounted; all assertions target containers):
./test/run.sh
Covers: build, healthcheck, version pin, DNS resolution, DNSSEC via correct
EDNS-DO queries (signed zone -> AD=1, no DO request -> AD=0, repeat),
DNSSEC negative test (a controlled zone broken.example with an
explicit trust anchor and three assertions: a valid zone validates to
NOERROR+AD, a zone with a manipulated signature is rejected with
SERVFAIL (no CD), and the same broken answer resolves to NOERROR with
validation off — the counter-test that proves the SERVFAIL is a signature
rejection, not a generic resolution failure; catches regressions like
val-permissive-mode: yes), non-root uid,
CapEff=0, no SUID binaries, read-only root fs, no-new-privileges, seccomp,
hide-identity (with control container proving the identity is revealed when
the flag is off), drop-in include (accept + reject), attack surface (no curl,
no shadow), supply chain (GPG signatures bound to the pinned key + SHA256
in build log, cache-bust per run), PIE (ELF e_type of the final binary),
compiled feature flags (configure line of unbound -V), RFC5011 anchor
persistence across container restart (content + mtime untouched, AD=1 before
and after), and a start test with the ACTUAL docker-compose.yml template
under a dedicated test project (regression for the recursive-include finding
of the 10/2026 external audit).
Probe semantics: the DNSSEC and CHAOS probes use a three-state exit code —
0=pass, 1=content deviation, 2=timeout. A content deviation (e.g. a
leaked identity, a missing AD bit) fails the run; a network timeout is
reported as NOT VERIFIED in the result line (visible, re-run to clear) so
infrastructure flakiness never masks a real finding. Any other exit code
(e.g. a Docker start error, exit 125) is reported as an execution error and
fails the run — a broken probe can no longer masquerade as a network hiccup.
Test isolation: the suite runs the compose template under the dedicated
project unbound-sec-test with a test-image override (test/compose.test.yml
pins unbound-sec:test) and removes only the resources it created — a
production deployment of the same template on the same daemon (and its
unbound-sec:latest tag / anchor volume) is untouched.
- image: crazymax/unbound:latest
+ image: unbound-sec:latest
Port 5053, healthcheck and the /config drop-in mechanism are identical.
One difference: unbound-sec mounts the drop-in dir ./conf.d/ to
/config (crazymax mounts ./config/). Move existing drop-ins from
config/ to conf.d/ — the base config must not sit inside /config
(recursive include). Add the hardening options from docker-compose.yml
(read_only, tmpfs, no-new-privileges, cap_drop, resource limits) and the
anchor volume for RFC5011 persistence.
build.sh signs the image with cosign in keyless mode (GitHub OIDC token).
With COSIGN_SIGN=1 it first pushes REGISTRY_IMAGE, then signs the
digest reported by the push (digest: sha256:… from the push output) — so
the signature is bound to the exact registry reference that was just published,
not to a (possibly pre-existing) registry tag:
REGISTRY_IMAGE=ghcr.io/<owner>/unbound-sec:latest COSIGN_SIGN=1 ./build.sh
The verification-only identity conditions live on the verify side (not on
sign); note that the certificate identity is the GitHub Actions workflow
URL and the issuer is the token endpoint — separate fields:
cosign verify \
--certificate-identity-regexp "^https://github.com/<owner>/unbound-sec/.github/workflows/.*" \
--certificate-oidc-issuer-regexp "^https://token.actions.githubusercontent.com$" \
--certificate-github-workflow-repository <owner>/unbound-sec \
ghcr.io/<owner>/unbound-sec:latest
MIT