|
|
@@ -17,8 +17,11 @@ C2="ubsec-t2" # valid drop-in container
|
|
|
C3="ubsec-t3" # broken drop-in container
|
|
|
C4="ubsec-t4" # identity control container
|
|
|
C5="ubsec-t5" # anchor persistence container
|
|
|
-C6="ubsec-t6" # DNSSEC negative-test unbound (forward-zone)
|
|
|
-RESP="ubsec-t6-resp" # static DNS responder for the negative test
|
|
|
+C6="ubsec-t6" # negative-test: valid zone + trust anchor (expect AD)
|
|
|
+C7="ubsec-t7" # negative-test: broken signature + trust anchor (expect SERVFAIL)
|
|
|
+C8="ubsec-t8" # negative-test: broken zone, validator off (counter-test, expect NOERROR)
|
|
|
+RESP="ubsec-t6-resp" # static DNS responder, VALID zone (port 5353)
|
|
|
+RESP_BROKEN="ubsec-t7-resp" # static DNS responder, BROKEN zone (port 5354)
|
|
|
NET="ubsec-testnet"
|
|
|
# The compose template is tested under a DEDICATED project name so the test
|
|
|
# never touches a production deployment of the same template on this daemon
|
|
|
@@ -55,13 +58,18 @@ cleanup() {
|
|
|
# Remove ONLY resources this test run created. The fixed container name
|
|
|
# "unbound" is gone from the template, so we no longer rm a name that a
|
|
|
# production deployment might use.
|
|
|
- docker rm -f "$C1" "$C2" "$C3" "$C4" "$C5" "$C6" "$RESP" >/dev/null 2>&1
|
|
|
+ docker rm -f "$C1" "$C2" "$C3" "$C4" "$C5" "$C6" "$C7" "$C8" "$RESP" "$RESP_BROKEN" >/dev/null 2>&1
|
|
|
compose_test down --remove-orphans --volumes >/dev/null 2>&1
|
|
|
docker network rm "$NET" >/dev/null 2>&1
|
|
|
docker network rm "ubsec-negnet" >/dev/null 2>&1
|
|
|
rm -rf "$(pwd)/test/fixture-identity" 2>/dev/null
|
|
|
- rm -rf "$(pwd)/test/fixture-broken-fwd" 2>/dev/null
|
|
|
- rm -f "$(pwd)/test/.broken-zone.bin" 2>/dev/null
|
|
|
+ rm -rf "$(pwd)/test/fixture-broken-valid" 2>/dev/null
|
|
|
+ rm -rf "$(pwd)/test/fixture-broken-broken" 2>/dev/null
|
|
|
+ rm -rf "$(pwd)/test/fixture-broken-noval" 2>/dev/null
|
|
|
+ rm -f "$(pwd)/test/.broken-valid.bin" 2>/dev/null
|
|
|
+ rm -f "$(pwd)/test/.broken-broken.bin" 2>/dev/null
|
|
|
+ rm -f "$(pwd)/test/.broken-dnskey.bin" 2>/dev/null
|
|
|
+ rm -f "$(pwd)/test/.broken-anchor.key" 2>/dev/null
|
|
|
rm -rf "$ANCHOR_DIR" 2>/dev/null
|
|
|
rm -f "$(pwd)/test/build.log" 2>/dev/null
|
|
|
}
|
|
|
@@ -157,7 +165,9 @@ case $probe_rc in
|
|
|
0) ok "external EDNS-DO probe (AD=1 with DO, AD=0 without)";;
|
|
|
1) bad "external EDNS-DO probe: CONTENT deviation"
|
|
|
printf '%s\n' "$probe_out" | sed 's/^/ /';;
|
|
|
- *) nv "external EDNS-DO probe (timeout; loopback check is the proof)"
|
|
|
+ 2) nv "external EDNS-DO probe (timeout; loopback check is the proof)"
|
|
|
+ printf '%s\n' "$probe_out" | sed 's/^/ /';;
|
|
|
+ *) bad "external EDNS-DO probe: execution error (exit $probe_rc)"
|
|
|
printf '%s\n' "$probe_out" | sed 's/^/ /';;
|
|
|
esac
|
|
|
|
|
|
@@ -223,7 +233,9 @@ case $id_rc in
|
|
|
0) ok "hide-identity: id.server. answer is empty";;
|
|
|
1) bad "hide-identity: id.server. answer is empty (CONTENT deviation)"
|
|
|
printf '%s\n' "$id_out" | sed 's/^/ /';;
|
|
|
- *) nv "hide-identity CHAOS probe (timeout; config asserted below)"
|
|
|
+ 2) nv "hide-identity CHAOS probe (timeout; config asserted below)"
|
|
|
+ printf '%s\n' "$id_out" | sed 's/^/ /';;
|
|
|
+ *) bad "hide-identity CHAOS probe: execution error (exit $id_rc)"
|
|
|
printf '%s\n' "$id_out" | sed 's/^/ /';;
|
|
|
esac
|
|
|
# Config-level assertion (deterministic): the base config must set it.
|
|
|
@@ -245,7 +257,9 @@ case $id2_rc in
|
|
|
0) ok "identity control: hide-identity:no reveals identity";;
|
|
|
1) bad "identity control: hide-identity:no reveals identity (CONTENT deviation)"
|
|
|
printf '%s\n' "$id2_out" | sed 's/^/ /';;
|
|
|
- *) nv "identity-control CHAOS probe (timeout)"
|
|
|
+ 2) nv "identity-control CHAOS probe (timeout)"
|
|
|
+ printf '%s\n' "$id2_out" | sed 's/^/ /';;
|
|
|
+ *) bad "identity-control CHAOS probe: execution error (exit $id2_rc)"
|
|
|
printf '%s\n' "$id2_out" | sed 's/^/ /';;
|
|
|
esac
|
|
|
|
|
|
@@ -286,11 +300,14 @@ else
|
|
|
fi
|
|
|
|
|
|
say "== 15. supply chain: GPG + SHA256 of source tarballs =="
|
|
|
-sigs="$(grep -c "Good signature" "$BUILDLOG" 2>/dev/null)"
|
|
|
+# The build echoes "GPG-VALIDSIG <tarball> signer=<fpr>" after each successful
|
|
|
+# signature verification (the signer fingerprint is extracted from GnuPG's
|
|
|
+# machine-readable --status-fd output and must equal the pinned fingerprint).
|
|
|
+sigs="$(grep -c "GPG-VALIDSIG" "$BUILDLOG" 2>/dev/null)"
|
|
|
if [ "$sigs" -ge 2 ]; then
|
|
|
- ok "GPG: Good signature x$sigs (unbound + ldns tarballs)"
|
|
|
+ ok "GPG: signer bound via VALIDSIG x$sigs (unbound + ldns tarballs)"
|
|
|
else
|
|
|
- bad "GPG: Good signature (found: $sigs, need >= 2)"
|
|
|
+ bad "GPG: signer bound via VALIDSIG (found: $sigs, need >= 2)"
|
|
|
fi
|
|
|
if grep -E "unbound\.tar\.gz: OK|ldns\.tar\.gz: OK" "$BUILDLOG" >/dev/null 2>&1; then
|
|
|
ok "SHA256: tarball checksums OK"
|
|
|
@@ -431,78 +448,124 @@ fi
|
|
|
compose_test down --remove-orphans --volumes >/dev/null 2>&1
|
|
|
|
|
|
say "== 20. DNSSEC negative test: invalid signature -> SERVFAIL =="
|
|
|
-# Controlled zone "broken.example" served by a static responder: a
|
|
|
-# well-formed RRSIG whose DNSKEY cannot be anchored in the trust chain (no
|
|
|
-# parent DS). A validating resolver must reject it with SERVFAIL (without
|
|
|
-# CD). This catches regressions like val-permissive-mode: yes, which would
|
|
|
-# still validate good answers but let broken ones through.
|
|
|
+# Controlled zone "broken.example" with an EXPLICIT trust anchor (the zone
|
|
|
+# DNSKEY), so validation is well-defined (RFC 4035 5.2 — no parent DS needed):
|
|
|
+# C6 valid : A + RRSIG (valid) -> NOERROR + AD
|
|
|
+# C7 broken : A (data modified) + RRSIG -> SERVFAIL (signature rejected)
|
|
|
+# C8 noval : broken zone, validator off -> NOERROR (resolvable, counter-test)
|
|
|
+# The counter-test (C8) separates SIGNATURE REJECTION from a generic
|
|
|
+# resolution failure: the broken answer resolves fine with validation off,
|
|
|
+# yet its signature is rejected with validation on. A static responder that
|
|
|
+# merely failed to serve the DNSKEY would not produce this pattern.
|
|
|
#
|
|
|
-# 1) generate the zone packet (fresh RRSIG timestamps) in a python container
|
|
|
-# 2) start a static UDP responder serving it
|
|
|
-# 3) start a test unbound with a forward-zone to the responder
|
|
|
-# 4) query www.broken.example A with DO -> expect SERVFAIL (rcode=2)
|
|
|
-#
|
|
|
-# RESP and C6 get their OWN network (not $NET), so they can't be affected by
|
|
|
-# the other test containers and the test stays deterministic.
|
|
|
+# RESP/RESP_BROKEN and C6/C7/C8 get their OWN network (not $NET), so they
|
|
|
+# can't be affected by the other test containers and the test stays
|
|
|
+# deterministic.
|
|
|
REPO="${REPO_PATH:-$(pwd)}"
|
|
|
NEG_NET="ubsec-negnet"
|
|
|
docker network create "$NEG_NET" >/dev/null 2>&1
|
|
|
-BZBIN="$(pwd)/test/.broken-zone.bin"
|
|
|
-# Remove any stale BZBIN first: if a previous run left a DIRECTORY there (Docker
|
|
|
-# creates a dir when mounting a missing file), the generator would fail with
|
|
|
-# IsADirectoryError.
|
|
|
-rm -rf "$BZBIN"
|
|
|
-docker run --rm -v "$REPO/test/make-broken-zone.py:/m.py:ro" -v "$(pwd)/test:/o" \
|
|
|
- python:alpine sh -c "pip install -q dnspython cryptography 2>/dev/null; python /m.py /o/.broken-zone.bin" >/dev/null 2>&1
|
|
|
-if [ ! -f "$BZBIN" ]; then
|
|
|
- bad "generate broken.example zone packet"
|
|
|
+BZDIR="$(pwd)/test"
|
|
|
+# Remove stale zone files first: a DIRECTORY left there by a previous mount of
|
|
|
+# a missing file would make the generator fail with IsADirectoryError.
|
|
|
+rm -f "$BZDIR/.broken-valid.bin" "$BZDIR/.broken-broken.bin" \
|
|
|
+ "$BZDIR/.broken-dnskey.bin" "$BZDIR/.broken-anchor.key"
|
|
|
+docker run --rm -v "$REPO/test/make-broken-zone.py:/m.py:ro" -v "$BZDIR:/o" \
|
|
|
+ python:alpine sh -c "pip install -q dnspython cryptography 2>/dev/null; python /m.py /o" >/dev/null 2>&1
|
|
|
+if [ ! -f "$BZDIR/.broken-valid.bin" ] || [ ! -f "$BZDIR/.broken-broken.bin" ] \
|
|
|
+ || [ ! -f "$BZDIR/.broken-dnskey.bin" ] || [ ! -f "$BZDIR/.broken-anchor.key" ]; then
|
|
|
+ bad "generate broken.example zone packets"
|
|
|
else
|
|
|
- ok "generate broken.example zone packet"
|
|
|
+ ok "generate broken.example zone packets (valid + broken + anchor)"
|
|
|
fi
|
|
|
+# Two static responders: VALID (5353) and BROKEN (5354). Both serve the same
|
|
|
+# DNSKEY packet (for trust-anchor priming); only the A packet differs.
|
|
|
docker run -d --name "$RESP" --network "$NEG_NET" \
|
|
|
- -v "$BZBIN:/p.bin:ro" -v "$REPO/test/broken-zone-responder.py:/r.py:ro" \
|
|
|
- python:alpine python /r.py /p.bin 5353 >/dev/null
|
|
|
-# Get the responder's IP from ITS OWN log (it prints its container IP). This
|
|
|
-# is more reliable than `docker inspect` from the host, which can be empty
|
|
|
-# while the container is starting on a slow WSL daemon.
|
|
|
-RESP_IP=""; i=0
|
|
|
-while [ $i -lt 15 ]; do
|
|
|
- RESP_IP="$(docker logs "$RESP" 2>&1 | grep -oE 'responder ip=[0-9.]+' | head -1 | cut -d= -f2)"
|
|
|
- [ -n "$RESP_IP" ] && [ "$RESP_IP" != "0.0.0.0" ] && break
|
|
|
- sleep 2; i=$((i+1))
|
|
|
-done
|
|
|
-# Fallback to docker inspect if the log didn't yield an IP.
|
|
|
-if [ -z "$RESP_IP" ] || [ "$RESP_IP" = "0.0.0.0" ]; then
|
|
|
- RESP_IP="$(docker inspect -f '{{(index .NetworkSettings.Networks "'"$NEG_NET"').IPAddress}}' "$RESP" 2>/dev/null)"
|
|
|
-fi
|
|
|
-[ -n "$RESP_IP" ] || { bad "negative-test responder has an IP (got empty)"
|
|
|
- docker logs "$RESP" 2>&1 | tail -3 | sed 's/^/ /'
|
|
|
- say " networks: $(docker inspect -f '{{json .NetworkSettings.Networks}}' "$RESP" 2>/dev/null)"
|
|
|
- say " state: $(docker inspect -f '{{.State.Running}} exit={{.State.ExitCode}}' "$RESP" 2>/dev/null)"; }
|
|
|
-FWD_DIR="$(pwd)/test/fixture-broken-fwd"
|
|
|
-rm -rf "$FWD_DIR"; mkdir -p "$FWD_DIR"; chmod 755 "$FWD_DIR"
|
|
|
-printf 'forward-zone:\n name: "broken.example"\n forward-addr: %s@5353\n' "$RESP_IP" > "$FWD_DIR/99-broken.conf"
|
|
|
-chmod 644 "$FWD_DIR/99-broken.conf"
|
|
|
-docker run -d --name "$C6" --network "$NEG_NET" -v "$FWD_DIR:/config:ro" "$IMAGE" >/dev/null
|
|
|
-# wait for readiness: unbound is ready when it answers the (broken) query at
|
|
|
-# all — a SERVFAIL is a valid response, so we check for ANY rcode, not a
|
|
|
-# successful (exit 0) drill.
|
|
|
-ready="no"; i=0
|
|
|
-while [ $i -lt 15 ]; do
|
|
|
- if docker exec "$C6" drill -p 5053 -D www.broken.example A @127.0.0.1 2>/dev/null | grep -q "rcode:"; then
|
|
|
- ready="yes"; break
|
|
|
+ -v "$BZDIR/.broken-valid.bin:/a.bin:ro" -v "$BZDIR/.broken-dnskey.bin:/k.bin:ro" \
|
|
|
+ -v "$REPO/test/broken-zone-responder.py:/r.py:ro" \
|
|
|
+ python:alpine python /r.py /a.bin /k.bin 5353 >/dev/null
|
|
|
+docker run -d --name "$RESP_BROKEN" --network "$NEG_NET" \
|
|
|
+ -v "$BZDIR/.broken-broken.bin:/a.bin:ro" -v "$BZDIR/.broken-dnskey.bin:/k.bin:ro" \
|
|
|
+ -v "$REPO/test/broken-zone-responder.py:/r.py:ro" \
|
|
|
+ python:alpine python /r.py /a.bin /k.bin 5354 >/dev/null
|
|
|
+# Get a responder's IP from ITS OWN log (it prints its container IP); fall
|
|
|
+# back to docker inspect. This is more reliable than host-side inspect, which
|
|
|
+# can be empty while a container is starting on a slow WSL daemon.
|
|
|
+get_ip() {
|
|
|
+ _c="$1"; _ip=""; _i=0
|
|
|
+ while [ $_i -lt 15 ]; do
|
|
|
+ _ip="$(docker logs "$_c" 2>&1 | grep -oE 'responder ip=[0-9.]+' | head -1 | cut -d= -f2)"
|
|
|
+ [ -n "$_ip" ] && [ "$_ip" != "0.0.0.0" ] && break
|
|
|
+ sleep 2; _i=$((_i+1))
|
|
|
+ done
|
|
|
+ if [ -z "$_ip" ] || [ "$_ip" = "0.0.0.0" ]; then
|
|
|
+ _ip="$(docker inspect -f '{{(index .NetworkSettings.Networks "'"$NEG_NET"').IPAddress}}' "$_c" 2>/dev/null)"
|
|
|
fi
|
|
|
- sleep 2; i=$((i+1))
|
|
|
-done
|
|
|
-[ "$ready" = "yes" ] || bad "negative-test resolver ready"
|
|
|
-sf_out="$(docker exec "$C6" drill -p 5053 -D www.broken.example A @127.0.0.1 2>/dev/null)"
|
|
|
-if printf '%s' "$sf_out" | grep -q "rcode: SERVFAIL"; then
|
|
|
- ok "invalid signature -> SERVFAIL (no CD; validator rejects unanchorable DNSKEY)"
|
|
|
+ printf '%s' "$_ip"
|
|
|
+}
|
|
|
+RVALID="$(get_ip "$RESP")"
|
|
|
+RBROKEN="$(get_ip "$RESP_BROKEN")"
|
|
|
+[ -n "$RVALID" ] && [ -n "$RBROKEN" ] || {
|
|
|
+ bad "negative-test responders have IPs (valid=$RVALID broken=$RBROKEN)"
|
|
|
+ docker logs "$RESP" 2>&1 | tail -2 | sed 's/^/ /'
|
|
|
+ docker logs "$RESP_BROKEN" 2>&1 | tail -2 | sed 's/^/ /'
|
|
|
+}
|
|
|
+# C6: trust anchor + forward to VALID + validator -> expect NOERROR + AD
|
|
|
+FWD_V="$(pwd)/test/fixture-broken-valid"; rm -rf "$FWD_V"; mkdir -p "$FWD_V"; chmod 755 "$FWD_V"
|
|
|
+printf 'trust-anchor-file: "/anchor.key"\nforward-zone:\n name: "broken.example"\n forward-addr: %s@5353\n' "$RVALID" > "$FWD_V/99.conf"
|
|
|
+chmod 644 "$FWD_V/99.conf"
|
|
|
+docker run -d --name "$C6" --network "$NEG_NET" -v "$FWD_V:/config:ro" -v "$BZDIR/.broken-anchor.key:/anchor.key:ro" "$IMAGE" >/dev/null
|
|
|
+# C7: trust anchor + forward to BROKEN + validator -> expect SERVFAIL
|
|
|
+FWD_B="$(pwd)/test/fixture-broken-broken"; rm -rf "$FWD_B"; mkdir -p "$FWD_B"; chmod 755 "$FWD_B"
|
|
|
+printf 'trust-anchor-file: "/anchor.key"\nforward-zone:\n name: "broken.example"\n forward-addr: %s@5354\n' "$RBROKEN" > "$FWD_B/99.conf"
|
|
|
+chmod 644 "$FWD_B/99.conf"
|
|
|
+docker run -d --name "$C7" --network "$NEG_NET" -v "$FWD_B:/config:ro" -v "$BZDIR/.broken-anchor.key:/anchor.key:ro" "$IMAGE" >/dev/null
|
|
|
+# C8: validator disabled (module-config: iterator) + forward to BROKEN ->
|
|
|
+# expect NOERROR (the broken answer is resolvable, just not validated).
|
|
|
+FWD_N="$(pwd)/test/fixture-broken-noval"; rm -rf "$FWD_N"; mkdir -p "$FWD_N"; chmod 755 "$FWD_N"
|
|
|
+printf 'module-config: iterator\nforward-zone:\n name: "broken.example"\n forward-addr: %s@5354\n' "$RBROKEN" > "$FWD_N/99.conf"
|
|
|
+chmod 644 "$FWD_N/99.conf"
|
|
|
+docker run -d --name "$C8" --network "$NEG_NET" -v "$FWD_N:/config:ro" "$IMAGE" >/dev/null
|
|
|
+# Readiness: unbound is ready when it answers the query at all — a SERVFAIL is
|
|
|
+# a valid response, so check for ANY rcode, not a successful (exit 0) drill.
|
|
|
+ready_c() {
|
|
|
+ _c="$1"; _r="no"; _i=0
|
|
|
+ while [ $_i -lt 15 ]; do
|
|
|
+ if docker exec "$_c" drill -p 5053 -D www.broken.example A @127.0.0.1 2>/dev/null | grep -q "rcode:"; then
|
|
|
+ _r="yes"; break
|
|
|
+ fi
|
|
|
+ sleep 2; _i=$((_i+1))
|
|
|
+ done
|
|
|
+ [ "$_r" = "yes" ]
|
|
|
+}
|
|
|
+ready_c "$C6" && ok "negative-test: valid resolver ready" || bad "negative-test: valid resolver ready"
|
|
|
+ready_c "$C7" && ok "negative-test: broken resolver ready" || bad "negative-test: broken resolver ready"
|
|
|
+ready_c "$C8" && ok "negative-test: noval resolver ready" || bad "negative-test: noval resolver ready"
|
|
|
+# 1) VALID zone validates: NOERROR + AD
|
|
|
+v_out="$(docker exec "$C6" drill -p 5053 -D www.broken.example A @127.0.0.1 2>/dev/null)"
|
|
|
+if printf '%s' "$v_out" | grep -q "rcode: NOERROR" && printf '%s' "$v_out" | grep -qE "flags:.*ad"; then
|
|
|
+ ok "valid zone validates (NOERROR + AD with explicit trust anchor)"
|
|
|
+else
|
|
|
+ bad "valid zone validates (got: $(printf '%s' "$v_out" | grep rcode | head -1))"
|
|
|
+ printf '%s\n' "$v_out" | sed 's/^/ /'
|
|
|
+fi
|
|
|
+# 2) BROKEN signature rejected: SERVFAIL (no CD)
|
|
|
+b_out="$(docker exec "$C7" drill -p 5053 -D www.broken.example A @127.0.0.1 2>/dev/null)"
|
|
|
+if printf '%s' "$b_out" | grep -q "rcode: SERVFAIL"; then
|
|
|
+ ok "broken signature -> SERVFAIL (no CD; validator rejects the invalid RRSIG)"
|
|
|
+else
|
|
|
+ bad "broken signature -> SERVFAIL (got: $(printf '%s' "$b_out" | grep rcode | head -1))"
|
|
|
+ printf '%s\n' "$b_out" | sed 's/^/ /'
|
|
|
+fi
|
|
|
+# 3) Counter-test: broken answer is RESOLVABLE with validation off -> NOERROR.
|
|
|
+# This proves step 2 is a signature rejection, not a resolution failure.
|
|
|
+n_out="$(docker exec "$C8" drill -p 5053 www.broken.example A @127.0.0.1 2>/dev/null)"
|
|
|
+if printf '%s' "$n_out" | grep -q "rcode: NOERROR" && printf '%s' "$n_out" | grep -qE "IN[[:space:]]+A[[:space:]]"; then
|
|
|
+ ok "broken answer resolvable with validation off (counter-test: signature rejection, not resolution failure)"
|
|
|
else
|
|
|
- bad "invalid signature -> SERVFAIL (got: $(printf '%s' "$sf_out" | grep rcode | head -1))"
|
|
|
- printf '%s\n' "$sf_out" | sed 's/^/ /'
|
|
|
+ bad "broken answer resolvable with validation off (got: $(printf '%s' "$n_out" | grep rcode | head -1))"
|
|
|
+ printf '%s\n' "$n_out" | sed 's/^/ /'
|
|
|
fi
|
|
|
-rm -rf "$FWD_DIR"
|
|
|
+rm -rf "$FWD_V" "$FWD_B" "$FWD_N"
|
|
|
|
|
|
say ""
|
|
|
say "=================================================="
|