Skip to content

Reject WHOIS referral targets that resolve to private/internal addresses (SSRF, #312) - #321

Merged
richardpenman merged 1 commit into
richardpenman:masterfrom
spartan8806:fix/ssrf-referral-filtering
Jul 11, 2026
Merged

richardpenman merged 1 commit into
richardpenman:masterfrom
spartan8806:fix/ssrf-referral-filtering

Conversation

@spartan8806

Copy link
Copy Markdown
Contributor

Addresses the SSRF item in #312 (CWE-918).

findwhois_server extracts the referral host from the untrusted "Whois Server:"
field of an upstream response, and whois() then connects to it. Without
validation, a malicious or compromised WHOIS server can redirect the client to
internal services — e.g. cloud metadata endpoints like 169.254.169.254.

This adds _is_safe_referral_host(), which resolves the referral host and skips
the referral if any resolved address is private / loopback / link-local /
reserved / multicast / unspecified. Only server-provided referral hosts are
checked — the caller's own chosen server is untouched.

Note on approach: this is a resolve-then-connect check, so a DNS-rebinding
attacker could still bypass it. Pushing the check into _connect on the resolved
sockaddr would close that fully — happy to adjust to whichever you prefer.

Refs #312

…ses (SSRF, richardpenman#312)

findwhois_server extracts the referral host from the untrusted 'Whois Server:' field of an upstream response, and whois() then connects to it. Without validation a malicious/compromised server can redirect the client to internal services (SSRF) such as cloud metadata endpoints (e.g. 169.254.169.254). Adds _is_safe_referral_host(), which resolves the referral host and skips the referral if any resolved address is private/loopback/link-local/reserved/multicast/unspecified. Only referral hosts are checked; the caller's chosen server is untouched. Note: this is a resolve-then-connect check, so a DNS-rebinding attacker could still bypass it -- pushing the check into _connect on the resolved sockaddr would close that fully, happy to adjust to your preference. Refs richardpenman#312.
@richardpenman
richardpenman merged commit 48bdbc7 into richardpenman:master Jul 11, 2026
5 checks passed
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