PyPI: nltk
CVE-2026-12075
Safety vulnerability ID: SFTY-20260731-71411
Affected versions of the nltk package are vulnerable to Server-Side Request Forgery (SSRF) due to a DNS rebinding flaw in its hostname validation logic. The validate_network_url() function in nltk.pathsec resolves and checks a hostname's IP address, but urlopen() then hands the raw hostname to urllib, which independently re-resolves it a second time at connect time through socket.getaddrinfo, so the address that gets validated is never the address that actually gets connected to, and this gap persists even with nltk.pathsec.ENFORCE enabled. An attacker who controls DNS for a hostname can return a public IP address during the validation lookup and a loopback or internal IP address during the connection lookup, allowing functions such as nltk.download and nltk.data.load to fetch and return the full response from internal-only services, including the cloud instance metadata endpoint, which can expose IAM credentials.
Overview
Natural Language Toolkit (NLTK): DNS-rebinding SSRF filter bypass in nltk.pathsec.urlopen (nltk.download / nltk.data.load) defeats ENFORCE mode
Advisory
nltk – Server-Side Request Forgery (SSRF)
How to Fix
Mitigation and Workarounds
---
Vulnerable Functions
Functions linked to known vulnerabilities.
Verified by Safety
Our Cybersecurity Intelligence Team reviewed this vulnerability. We combine public data with our own research to find issues not yet reported to public sources.
Learn more
