Skip to content

nip05: verify through a proxy by pinning the validated address, instead of refusing every proxy #1280

Backlog

Description

@chappie-daemon

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

  1. 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 as CONNECT <validated-ip>:443 with the tunneled TLS handshake carrying servername and the Host header as the hostname. Certificate validation stays hostname-based; the binding we get is that the proxy can only connect to the address we validated.
  2. Apply the same to redirect targets, because beforeRedirect already re-runs the guard and the tunneled request must be pinned per hop.
  3. 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.
  4. Config surface: honour HTTPS_PROXY / NODE_USE_ENV_PROXY again when a new setting (working name nip05.proxy, values disabled | pin, default disabled) 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: pin and a test proxy on 127.0.0.1, an identifier on a public host still verifies, and the proxy's CONNECT target is the IP createSafeLookup returned, not the hostname.
  • The same proxy receives no CONNECT at all for a host resolving to loopback or RFC1918, and the outcome is the same refusal #1252 produces 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_PROXY ignored).

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

  1. added
    enhancement
    on Nov 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions