---
id: "CVE-2026-63311"
kind: "vulnerability"
aliases: ["CVE-2026-63311", "GHSA-3gqm-fcw5-w839"]
title: "NLTK: SSRF Fail-Open in validate_network_url() via DNS Resolution Failure"
severity: "medium"
cvss: 6.9
epss: 0.00334
exploited: false
status: "open"
category: "package"
products: [{"name": "nltk", "fixed": ["3.10.0"], "affected": "<= 3.9.4", "ecosystem": "pypi"}, {"name": "nltk", "fixed": ["3.10.0"], "affected": "< 3.10.0", "ecosystem": "vendor"}]
ecosystems: ["pypi", "vendor"]
tags: ["cloud", "cwe-918", "nltk", "package", "pypi", "python"]
not_affected_if: ["fixed-urls", "local-data-only"]
published_at: "2026-08-22T15:16:19+00:00"
first_seen_at: "2026-10-27T08:02:10+00:00"
updated_at: "2026-10-27T08:31:47+00:00"
sources: [{"source": "ghsa", "url": "https://github.com/advisories/GHSA-3gqm-fcw5-w839", "first_seen_at": "2026-10-27T08:02:10+00:00"}, {"source": "nvd", "url": "https://nvd.nist.gov/vuln/detail/CVE-2026-63311", "first_seen_at": "2026-10-27T08:31:47+00:00"}]
---

# NLTK: SSRF Fail-Open in validate_network_url() via DNS Resolution Failure

NLTK 3.9.4 and earlier skip the private-address check in validate_network_url() when DNS lookup fails, so the request still goes out. An attacker who can make an application fetch a URL can reach internal services such as cloud metadata endpoints.

_Summary, check and fix written by a model from the sources; labelled as such._

## Affected

- pypi:nltk affected <= 3.9.4 fixed 3.10.0
- vendor:nltk affected < 3.10.0 fixed 3.10.0

## How to check

- Run `pip show nltk` and check whether the version is `3.9.4` or earlier.
- Search application code for calls to nltk network download or URL-loading paths that take user-supplied URLs.

## Fix

- Upgrade `nltk` to `3.10.0`.
- Until upgraded, do not pass user-controlled URLs into NLTK network functions.

## Timeline

- 2026-10-27T08:02:10+00:00 ghsa https://github.com/advisories/GHSA-3gqm-fcw5-w839
- 2026-10-27T08:31:47+00:00 nvd https://nvd.nist.gov/vuln/detail/CVE-2026-63311

## From the sources

There is an SSRF vulnerability in NLTK 3.9.4's network URL validation. The validate_network_url() function in nltk/pathsec.py fails open when DNS resolution returns an error.

The _resolve_hostname() helper at lines 193-234 catches OSError and ValueError during socket.getaddrinfo() and returns an empty list []. When this happens, the validation loop in validate_network_url() iterates over nothing (for addr in resolved: ... never executes), with no else/fallback check. The function returns normally, and urlopen() proceeds to make the request without any IP validation.

This means:
1. If DNS is temporarily unavailable, ALL SSRF protections are disabled
2. DNS rebinding attacks bypass the check after the LRU cache entry expires
3. In environments with unreliable resolvers, the protection is permanently bypassed

PoC:
```python
import nltk.pathsec
import unittest.mock

# Simulate DNS failure
with unittest.mock.patch('socket.getaddrinfo', side_effect=OSError('DNS unavailable')):
    # This SHOULD raise but doesn't -- fails open
    nltk.pathsec.validate_network_url('http://169.254.169.254/latest/meta-data/')
    # Returns normally, allowing SSRF to cloud metadata
```

The correct behavior is fail-closed: if DNS resolution fails, the URL should be REJECTED (not allowed). The function should raise an exception or return a failure status when _resolve_hostname() returns an empty list.

This is distinct from CVE-2024-39705 (which addressed pickle deserialization) and CVE-2026-33236 (which addressed XML path traversal). This finding targets the newly-added pathsec.py security layer introduced to fix those earlier issues.

Suggested fix: Add an explicit check after _resolve_hostname() returns: if the result is empty, raise a SecurityError. Never allow a URL request to proceed when IP validation was impossible.

CVSS Note: The CVSS use SC:H (High subsequent confidentiality) because the advisory explicitly identifies cloud metadata endpoints (169.254.169.254) as an attack target. Access to AWS IMDS or GCP metadata exposes credentials or service account tokens, which constitutes High-impact disclosure on downstream systems. This justifies SC:H over NVD's SC:L.

---

_Free to read at a human pace. An API with keys and an MCP server are in preparation; early access: hello@infrastack.ai_
