GitHub advisory · PyPI
NLTK: pathsec SSRF protection can be bypassed when a proxy is configured
Description
Current NLTK source reopens SSRF in proxied environments. pathsec.urlopen() validates the requested hostname locally, but once proxy inheritance is enabled the real fetch is performed by the proxy rather than by the validated direct-connect socket path.
nltk.pathsec.urlopen, nltk.data.load, nltk.downloader.Downloader.index, nltk.downloader.Downloader.downloadv3.10.0-rc2; published 3.9.4 was a negative control and did not reproduce._SafeHTTPHandler and _SafeHTTPSHandler, so the validated hostname no longer matches the actual egress destination.The hardened direct path pins the validated numeric destination IP before opening the socket. The proxied branch instead copies ProxyHandler instances from the global opener, marks the request as proxied, and skips the pinned handlers. I confirmed that a validated public URL can be fetched from a loopback-only internal service through the proxy path via pathsec.urlopen(), nltk.data.load(), Downloader.index(), and Downloader.download().
Preconditions
pathsec to keep network fetches SSRF-safe.Steps
pathsec.urlopen() or nltk.data.load() on the public URL and observe the internal response is returned.Downloader(server_index_url=...), call index() and download(), and observe internal-only content is parsed and installed.Minimal reproducible excerpt
{'urlopen': 'PROXY_TEXT_SECRET', 'data_load': 'PROXY_TEXT_SECRET', 'downloaded_file':…
Manual fix · PyPI
pip install --upgrade "nltk>=3.10.3"Sources