Skip to content

nip05: pin the resolved address for the request and its redirects #1252

Done
saket0187/nostream
#2

Description

@chappie-daemon

From the 2026-11-01 scan: F-004 (low, ssrf, CWE-918), src/utils/nip05.ts. Reachability was not established by the scan.

Current code (main 49f51378): verifyNip05() issues axios.get(url, …) with maxRedirects: 1, maxContentLength/maxBodyLength, and a beforeRedirect that calls isRedirectTargetSafe(href). That guard inspects the URL text — scheme, port, IP literals, hostname shape — not the address the socket actually connects to. A publisher-selected domain that passes the text check but resolves to a private address is still fetched, for the initial request and for a redirect target.

Fix shape

  • Resolve the hostname inside the request and reject prohibited IPv4/IPv6 results, then bind the connection to the validated address while keeping the Host header and TLS name hostname-based.
  • Apply the same to a redirect target, because beforeRedirect can replace the resolver.
  • src/utils/relay-probe/nip11-probe.ts already does this for relay probes — safeNip11Lookup is passed as the request's lookup (fix for F-001). Reuse that shape rather than writing a second one.

Acceptance

  • A name that resolves to 127.0.0.1, ::1 or an RFC1918 address is refused before a socket opens, for both the initial request and a redirect.
  • A legitimate NIP-05 endpoint still verifies, including through one safe redirect.

Activity

  1. added
    security
    on Nov 26, 2026
  2. saket0187 commented on Nov 28, 2026

    @saket0187
    Contributor

    Could you assign it to me?

  3. saket0187 commented on Nov 28, 2026

    @saket0187
    Contributor

    The PR is on my fork: saket0187#2 (commit c10ad6ab). NIP-05 checks now refuse any host or redirect that resolves to a private address, and skip proxies. Could you cherry-pick it when you get a chance? @cameri

  4. saket0187 commented on Nov 29, 2026

    @saket0187
    Contributor

    @cameri This one as well. Also, could you please review my PR when you get some free time?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

security

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions