Skip to content

Fix SSRF validation for domains with mixed IPv4 and IPv6 addresses - #53

Open
j0k3r wants to merge 2 commits into
masterfrom
ipv6-validation-fix
Open

j0k3r wants to merge 2 commits into
masterfrom
ipv6-validation-fix

Conversation

@j0k3r

@j0k3r j0k3r commented Nov 24, 2026

Copy link
Copy Markdown
Owner

The plugin previously checked only IPv4 addresses. A domain could therefore pass validation with a public IPv4 address while the HTTP client connected to a private IPv6 address.

This PR:

  • Uses the system resolver to check both IPv4 and IPv6 addresses via socket_addrinfo_lookup, which requires the PHP sockets extension. Unlike dns_get_record, this also respects local hosts-file entries and the system's name resolution configuration.
  • Uses the system resolver to check both IPv4 and IPv6 addresses (using socket_addrinfo_lookup, that's why the PHP sockets extension is now required which is a better solution that using dns_get_record).
  • Rejects a domain if any resolved address is blocked.
  • Requires every resolved address to match the IP allowlist when one is configured.
  • Adds IPv6 address and CIDR support, including checks for private networks and IPv6 formats that can embed IPv4 addresses.
  • Adds repeatable tests without relying on public DNS.
  • Updates the documentation and CI configuration.

It addresses the IPv4/IPv6 validation issue reported in Snyk and discussed in #8.

The plugin previously checked only IPv4 addresses. A domain could therefore pass validation with a public IPv4 address while the HTTP client connected to a private IPv6 address.

This PR:
- Uses the system resolver to check both IPv4 and IPv6 addresses via `socket_addrinfo_lookup`, which requires the PHP `sockets` extension. Unlike `dns_get_record`, this also respects local hosts-file entries and the system's name resolution configuration.
- Uses the system resolver to check both IPv4 and IPv6 addresses (using `socket_addrinfo_lookup`, that's why the PHP `sockets` extension is now required which is a better solution that using `dns_get_record`).
- Rejects a domain if any resolved address is blocked.
- Requires every resolved address to match the IP allowlist when one is configured.
- Adds IPv6 address and CIDR support, including checks for private networks and IPv6 formats that can embed IPv4 addresses.
- Adds repeatable tests without relying on public DNS.
- Updates the documentation and CI configuration.

It addresses the IPv4/IPv6 validation issue reported in [Snyk](https://security.snyk.io/vuln/SNYK-PHP-J0K3RHTTPLUGSSRFPLUGIN-8400871) and discussed in #8.
@j0k3r

j0k3r commented Nov 24, 2026

Copy link
Copy Markdown
Owner Author

Can you have a look @jtojnar & @Rudloff?

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.

1 participant