Skip to content

fix: prevent SSRF via /cors endpoint by blocking private/reserved IPs#4084

Merged
khassel merged 1 commit intoMagicMirrorOrg:developfrom
KristjanESPERANTO:cors
Apr 3, 2026
Merged

fix: prevent SSRF via /cors endpoint by blocking private/reserved IPs#4084
khassel merged 1 commit intoMagicMirrorOrg:developfrom
KristjanESPERANTO:cors

Conversation

@KristjanESPERANTO
Copy link
Copy Markdown
Collaborator

Resolve target hostname before proxying and reject any address that is not globally routable (loopback, RFC 1918, link-local, etc.) using ipaddr.js and dns.lookup().

Resolve target hostname before proxying and reject any address that is
not globally routable (loopback, RFC 1918, link-local, etc.) using
ipaddr.js and dns.lookup().
@khassel khassel merged commit 03f2689 into MagicMirrorOrg:develop Apr 3, 2026
9 checks passed
@KristjanESPERANTO KristjanESPERANTO deleted the cors branch April 3, 2026 17:15
khassel pushed a commit that referenced this pull request Apr 4, 2026
PR #4084 blocked SSRF by checking the IP before `fetch()` — but
`fetch()` resolves DNS again on its own. With DNS rebinding (TTL=0,
alternating IPs) an attacker can slip a private IP through between check
and connection.

Fix: resolve DNS once, validate, pin the validated IP for the
connection.

No second DNS query → no rebinding window. `isPrivateTarget()` is gone,
code is shorter than before.

Not a likely attack for a typical MagicMirror setup, but it doesn't add
complexity so there's no reason not to close the gap.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants