Skip to content

Harden SSRF guard against redirect, IPv6-mapped, and alt-encoding byp…#42

Open
skull463 wants to merge 1 commit into
mskayyali:mainfrom
skull463:harden-ssrf-guard
Open

Harden SSRF guard against redirect, IPv6-mapped, and alt-encoding byp…#42
skull463 wants to merge 1 commit into
mskayyali:mainfrom
skull463:harden-ssrf-guard

Conversation

@skull463
Copy link
Copy Markdown
Contributor

…asses

Follow-up to 60c029f (which fixed #14's reported fda.gov case).

  • Re-validate every hop in fetchUrlMeta (redirect: manual, MAX_HOPS=5) so a public URL cannot 302 to http://169.254.169.254/ etc.
  • Parse IPv4 literals in all Node-accepted forms (dotted-decimal, dotted-octal, dotted-hex, packed integer, short forms) so http://2130706433/ and http://0x7f.0.0.1/ are blocked.
  • Unwrap IPv4-mapped/compatible IPv6 (::ffff:127.0.0.1) and apply IPv4 rules so loopback/metadata/RFC1918 cannot be reached via IPv6 syntax.
  • Block the IPv6 unspecified address ::.
  • Strip trailing dots during hostname normalization so 'localhost.' cannot bypass the named-host check.

The #14 fix (fc/fd prefix checks only on IPv6 literals) is preserved. No new dependencies.

…asses

Follow-up to 60c029f (which fixed mskayyali#14's reported fda.gov case).

- Re-validate every hop in fetchUrlMeta (redirect: manual, MAX_HOPS=5)
  so a public URL cannot 302 to http://169.254.169.254/ etc.
- Parse IPv4 literals in all Node-accepted forms (dotted-decimal,
  dotted-octal, dotted-hex, packed integer, short forms) so
  http://2130706433/ and http://0x7f.0.0.1/ are blocked.
- Unwrap IPv4-mapped/compatible IPv6 (::ffff:127.0.0.1) and apply
  IPv4 rules so loopback/metadata/RFC1918 cannot be reached via
  IPv6 syntax.
- Block the IPv6 unspecified address ::.
- Strip trailing dots during hostname normalization so 'localhost.'
  cannot bypass the named-host check.

The mskayyali#14 fix (fc/fd prefix checks only on IPv6 literals) is preserved.
No new dependencies.
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.

Fix SSRF guard: IPv6 ULA checks falsely block legitimate hostnames

1 participant