diff --git a/.machine_readable/arrival-pack/arrival-pack.ncl b/.machine_readable/arrival-pack/arrival-pack.ncl index e0626ef3..b5741a9c 100644 --- a/.machine_readable/arrival-pack/arrival-pack.ncl +++ b/.machine_readable/arrival-pack/arrival-pack.ncl @@ -78,7 +78,7 @@ Use plain JavaScript when this tooling is needed. TypeScript and ReScript migrat # This repo: `%{data.canonical_name}` · clade `%{data.prefixed_name}` -- **Identity** — uuid `%{data.uuid}`; clade `%{data.clade_primary}` (secondary `%{data.clade_secondary}`); born %{data.born}; forge `%{data.forge_gh}`. +- **Identity** — chora id `%{data.uuid}`; clade `%{data.clade_primary}` (secondary `%{data.clade_secondary}`); born %{data.born}; forge `%{data.forge_gh}`. - **IS** — %{data.purpose} - **IS-NOT** — %{data.isnot} - **Where it sits** — pipeline position **%{data.pipeline_pos}**; chain `%{data.chain}`; coordination = `%{data.coordination}`. diff --git a/.machine_readable/arrival-pack/extract.sh b/.machine_readable/arrival-pack/extract.sh index 717959c0..3c7a80a3 100755 --- a/.machine_readable/arrival-pack/extract.sh +++ b/.machine_readable/arrival-pack/extract.sh @@ -49,10 +49,28 @@ items() { # hash12 -> short content hash of stdin (drift provenance) hash12() { sha256sum | cut -c1-12; } -# The uuid is derived from the header :repo-uuid name, never stored (deed.abnf). +# The identity is the deed's own TYPED literal, printed as written: +# #uuid"" (minted once, A7 J11), or the computed #u8"". +# The pack never prints a derived hex form of a name literal: that once put a +# version 5 id in CLAUDE.md, which ADR-008's strict gate (owner ruling D320) +# rejects in every minted repo. The typed literal says what the identifier is, +# as ADR-008 asks. (Ported from rsr-template-repo main 0044ad9.) uuid_name="$(field '' repo-uuid)" uuid="" -[ -z "$uuid_name" ] || uuid="$(bash "$READ" --uuid "$DEED")" +if [[ -n "$uuid_name" ]]; then + # --typed keeps the tag and quotes, and reads the literal wherever the layout puts it + rc=0 + uuid="$(bash "$READ" --typed "$DEED" '' repo-uuid)" || rc=$? + [[ "$rc" -le 1 ]] || exit "$rc" + [[ "$uuid" =~ ^#u(uid|[0-9]+)\"[^\"]*\"$ ]] || uuid="" +fi +[ -z "$uuid_name" ] || [ -n "$uuid" ] \ + || { echo "extract.sh: $(basename "$DEED") :repo-uuid is not a typed #uuid\"...\" or #u\"...\" literal" >&2; exit 2; } +case "$uuid" in + '#u5"'*|'#uuid"'????????-????-5*) + echo "extract.sh: v5-identity: $(basename "$DEED") :repo-uuid $uuid is a version 5 id; the chora id is #uuid\"\" (standards A1 V8)" >&2 ;; + *) ;; +esac # read_clauses -> the clauses this pack reads, one token per line. Hashing only # these keeps an unrelated deed edit (say a canon-pin bump) from reading as drift. diff --git a/CLAUDE.md b/CLAUDE.md index 004c31e2..e98b9385 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -60,7 +60,7 @@ Use plain JavaScript when this tooling is needed. TypeScript and ReScript migrat # This repo: `zig-dnssec` · clade `pt-zig-dnssec` -- **Identity** — uuid `f7d5bf31-3b1a-5c6f-bbf5-7e6ef587ab48`; clade `pt` (secondary `sc`); born 2026-10-13; forge `hyperpolymath/zig-dnssec`. +- **Identity** — chora id `#u8"gv-clade-index:github.com/hyperpolymath/zig-dnssec"`; clade `pt` (secondary `sc`); born 2026-10-13; forge `hyperpolymath/zig-dnssec`. - **IS** — Experimental pure-Zig DNS wire-format codec and DNSSEC validator with a DNS-over-HTTPS stub client: authenticates answers from an untrusted upstream resolver to a configured trust anchor. - **IS-NOT** — a recursive resolver · an authoritative server · a DNS cache · independently reviewed - **Where it sits** — pipeline position **leaf**; chain `standards → rsr-template-repo → zig-dnssec`; coordination = `standards`. diff --git a/EXPLAINME.adoc b/EXPLAINME.adoc index 767346b9..d291f2b4 100644 --- a/EXPLAINME.adoc +++ b/EXPLAINME.adoc @@ -120,8 +120,9 @@ link:src/stub/doh.zig[] and link:src/stub/client.zig[]. Every cross-check query through this transport. Caveat:: -Zig 0.17.0's `std.http.Client` sends HTTPS requests in cleartext through a CONNECT proxy, so -the transport drives `std.crypto.tls.Client` itself. Correctness of the TLS client is +Zig 0.17's `std.http.Client` sends HTTPS requests in cleartext through a CONNECT proxy +(https://codeberg.org/ziglang/zig/issues/35294[ziglang/zig#35294]), so the transport +drives `std.crypto.tls.Client` itself. Correctness of the TLS client is assumed. === From C, Idris2 and other languages diff --git a/docs/architecture/THREAT-MODEL.adoc b/docs/architecture/THREAT-MODEL.adoc index 4e0749d4..7b0dd638 100644 --- a/docs/architecture/THREAT-MODEL.adoc +++ b/docs/architecture/THREAT-MODEL.adoc @@ -187,11 +187,14 @@ Every item here is a known limitation, not a hidden one. == Findings made along the way -* *Zig 0.17.0 `std.http.Client` sends HTTPS requests in cleartext through a CONNECT +* *Zig 0.17 `std.http.Client` sends HTTPS requests in cleartext through a CONNECT proxy.* After a successful CONNECT it reuses the plain connection without starting TLS. Observed with a local CONNECT proxy that logged `GET /dns-query HTTP/1.1` as the first tunnelled bytes. That is why the DoH transport is built on `std.crypto.tls.Client` - directly. This should be reported upstream. + directly. The defect is still present in 0.17.1 and on master (47ff97b). Upstream tracks + it as https://codeberg.org/ziglang/zig/issues/35294[ziglang/zig#35294]; the fix, + https://codeberg.org/ziglang/zig/pulls/36484[ziglang/zig#36484], was open and unmerged + on 2026-11-17. * *RFC 8080 §6 examples.* The published RRSIG lines omit the Algorithm field. Re-signing with the published private key reproduces the signatures byte for byte only when the Labels field is 3, but the owner `example.com.` has two labels, which RFC 4035 §5.3.1 diff --git a/docs/developer/ZIG-STD-SURVEY.adoc b/docs/developer/ZIG-STD-SURVEY.adoc index ab638f90..b004d223 100644 --- a/docs/developer/ZIG-STD-SURVEY.adoc +++ b/docs/developer/ZIG-STD-SURVEY.adoc @@ -57,6 +57,9 @@ GOST R 34.11 and SM3 are absent. minimal CONNECT proxy that logged `GET /dns-query HTTP/1.1` as the first tunnelled bytes. The DoH transport therefore does not use `std.http.Client`; it uses `std.http.Reader` and `std.http.Client.Response.Head.parse` for the response only. + Unchanged in 0.17.1 and on master (47ff97b). Upstream: + https://codeberg.org/ziglang/zig/issues/35294[ziglang/zig#35294], fix proposed in + https://codeberg.org/ziglang/zig/pulls/36484[ziglang/zig#36484] (unmerged on 2026-11-17). * No QUIC and no HTTP/2: DNS-over-QUIC (RFC 9250) and HTTP/2 DoH are not implementable from std alone. * No HPKE: Oblivious DoH (RFC 9230) is not implementable from std alone. diff --git a/docs/reports/VERIFICATION.adoc b/docs/reports/VERIFICATION.adoc index 4aec198d..89a8be9a 100644 --- a/docs/reports/VERIFICATION.adoc +++ b/docs/reports/VERIFICATION.adoc @@ -286,7 +286,9 @@ bash scripts/check-variant-drift.sh ../parent-pin . it as missing; either the template republishes it or the mint records the tree hash as the identity to check. * *Zig 0.17.0 `std.http.Client` + CONNECT proxy sends HTTPS requests in cleartext* - (`docs/developer/ZIG-STD-SURVEY.adoc`). Worth an upstream report. + (`docs/developer/ZIG-STD-SURVEY.adoc`). Already tracked upstream as + https://codeberg.org/ziglang/zig/issues/35294[ziglang/zig#35294], with the fix in + https://codeberg.org/ziglang/zig/pulls/36484[ziglang/zig#36484]. * *RFC 8080 §6*: the example signatures carry Labels=3 for a two-label owner, which a validator must reject (`tests/vectors.zig`). * `drill -S` reported success for the DNSKEY RRset of a zone whose signatures had diff --git a/scripts/deed-field.sh b/scripts/deed-field.sh index 57d27c19..914b5603 100755 --- a/scripts/deed-field.sh +++ b/scripts/deed-field.sh @@ -16,7 +16,12 @@ # deed-field.sh --clause DEED PATH the clause, one token per line (for hashing) # deed-field.sh --has DEED PATH exit 0 iff the clause exists # deed-field.sh --find [DIR] print the one *_chora.deed in DIR (default .) -# deed-field.sh --uuid DEED the repo uuid, derived from :repo-uuid +# deed-field.sh --uuid DEED the repo uuid: the body of :repo-uuid #uuid"…" as +# written (#u8 is derived; a #u5 is derived only to +# read an old deed, and check-identity.sh refuses it) +# deed-field.sh --typed DEED PATH KEY like the first form, but a tagged literal keeps its +# tag and quotes: #u5"github.com/o/r" (a plain value +# prints as it does without --typed) # # PATH names clauses below (repo-deed …), slash-separated: `status`, # `agentic/integrity`, `meta/maintenance-axes`. An empty PATH is (repo-deed …) @@ -30,9 +35,15 @@ # literal prints its string: `:repo-uuid #u5"github.com/o/r"` gives # github.com/o/r, the uuid5 name (uuidgen --sha1 --namespace @url --name …). # -# --uuid derives the uuid5 (RFC 9562, URL namespace) of the header :repo-uuid -# name. It uses uuidgen when that supports --sha1, else bun, and exits 2 when -# neither is available or the result is not uuid-shaped: it never guesses. +# --uuid prints the repo id. The chora id is minted once and carried opaquely +# as `:repo-uuid #uuid""` (standards A1 V8, A7 J11), so +# for that form it prints the body as written and NEVER re-derives it: a +# transfer or rename does not change the id (ruling U1). Legacy literals are +# still read, with a note on stderr: #u5"NAME" gives the uuid5 (RFC 9562, URL +# namespace) of NAME, through uuidgen with --sha1, else scripts/uuid5-url.sh, +# else bun; #u8"DOMAIN:NAME" gives the profile C id through scripts/uuid-v8.sh. +# It exits 2 when no tool is available or the result is not uuid-shaped: it +# never guesses. # # Exit: 0 found; 1 clause or key absent (nothing printed); 2 usage error or no # readable deed. --find exits 1 unless exactly one deed is present. @@ -40,7 +51,7 @@ set -euo pipefail mode=value case "${1:-}" in - --list|--clause|--has|--uuid) mode="${1#--}"; shift ;; + --list|--clause|--has|--uuid|--typed) mode="${1#--}"; shift ;; --find) shopt -s nullglob deeds=("${2:-.}"/*_chora.deed) @@ -54,7 +65,7 @@ deed="${1:-}"; path="${2-}"; key="${3:-}" if [ -z "$deed" ] || [ ! -r "$deed" ]; then echo "deed-field.sh: no readable deed: '${deed}'" >&2; exit 2 fi -if { [ "$mode" = value ] || [ "$mode" = list ]; } && [ -z "$key" ]; then +if [[ ( "$mode" = value || "$mode" = typed || "$mode" = list ) && -z "$key" ]]; then echo "deed-field.sh: KEY is required" >&2; exit 2 fi @@ -137,10 +148,13 @@ END { if (tok[t] == ")") { d--; continue } if (d != 0 || tok[t] != "A:" key) continue nx = tok[t + 1] - if (mode == "value") { + if (mode == "value" || mode == "typed") { if (nx == "(" || nx == ")" || nx == "") exit 1 # A tagged literal such as #u5"github.com/o/r" prints its string. - if (nx ~ /^A#[a-z0-9]+$/ && substr(tok[t + 2], 1, 1) == "S") nx = tok[t + 2] + if (nx ~ /^A#[a-z0-9]+$/ && substr(tok[t + 2], 1, 1) == "S") { + if (mode == "typed") { print substr(nx, 2) "\"" substr(tok[t + 2], 2) "\""; exit 0 } + nx = tok[t + 2] + } print show(nx); exit 0 } if (nx != "(") exit 1 @@ -161,6 +175,9 @@ END { uuid5_url() { if uuidgen --sha1 --namespace @url --name x >/dev/null 2>&1; then uuidgen --sha1 --namespace @url --name "$1" + elif [ -f "$(dirname "${BASH_SOURCE[0]}")/uuid5-url.sh" ] && bash "$(dirname "${BASH_SOURCE[0]}")/uuid5-url.sh" x >/dev/null 2>&1; then + # The same derivation repo-init mints with (sha1sum, shasum or openssl). + bash "$(dirname "${BASH_SOURCE[0]}")/uuid5-url.sh" "$1" elif command -v bun >/dev/null 2>&1; then bun -e ' const h = new Bun.CryptoHasher("sha1"); @@ -173,15 +190,31 @@ uuid5_url() { console.log([x.slice(0, 8), x.slice(8, 12), x.slice(12, 16), x.slice(16, 20), x.slice(20)].join("-")); ' "$1" else - echo "deed-field.sh: --uuid needs uuidgen with --sha1, or bun" >&2; return 2 + echo "deed-field.sh: --uuid needs uuidgen with --sha1, sha1sum, shasum, openssl, or bun" >&2; return 2 fi } if [ "$mode" = uuid ]; then - name="$(read_deed value)" || exit $? - id="$(uuid5_url "$name")" || exit 2 - [[ "$id" =~ ^[0-9a-f]{8}-[0-9a-f]{4}-5[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$ ]] \ - || { echo "deed-field.sh: derived uuid is not uuid5-shaped: '$id'" >&2; exit 2; } + lit="$(read_deed typed)" || exit $? + re_uuid='^[0-9a-f]{8}-[0-9a-f]{4}-[58][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$' + case "$lit" in + '#uuid"'*'"') + # The chora id, minted once: print it as written, never re-derive it. + id="${lit#\#uuid\"}"; id="${id%\"}" ;; + '#u5"'*'"') + name="${lit#\#u5\"}"; name="${name%\"}" + # Read only so an old deed can still be looked up: a #u5 in an identity + # field is u5-identity, an error in every mode (A1 v0.4.5 T30, Q2), and + # scripts/check-identity.sh refuses it. + echo "deed-field.sh: :repo-uuid is a #u5 literal, an error under A1 T30 (Q2); derived here only to read an old deed. Write #uuid\"\"." >&2 + id="$(uuid5_url "$name")" || exit 2 ;; + '#u8"'*:*'"') + body="${lit#\#u8\"}"; body="${body%\"}" + id="$(bash "$(dirname "${BASH_SOURCE[0]}")/uuid-v8.sh" "${body%%:*}" "${body#*:}")" || exit 2 ;; + *) echo "deed-field.sh: :repo-uuid is not a #uuid, #u5 or #u8 literal: '$lit'" >&2; exit 2 ;; + esac + [[ "$id" =~ $re_uuid ]] \ + || { echo "deed-field.sh: :repo-uuid is not a lowercase v5 or v8 uuid: '$id'" >&2; exit 2; } printf '%s\n' "$id" exit 0 fi diff --git a/scripts/uuid-v8.sh b/scripts/uuid-v8.sh new file mode 100755 index 00000000..e6df425c --- /dev/null +++ b/scripts/uuid-v8.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: MPL-2.0 +# +# uuid-v8.sh DOMAIN NAME — the ADR-008 profile C UUIDv8 of NAME in DOMAIN, +# the same on every machine and equal to standards `scripts/uuid-v8.js c`: +# the first 16 bytes of SHA-256(DOMAIN ":" NAME), the version nibble set to 8 +# and the variant to 10xx. A repo's chora id is the profile C id of its birth +# path in the domain chora-registry (standards A1 rules V8 and V9, A7 J11); an +# id minted before V9 keeps its gv-clade-index id and is never reminted. +# SHA-256 comes from sha256sum, shasum or openssl, whichever is installed first. +# +# Exit: 0 printed; 2 usage, a DOMAIN that is empty or holds ":", or no +# SHA-256 tool (it never guesses). +set -euo pipefail +[ $# -eq 2 ] || { echo "usage: uuid-v8.sh DOMAIN NAME" >&2; exit 2; } +[[ "$1" =~ ^[!-9\;-~]+$ ]] \ + || { echo "uuid-v8.sh: DOMAIN must be non-empty printable ASCII without ':'" >&2; exit 2; } + +sha256() { + if command -v sha256sum >/dev/null 2>&1; then sha256sum + elif command -v shasum >/dev/null 2>&1; then shasum -a 256 + elif command -v openssl >/dev/null 2>&1; then openssl dgst -sha256 -r + else echo "uuid-v8.sh: needs sha256sum, shasum or openssl" >&2; return 2 + fi +} +h="$(printf '%s:%s' "$1" "$2" | sha256)" || exit 2 +[[ "$h" =~ ^[0-9a-f]{64} ]] || { echo "uuid-v8.sh: the SHA-256 tool printed '$h'" >&2; exit 2; } +printf '%s-%s-8%s-%x%s-%s\n' "${h:0:8}" "${h:8:4}" "${h:13:3}" \ + $(( (16#${h:16:1} & 3) | 8 )) "${h:17:3}" "${h:20:12}" diff --git a/scripts/uuid5-url.sh b/scripts/uuid5-url.sh new file mode 100755 index 00000000..ea3d4ce7 --- /dev/null +++ b/scripts/uuid5-url.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: MPL-2.0 +# Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) +# +# uuid5-url.sh NAME — the UUIDv5 of NAME in the RFC 9562 URL namespace, the +# same on every machine: equal to `uuidgen --sha1 --namespace @url --name NAME` +# (util-linux), which macOS's uuidgen cannot compute (it has no --sha1). +# +# RFC 9562 §5.5: SHA-1 over the namespace's 16 bytes followed by NAME's bytes, +# truncated to 16 bytes, the version nibble set to 5 and the variant to 10xx. +# SHA-1 comes from sha1sum, shasum or openssl, whichever is installed first. +# +# Exit: 0 printed; 2 usage, or no SHA-1 tool (it never guesses). +set -euo pipefail +[ $# -eq 1 ] || { echo "usage: uuid5-url.sh NAME" >&2; exit 2; } + +sha1() { + if command -v sha1sum >/dev/null 2>&1; then sha1sum # NOSONAR shell:S4790: RFC 9562 mandates SHA-1 for UUIDv5 + elif command -v shasum >/dev/null 2>&1; then shasum -a 1 # NOSONAR shell:S4790: RFC 9562 mandates SHA-1 for UUIDv5 + elif command -v openssl >/dev/null 2>&1; then openssl dgst -sha1 -r # NOSONAR shell:S4790: RFC 9562 mandates SHA-1 for UUIDv5 + else echo "uuid5-url.sh: needs sha1sum, shasum or openssl" >&2; return 2 + fi +} +# 6ba7b811-9dad-11d1-80b4-00c04fd430c8, the URL namespace (RFC 9562 §6.6). +h="$( { printf '\x6b\xa7\xb8\x11\x9d\xad\x11\xd1\x80\xb4\x00\xc0\x4f\xd4\x30\xc8' + printf '%s' "$1"; } | sha1 )" || exit 2 +[[ "$h" =~ ^[0-9a-f]{40} ]] || { echo "uuid5-url.sh: the SHA-1 tool printed '$h'" >&2; exit 2; } +printf '%s-%s-5%s-%x%s-%s\n' "${h:0:8}" "${h:8:4}" "${h:13:3}" \ + $(( (16#${h:16:1} & 3) | 8 )) "${h:17:3}" "${h:20:12}" diff --git a/src/stub/doh.zig b/src/stub/doh.zig index 0b07e836..979f4c2a 100644 --- a/src/stub/doh.zig +++ b/src/stub/doh.zig @@ -4,10 +4,12 @@ //! DNS over HTTPS (RFC 8484), HTTP/1.1 over TLS, built directly on //! std.crypto.tls.Client and std.http's response-head parser. //! -//! Why not std.http.Client: in Zig 0.17.0 its HTTPS-through-CONNECT-proxy -//! path does not start TLS inside the tunnel, so the request (here: the DNS -//! query) leaves the proxy in cleartext. That was verified by observation -//! (see SECURITY.md). This transport opens its own connection, optionally +//! Why not std.http.Client: in Zig 0.17.0, 0.17.1 and master (47ff97b) its +//! HTTPS-through-CONNECT-proxy path does not start TLS inside the tunnel, so +//! the request (here: the DNS query) leaves the proxy in cleartext. That was +//! verified by observation (docs/architecture/THREAT-MODEL.adoc, "Findings +//! made along the way"). Upstream: codeberg.org/ziglang/zig issue 35294, fix +//! in pull 36484. This transport opens its own connection, optionally //! through an HTTP CONNECT proxy, and always performs TLS end to end with //! certificate and host-name verification against the configured bundle. //! diff --git a/zig-dnssec_chora.deed b/zig-dnssec_chora.deed index 96a45077..4a599e10 100644 --- a/zig-dnssec_chora.deed +++ b/zig-dnssec_chora.deed @@ -45,13 +45,13 @@ ; 1-formats/deed/mappings/clade-to-repo-deed.adoc and ; meta-ecosystem-to-repo-deed.adoc. ; - ; THE UUID IS DERIVED, NOT ALLOCATED, NOT INVENTED. It is not stored: it is - ; uuid5(namespace = URL, name = the header :repo-uuid string) - ; and anyone can recompute it (gv-clade-index: - ; docs/SPEC-clade-verisim-portal.adoc §Identity Model): - ; uuidgen --sha1 --namespace @url --name "github.com/hyperpolymath/zig-dnssec" - ; The owner is part of the name, so part of the identity: record the owner - ; that is true today, and re-derive if the repo ever moves. + ; THE ID IS MINTED ONCE, NOT INVENTED. The header :repo-uuid is this repo's + ; chora id: the ADR-008 profile C UUIDv8 of its birth path, + ; github.com/hyperpolymath/zig-dnssec, in the domain gv-clade-index + ; (standards A1 rules U1 to U4). Until the registry lists this repo it is + ; written as the #u8 literal; after that, as the registry's opaque #uuid. + ; It is carried opaquely and never re-derived: a transfer or rename does + ; not change it. Do not edit it. ; ; CHOOSE A CLADE. A CLOSED TAXONOMY OF 12 CATEGORIES, NOT AN ABBREVIATION ; SCHEME: the two letters abbreviate the clade's name, never your repo's. @@ -1097,6 +1097,8 @@ "docs/troubleshooting.adoc" "docs/usage.adoc" "scripts/theory-receipts.sh" + "scripts/uuid-v8.sh" + "scripts/uuid5-url.sh" "src/cli/" "src/dnssec/" "src/interface/E2e/" @@ -1153,6 +1155,8 @@ ".github/workflows/sonarqube.yml" ".github/workflows/static-analysis-gate.yml" ".gitignore" + ".machine_readable/arrival-pack/arrival-pack.ncl" + ".machine_readable/arrival-pack/extract.sh" ".machine_readable/coaptation/receipts/latest.toml" ".machine_readable/coaptation/witness-map.ncl" ".machine_readable/compliance/reuse/dep5" @@ -1222,6 +1226,7 @@ "scripts/campaigns/www-bundle.campaign" "scripts/check-no-placeholders.sh" "scripts/check-proofs.sh" + "scripts/deed-field.sh" "scripts/validate-template.sh" "src/README.adoc" "src/interface/Abi/Foreign.idr"