Skip to content

chore: SSRF test sweep — migrate .example hostname fixtures so #381 can land #544

Open

Description

@melvincarvalho

Prerequisite work for #381.

Context

#381 asks for validateExternalUrl to fail closed when both dns.resolve4 and dns.resolve6 return empty arrays. Attempted today (branch issue-381-ssrf-empty-dns-fail-closed, reverted before push).

The 3-line production change is straightforward. The problem: ~10 existing tests bake .example hostnames (alice.example, melvin.example, etc.) past the validator because the current fail-open lets them through. After fail-closed lands, those tests break with:

SSRF protection: Hostname alice.example has no A/AAAA records

Affected test files identified so far (non-exhaustive):

  • test/keys-provision-lws-cid.test.js
  • test/nostr-cid-vm.test.js

(Plus likely others — full count emerged from npm test after the patch.)

Scope

For each affected test, pick one of:

  1. Override DNS via a test seam. A small _dns parameter on validateExternalUrl (mirroring the _validateUrl precedent at src/auth/did-nostr.js:97 — "test seam; production callers MUST NOT override") lets the test supply a stub that returns a known IP for *.example. Most surgical, no fixture change.
  2. Migrate to IP literals. Replace alice.example with 127.0.0.1 or similar in the fixture. Cleaner, but requires re-examining each test's assertions about WebIDs / origins / etc.

Recommendation: option 1 for tests that ARE testing SSRF-adjacent behavior; option 2 for tests where the fake hostname is incidental.

Acceptance

Refs

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions