Repository navigation
Description
Follow-up of #1252 / PR #1278. The fix there resolves every NIP-05 host locally and refuses a private address, which forces proxy: false and its own https.Agent on the verification request — a proxy resolves the name itself, so the check never runs. The trade-off is stated in CONFIGURATION.md under nip05.mode: a relay that reaches the internet only through an egress proxy can no longer verify NIP-05 identifiers at all. This issue is to give that relay a supported path back, without handing name resolution — and so the address check — to the proxy.
Shape
- Resolve and pin locally, then tunnel to the address. The hostname is resolved by
createSafeLookup, every address is checked, and the request is sent to the proxy asCONNECT <validated-ip>:443with the tunneled TLS handshake carryingservernameand theHostheader as the hostname. Certificate validation stays hostname-based; the binding we get is that the proxy can only connect to the address we validated. - Apply the same to redirect targets, because
beforeRedirectalready re-runs the guard and the tunneled request must be pinned per hop. - Say so when the proxy refuses it. A proxy that rejects an IP-literal
CONNECT(or returns a non-2xx) makes verification fail with a reason naming the proxy and the host, never a silent fallback to proxy-side resolution. - Config surface: honour
HTTPS_PROXY/NODE_USE_ENV_PROXYagain when a new setting (working namenip05.proxy, valuesdisabled|pin, defaultdisabled) enables it, so the safe behaviour stays the default and the operator opts into the pinned path knowingly.
Alternative considered and rejected: let the proxy resolve and trust the network's egress policy. The relay's own network is exactly what the check protects — a proxy commonly sits inside it — so this only moves the SSRF one hop.
Acceptance
- With
nip05.proxy: pinand a test proxy on127.0.0.1, an identifier on a public host still verifies, and the proxy'sCONNECTtarget is the IPcreateSafeLookupreturned, not the hostname. - The same proxy receives no
CONNECTat all for a host resolving to loopback or RFC1918, and the outcome is the same refusal#1252produces today. - A redirect to such a host is refused with the proxy still receiving nothing for it.
- TLS validation still fails against a certificate that does not match the hostname, proving SNI/servername is the host and not the pinned IP.
- With the setting absent or
disabled, behaviour is byte-identical to PR fix(nip05): refuse a verification host that resolves to a private address #1278 (no proxy consulted,HTTPS_PROXYignored).
Where: src/utils/nip05.ts, src/utils/safe-lookup.ts, CONFIGURATION.md. Tests belong next to the six real-connection cases added in #1252.
Activity