Junglewise Threat Intelligence

NLTK SSRF fail-open in validate_network_url via DNS resolution failure

Severity: medium · CVSS 5.3 · Published 2026-08-22

Executive brief

NLTK is a widely-used Python library for natural language processing that includes network security validation functions. The library's validate_network_url() function is designed to prevent server-side request forgery (SSRF) attacks by validating that URLs only point to allowed IP addresses. However, when DNS resolution fails, the validation logic silently succeeds without performing any IP checks, allowing an attacker to bypass these protections and reach restricted network resources such as cloud metadata endpoints (e.g., AWS IMDS at 169.254.169.254) to steal credentials or configuration data.

Technical details

The vulnerability is a classic fail-open logic error in the validate_network_url() function within nltk/pathsec.py. When the _resolve_hostname() helper function encounters an OSError or ValueError during socket.getaddrinfo() DNS resolution (lines 193-234), it returns an empty list rather than raising an exception. Subsequently, the validation loop in validate_network_url() iterates over this empty list with no else/fallback check, causing the function to return successfully without performing any IP address validation. An attacker can exploit this by triggering temporary DNS resolution failures (via network conditions or misconfiguration) or employing DNS rebinding techniques to poison cached DNS entries. This allows arbitrary URL requests to bypass security checks and access restricted resources like AWS IMDS metadata endpoints. The correct behavior is fail-closed: if DNS resolution fails, the URL should be rejected. A patch is available in NLTK 3.10.0 and later; users of NLTK 3.9.4 and earlier are vulnerable.

Affected products

  • NLTK Project NLTK <= 3.9.4

Timeline

  • 2026-08-07: disclosed: Vulnerability published by NLTK maintainers as GHSA-3gqm-fcw5-w839
  • 2026: patched: Fixed in NLTK version 3.10.0

References

Related threats