Summary
NLTK contains a server-side request forgery vulnerability in its URL-fetching and downloader pathways when an HTTP proxy is configured. An attacker who can provide a URL to these components may cause the proxy to request internal services that local hostname validation would otherwise reject, potentially exposing internal resources or retrieving attacker-controlled package metadata and content.
Affected context
The issue can occur in NLTK deployments that use nltk.pathsec.urlopen or callers such as nltk.data.load and nltk.downloader.Downloader, while an HTTP proxy is configured. Local validation may approve a public destination, but inherited proxy-handler behavior can cause the proxy to perform the actual request without applying equivalent destination validation.
Exploit preconditions
- Attack surface: NLTK URL-fetching, data-loading, or downloader functionality
- Required access: Ability to supply or influence a URL processed by an affected NLTK component
- Environmental condition: An HTTP proxy must be configured and reachable by the NLTK process
- Trigger point: The proxied HTTP or HTTPS request performed after local hostname validation
- Why exploitation is possible: The application validates the original requested hostname, while the proxy can forward the request to a different internal destination that is not re-validated
Why this happens
The vulnerability results from a mismatch between application-side URL validation and proxy-side request execution. NLTK validates the requested hostname locally, but proxy-handler inheritance disables the safe HTTP and HTTPS handlers, allowing the configured proxy to resolve and contact a destination that was not covered by the original validation. This is a form of CWE-918: Server-Side Request Forgery, where attacker-influenced server requests can reach unintended internal or protected resources.
Potential impact
- An attacker could disclose HTTP resources available only from internal networks
- An attacker could access loopback-only or otherwise restricted services
- An attacker could provide forged downloader indexes
- NLTK could install attacker-chosen package or data content
- Applications could experience data poisoning or supply-chain compromise
General mitigation guidance
Mitigation generally focuses on enforcing destination controls at the point where the final network request is made, including when traffic passes through a proxy.
Common defensive patterns include:
- Using request handling that preserves safe HTTP and HTTPS validation for proxied traffic
- Applying allowlists for schemes, hosts, ports, resolved addresses, and redirect destinations
- Blocking loopback, link-local, private, and other reserved address ranges after resolution
- Separating downloader permissions from general application privileges
- Treating downloaded indexes and package content as untrusted until integrity and provenance checks succeed
- Restricting proxy egress and preventing access to internal administrative services
- Avoiding automatic installation or execution of content retrieved from untrusted endpoints
How teams detect issues like this
Organizations can look for SSRF exposure through:
- Static analysis of URL validation followed by proxy-aware network requests
- Code review signals such as validation of the original hostname without validation after redirects, resolution, or proxy forwarding
- Tests covering loopback, private, link-local, reserved, and unusual address representations
- Configuration audits for unrestricted outbound proxies and downloader permissions
- Network monitoring for application processes contacting internal address ranges through proxies
- Policy enforcement requiring destination allowlists and content integrity validation
Automated security review tools may help identify unsafe URL-fetching patterns, but runtime proxy behavior should also be tested.

