Ver Fonte

docs: complete deviation reference vs. vanilla Unbound 1.26.2 (build flags, config defaults, packaging)

All stock defaults verified against the 1.26.2 source (config_file.c,
acl_list.c, configure.ac), documented in docs/vanilla-deviations.md.
Bob há 1 mês atrás
pai
commit
beb843d5ab
2 ficheiros alterados com 96 adições e 0 exclusões
  1. 3 0
      README.md
  2. 93 0
      docs/vanilla-deviations.md

+ 3 - 0
README.md

@@ -8,6 +8,9 @@ healthcheck — with the security findings from the 10/2026 audit of
 
 ## Why this project
 
+Full reference of all deviations from vanilla Unbound 1.26.2 (build flags,
+config defaults, packaging): [docs/vanilla-deviations.md](docs/vanilla-deviations.md).
+
 Audit results for `crazymax/unbound:latest` (Unbound 1.26.1, Alpine 3.24.1,
 built 2026-09-17):
 

+ 93 - 0
docs/vanilla-deviations.md

@@ -0,0 +1,93 @@
+# Deviations from vanilla Unbound 1.26.2
+
+Complete reference of everything this project changes relative to stock
+Unbound 1.26.2 (NLnet Labs). All stock defaults below were verified against
+the 1.26.2 source (`util/config_file.c`, `daemon/acl_list.c`, `configure.ac`)
+on 2026-10-23 — not from memory.
+
+Three levels: (1) build/compile, (2) runtime configuration
+(`config/unbound.conf`), (3) container packaging.
+
+## 1. Build / compile deviations
+
+Vanilla `./configure` with no options vs. our Dockerfile build stage:
+
+| Flag | Vanilla default | unbound-sec | Why |
+|---|---|---|---|
+| `--with-username` | `unbound` (daemon drops to user "unbound" at startup) | `""` (no built-in user) | Container user model (Docker `USER unbound`, uid 1500) replaces it; avoids setuid inside the container |
+| `--with-chroot-dir` | same as run-dir | `""` (no chroot) | Containers are the isolation boundary; no nested chroot |
+| `--with-run-dir` | dir part of the config file (`/etc/unbound` for stock layout) | `/var/run/unbound` | explicit, writable run-dir (tmpfs in hardened mode) |
+| `--with-pidfile` | `run-dir/unbound.pid` | `/var/run/unbound/unbound.pid` | explicit |
+| `--with-ssl` | off | on (`/usr`) | DoT support (server-side TLS on 5053, TLS upstream) |
+| `--with-libevent` | off (own epoll loop) | on (`/usr`) | event library from Alpine, consistent with other crazy-max-style builds |
+| `--with-libhiredis` | off → cachedb module off | on → `--enable-cachedb` | Redis auxiliary cache available (drop-in compatible with crazymax) |
+| `--with-libexpat` | off (fails build if missing in this version) | on | required by `unbound-anchor` (RFC5011/XML); expat 2.9.0, no open CVEs |
+| `--enable-event-api` | off | on | experimental pluggable event API header installed (parity) |
+| `--disable-shared` | shared libs | static | no extra runtime .so dependencies |
+| `--disable-rpath` | on | off | deterministic linking |
+| `--disable-flto` | on | off | faster build, negligible runtime difference |
+
+Not compiled (vanilla default = off, kept off):
+DNS-over-QUIC (`--with-quic`, would pull libuv/libnghttp2), DNSCrypt,
+DNSTAP, GeoIP, Python control scripts, libcurl (unbound-anchor uses raw
+OpenSSL, no curl needed).
+
+Result (verified via `unbound -V` in the built image):
+`Linked modules: dns64 cachedb respip validator iterator`,
+`libevent 2.1.13-stable`, `OpenSSL 3.5.x`.
+
+Added on top of Unbound (not part of it):
+- ldns 1.9.2 with `drill` — used by the image healthcheck
+- Alpine runtime packages: ca-certificates (DoT cert bundle), dnssec-root
+  (root trust anchor), expat, hiredis, libevent, libpcap, openssl
+
+## 2. Configuration deviations (`config/unbound.conf`)
+
+Stock unbound runs with `verbosity 1, port 53, all interfaces, loopback-only
+ACL, no private-address list, no trust anchor, no TLS, daemonized`. Our base
+config changes:
+
+| Setting | Vanilla default | unbound-sec | Why |
+|---|---|---|---|
+| `interface` | all addresses @ 53 | `0.0.0.0@5053` | unprivileged port, drop-in compatible with crazymax/unbound |
+| `do-ip6` | yes | no | container network is IPv4; shrinks address space |
+| `do-daemonize` | yes | no | container runs the process in the foreground |
+| `so-sndbuf` | 4 MB (`4*1024*1024`) | 0 (kernel default) | avoids the "send buffer not granted" warning in containers without raised kernel limits (crazy-max made the same change) |
+| `access-control` | `127.0.0.0/8 allow` (+ `::1` if do-ip6) | RFC1918 (`10/8`, `172.16/12`, `192.168/16`) + `127/8` | LAN resolver; tighten via `/config` drop-in for larger exposures |
+| `private-address` | (none) | RFC1918 + `169.254.0.0/16` | internal ranges never leak into answers (vanilla would) |
+| `module-config` | `validator iterator` | `validator cachedb iterator` | cachedb module active (Redis auxiliary cache on demand) |
+| `statistics-interval` | 0 (off) | 600 | periodic stats to log |
+| `statistics-cumulative` | no | yes | stats accumulate across intervals |
+| `hide-identity` | no | yes | CHAOS `id.server` query returns nothing |
+| `hide-version` | no | yes | CHAOS `version.server` query returns nothing |
+| `identity` | (none) | `unbound-sec` | used only when `hide-identity: no` (tested) |
+| `directory` | run-dir | `/etc/unbound` | config location |
+| `pidfile` | `run-dir/unbound.pid` | `/run/unbound/unbound.pid` | writable tmpfs in hardened mode |
+| trust anchor | **none** (validator runs, but nothing is anchored) | `auto-trust-anchor-file: /run/unbound/root.key` (from `dnssec-root` package, copied by entrypoint) | real DNSSEC validation out of the box; RFC5011 rollover works on the writable run-dir |
+| `tls-cert-bundle` | (none) | `/etc/ssl/certs/ca-certificates.crt` | TLS upstream verification + DoT |
+| `include` | (none) | `/config/*.conf` | drop-in override mechanism (crazy-max compatible) |
+
+Unchanged from vanilla (explicitly set for clarity): `verbosity: 1`,
+`do-ip4: yes`, `do-udp: yes`, `do-tcp: yes`, `serve-expired-reply-ttl: 0`,
+`logfile: ""`.
+
+## 3. Container packaging (vanilla Unbound has none of this)
+
+- Alpine 3.24 base, multi-stage xx cross-compile, multi-arch capable
+- non-root user `unbound` (uid/gid 1500), zero effective capabilities,
+  no SUID binaries in the image
+- entrypoint: copy static root anchor to writable run-dir,
+  `unbound-checkconf` fail-fast, `exec unbound -d`
+- healthcheck: `drill -p 5053 unbound.net @127.0.0.1` (30 s interval)
+- `VOLUME /config`, `EXPOSE 5053/tcp 5053/udp`
+- hardened compose template: `read_only` root fs, tmpfs `/tmp` +
+  `/run/unbound` (uid/gid 1500), `no-new-privileges`, `cap_drop ALL`
+- cosign keyless signing via `build.sh` (optional)
+
+## What was deliberately NOT changed
+
+- Query behavior stays vanilla: no ratelimits, no prefetch tuning, no
+  `local-zone`/`local-data`, no EDNS changes — a drop-in replacement, not a
+  re-tuned resolver.
+- `access-control` stays as wide as crazy-max's (RFC1918), to keep
+  migration a one-line change.