Quellcode durchsuchen

v0.3.3: GnuPG-Exitcode in GPG-Pipeline prüfen; cd-check.py DO-Bit-Feld fixen

Audit-Runde 4 (v0.3.2, e4dfe4a):
- [P3] GPG-Pipeline ignorierte den Rückgabecode von GnuPG: In set -eux
  zählt nur der Exitcode des letzten grep; ein passender VALIDSIG-
  Fingerprint reichte aus, selbst wenn GnuPG selbst fehlschlug
  (abgelaufener/widerrufener Key). Jetzt: GnuPG als separater Befehl
  (Exitcode wird von && geprüft), Status in Datei, dann Fingerprint-
  Check. Beide Stages (unbound + ldns).
- [Minor] test/cd-check.py: DO-Bit (0x8000) stand im 2-Byte-CLASS-Feld
  statt im 4-Byte-EXTENDED-FLAGS-Feld des OPT-Records → DO-Bit war nicht
  gesetzt (AD blieb 0). Gefixt auf struct.pack(">HHIH",41,0,0x8000,0),
  wie dns-check.py und wie unbound es interpretiert (verifiziert: AD=1).
  Datei ist im Gegentest ungenutzt (validator via module-config off).
ric vor 1 Monat
Ursprung
Commit
525ba18ad9
3 geänderte Dateien mit 34 neuen und 7 gelöschten Zeilen
  1. 25 0
      CHANGELOG.md
  2. 4 4
      Dockerfile
  3. 5 3
      test/cd-check.py

+ 25 - 0
CHANGELOG.md

@@ -2,6 +2,31 @@
 
 All notable changes to this project are documented here.
 
+## [0.3.3] - 2026-10-23
+
+Closes the findings of the fourth audit of v0.3.2 (commit `e4dfe4a`): the GPG
+pipeline now requires a successful GnuPG exit code before checking the signer
+fingerprint, and a latent DO-bit field bug in `test/cd-check.py` is fixed.
+
+### Fixed (P3)
+- **The GPG pipeline ignored GnuPG's return code.** With `set -eux`, a
+  `gpg … | grep … | awk … | grep …` pipeline's exit status is that of the last
+  `grep`; a matching `VALIDSIG` fingerprint was therefore enough to proceed even
+  if GnuPG itself reported an error. `VALIDSIG` only means *cryptographically
+  valid* and can appear alongside expired/revoked-key warnings. Now GnuPG runs
+  as a **separate command** (its exit code is checked by `&&`), the status
+  output is stored to a file, and only then is that file checked for the expected
+  signer fingerprint — so a non-zero GnuPG exit (e.g. expired/revoked key,
+  missing public key) fails the build. (Both the unbound and ldns source
+  stages.)
+- **`test/cd-check.py` had the DO bit in the wrong OPT field.** The `0x8000`
+  was in the 2-byte CLASS field instead of the OPT record's 4-byte EXTENDED
+  FLAGS field, so the DO bit was not set (verified: AD stayed 0). Fixed to
+  `struct.pack(">HHIH", 41, 0, 0x8000, 0)` — matching `dns-check.py` and how
+  unbound interprets the DO bit (verified: AD=1). The file is not used by the
+  current counter-test (which disables the validator via `module-config:
+  iterator`), so this is a latent bug, not a behavioral change.
+
 ## [0.3.2] - 2026-10-23
 
 Closes the findings of the third audit of v0.3.1 (commit `678fdbf`): the

+ 4 - 4
Dockerfile

@@ -73,8 +73,8 @@ RUN set -eux \
  && gpg --no-tty --list-keys --with-colons \
     | awk -F: '/^fpr:/{print $10}' \
     | grep -qx "$GNUPG_FINGERPRINT" \
- && gpg --batch --verify --status-fd 1 unbound.tar.gz.asc unbound.tar.gz 2>/dev/null \
-    | grep '^\[GNUPG:\] VALIDSIG' | awk '{print $3}' \
+ && gpg --batch --verify --status-fd 1 unbound.tar.gz.asc unbound.tar.gz > /tmp/gpg.status 2>/dev/null \
+ && awk '/^\[GNUPG:\] VALIDSIG/ {print $3; exit}' /tmp/gpg.status \
     | grep -qx "$GNUPG_FINGERPRINT" \
  && echo "GPG-VALIDSIG unbound.tar.gz signer=$GNUPG_FINGERPRINT" \
  && tar xzf unbound.tar.gz --strip 1
@@ -99,8 +99,8 @@ RUN set -eux \
  && gpg --no-tty --list-keys --with-colons \
     | awk -F: '/^fpr:/{print $10}' \
     | grep -qx "$GNUPG_FINGERPRINT" \
- && gpg --batch --verify --status-fd 1 ldns.tar.gz.asc ldns.tar.gz 2>/dev/null \
-    | grep '^\[GNUPG:\] VALIDSIG' | awk '{print $3}' \
+ && gpg --batch --verify --status-fd 1 ldns.tar.gz.asc ldns.tar.gz > /tmp/gpg.status 2>/dev/null \
+ && awk '/^\[GNUPG:\] VALIDSIG/ {print $3; exit}' /tmp/gpg.status \
     | grep -qx "$GNUPG_FINGERPRINT" \
  && echo "GPG-VALIDSIG ldns.tar.gz signer=$GNUPG_FINGERPRINT" \
  && tar xzf ldns.tar.gz --strip 1

+ 5 - 3
test/cd-check.py

@@ -14,9 +14,11 @@ name = b"\x03www\x08broken\x07example\x00"  # www.broken.example
 qtype, qclass = 1, 1
 flags = 0x0110  # RD | CD
 tid = 0x1234
-# OPT record carrying the DO bit: name(root) + type(41) + class(extflags=DO)
-# + ttl(udp-size) + rdlength(0). The 32-bit TTL field must be present.
-opt = b"\x00" + struct.pack(">HHIH", 41, 0x8000, 0, 0)
+# OPT record carrying the DO bit. The DO bit lives in the OPT record's 4-byte
+# EXTENDED FLAGS field (0x8000), NOT in the 2-byte CLASS field — this matches
+# how unbound (and dns-check.py) interpret it. Fields: type(41) + class(0) +
+# extflags(DO=0x8000) + rdlength(0).
+opt = b"\x00" + struct.pack(">HHIH", 41, 0, 0x8000, 0)
 hdr = struct.pack(">HHHHHH", tid, flags, 1, 0, 0, 1)
 pkt = hdr + name + struct.pack(">HH", qtype, qclass) + opt