Repository navigation
Description
Surfaced during Copilot review of #379 (cors-proxy).
`validateExternalUrl()` in `src/utils/ssrf.js` swallows individual record-type lookup failures with `.catch(() => [])` and only fails closed if the outer try/catch fires. The path that's not covered: both `dns.resolve4` and `dns.resolve6` succeed but return empty arrays, or both return empty due to transient DNS issues.
In that case the loop iterates over zero IPs, finds no private one, returns `{ valid: true }`. The subsequent `fetch()` then resolves the hostname via the OS resolver, which may pick up a different (possibly private) address. SSRF check is bypassed.
Reproduction sketch
- Hostname with no A/AAAA but a CNAME chain that the OS follows but Node's `dns.resolve4/6` doesn't (rare but legal)
- Forced DNS failure on resolve4/6 while the OS cache still has an entry
- Adversarial nameserver returning empty records to the validating resolver but a real address to the OS resolver
Suggested fix
In `validateExternalUrl()`, when the host is a hostname (not an IP) and DNS lookup is required, treat `addresses.length === 0 && addresses6.length === 0` as failure (return `{ valid: false, error: ... }`).
```js
const addresses = await dns.resolve4(hostname).catch(() => []);
const addresses6 = await dns.resolve6(hostname).catch(() => []);
if (addresses.length === 0 && addresses6.length === 0) {
return { valid: false, error: `No A/AAAA records for ${hostname}`, url: null };
}
```
Scope / blast radius
`validateExternalUrl` / `safeFetch` are called from:
- `src/handlers/cors-proxy.js` (the new proxy in cors-proxy: Phase 1 — WAC-gated proxy for browser apps (#378) #379)
- ActivityPub federation outbound calls (`src/ap/*`)
- Image / media proxying (if any)
- Webledger lookups
- Any future SSRF-sensitive callsite
Every consumer is by definition SSRF-sensitive, so failing closed on lookup-empty is the correct default. The risk of breaking legitimate hostnames with quirky DNS configs is small — those calls were going to fail at `fetch()` anyway.
Refs
- cors-proxy: Phase 1 — WAC-gated proxy for browser apps (#378) #379 (PR) — the cors-proxy work that surfaced this
- Copilot review thread on cors-proxy: Phase 1 — WAC-gated proxy for browser apps (#378) #379, comment id 3209275355
- `src/utils/ssrf.js` lines ~109-125 (the resolve4/resolve6 block)
Activity
Address copilot pass 3 on #400
Address copilot pass 13 on #400
Address copilot pass 14 on #400
Address copilot pass 16 on #400
auth: NIP-98 → WebID via verificationMethod lookup (#399) (#400)
melvincarvalho commentedon Jun 9, 2026
Attempted today (2026-06-09): wider scope than expected, sweep filed as #544
Tried the fix on a branch (since reverted, never pushed). The production change is 3 lines as proposed, but ~10 existing tests bake
.examplehostnames past the validator and break on fail-closed:Affected at least:
test/keys-provision-lws-cid.test.jstest/nostr-cid-vm.test.jsThe clean path forward needs a sweep — either a
_dnstest seam (matching the_validateUrlprecedent atsrc/auth/did-nostr.js:97) or migrating fixtures to IP literals. Filed as #544 so the implementation work can be tracked discretely; this issue stays open as the security bug it actually is.