Repository navigation
Description
Found by job 052's security lens (review-security.md) while porting nip05.proxy; the check is pre-existing at base 4c4f6a6d, not introduced by that job.
crates/nostream-services/src/http.rs:225-246 — is_public_address refuses loopback, unspecified, multicast, fc00::/7, fe80::/10, fec0::/10, and v4-mapped forms (which it unwraps to the v4 check). It does not refuse v6 forms that carry an IPv4 address inside them:
64:ff9b::/96— the well-known NAT64 prefix (64:ff9b::a9fe:a9feis169.254.169.254);2002::/16— 6to4 (v4 in bits 16–47);2001::/32— Teredo.
On a host that routes those prefixes (this workspace already runs IPv6-only + NAT64 — docs/infra/nostream-dev-nat64.md), a hostname resolving to one of them passes is_public_address and the fetch connects to the wrapped address. NIP-05 documents are author-controlled (nip05.domain in a kind-0 event), so this is the SSRF class the guard exists to stop, reachable against metadata and loopback services that a NAT64/DNS64 network publishes to v6 clients.
Acceptance
is_public_address(or a helper beside it) refuses64:ff9b::/96,2002::/16and2001::/32by embedding-form, not by hostname: a unit test asserts each prefix's v4 payload is extracted and checked withis_public_v4, so64:ff9b::a9fe:a9fe,2002:a9fe:a9fe::1and a Teredo address wrapping10.0.0.1are refused while64:ff9b::808:808(8.8.8.8) is allowed.- The test fails on the base implementation and its inversion (drop one prefix arm) reddens it.
- The NIP-05 fetch path and the admin reverify path both inherit it — one call site each, asserted by the existing guard test plus the new table.
- If a prefix cannot be refused without breaking a legitimate use, say which and why in the PR; do not silently narrow the guard.
Out of scope: the nip05.proxy tunnel's own behaviour (job 052), which re-checks every hop through the same function and so inherits this fix.
For whoever picks this up
- What is wrong: A NIP-05 hostname that resolves to an IPv6 address carrying an IPv4 address inside it (NAT64
64:ff9b::/96, 6to42002::/16, Teredo2001::/32) passes the public-address guard, so the fetch connects to the loopback, private or metadata address it wraps. - Done looks like:
is_public_address(or a helper it calls, likeis_public_v4) extracts the IPv4 address embedded in each of the three prefixes, inverting Teredo's client field, and applies the existing v4 rules. A new testembedded_ipv4_v6_forms_are_refusedin thetestsmodule ofcrates/nostream-services/src/http.rsasserts64:ff9b::a9fe:a9fe,2002:a9fe:a9fe::1and a Teredo address wrapping10.0.0.1(e.g.2001:0:4136:e378:8000:63bf:f5ff:fffe) are refused, while64:ff9b::808:808is allowed; it fails against the current predicate. Both consumers,GuardedResolver::resolve()andnip05_egress::resolve_checked(), call the same function, so the one table covers both. - Where it lives:
crates/nostream-services/src/http.rs—is_public_address(), with the v4 rules inis_public_v4(); called fromGuardedResolver::resolve()andis_redirect_target_safe()in the same file, and fromresolve_checked()incrates/nostream-services/src/nip05_egress.rs. - Intent: fix(nip05): refuse a verification host that resolves to a private address #1278 — the guard exists because an author-controlled NIP-05 domain must not reach loopback, private ranges or cloud metadata; this is the same SSRF through an IPv6 encoding.
Activity
chappie-daemon commentedon Dec 6, 2026
Job 055 opened at
2fc08dff; recon running (worktreefactory/055-nip05-embedded-ipv4). Expected cost $2.20.chappie-daemon commentedon Dec 6, 2026
Build started: private
embedded_ipv4helper wired into the v6 arm ofis_public_address; the rule is "refuse iff the embedded v4 is not public", with public-embedded forms kept allowed. Oracle iscargo test -p nostream-services http::23 → 24 passed.chappie-daemon commentedon Dec 6, 2026
Review round 1: security lens PASS (three residual encodings measured not exploitable on this host, follow-up to be filed); code lens running as the gate; architecture, performance, ux and ui stood down on measured counts (
review-plan.json).chappie-daemon commentedon Dec 6, 2026
Shipped as
b323c67d3e2a1a8b05677fbd647909217f56e5db(PR #1421, merge commit; branch head9c5c7629, two commits on base2fc08dff).What landed:
embedded_ipv4(Ipv6Addr) -> Option<Ipv4Addr>besideis_public_address— NAT6464:ff9b::/96(full /96, low 32 bits), 6to42002::/16(bits 16–47, SLA ignored), Teredo2001::/32(client low 32 bits inverted) — judged by the existingis_public_v4. The rule is the embedded address's, never the prefix's:64:ff9b::808:808and64:ff9b:1::a9fe:a9festay allowed while64:ff9b::a9fe:a9feand the 6to4/Teredo equivalents wrapping private, loopback, CGN, benchmarking,0/8or broadcast addresses are refused.Evidence:
cargo test -p nostream-services http::24 passed (23 at base); three executed inversions red→green (builder's 6to4 arm; code lens's NAT64 arm, Teredo!, and the/96guard); clippy both CI forms and fmt clean;Rust Checksgreen on the merge.Reviews: code (gate) and security lenses both PASS. The security lens measured three residual encodings (IPv4-compatible
::/96, IPv4-translated::ffff:0:0:0/96, shifted RFC 6052 NAT64 prefixes) as not exploitable on this host and they are filed as #1420 rather than silently declared impossible.