All vulnerabilities
CVE-2026-62388GHSA-p3m8-78j2-g5p3PYSEC-2026-3722

NLTK: Default ENFORCE=False Disables All pathsec Security Controls

nltk nltkpipLibraries & packages
CVSS
8.7High
ExploitationPublic exploit codeCISA's assessment says proof of concept code is public, assessed 26 Aug 2026. Not in the KEV catalogCISA via CVE List
Exploit odds (EPSS)0.51%Chance of exploitation activity in the next 30 days, higher than 43% of CVEs. Scored 26 Oct 2026FIRST EPSS
Fixed in3.10.0Fixed versionGitHub
Published22 Aug 2026Updated 27 Oct 2026CVE List

What fixes it

A fixed version on one release line is not the upgrade target for every line. Check your exact version and any vendor backports.

Description

NLTK's pathsec.py security module defaults to ENFORCE=False (line 24), which means all 8 security validation functions only emit RuntimeWarning instead of raising exceptions when violations are detected.

The pathsec module was introduced as the fix for CVE-2024-39705 (arbitrary code execution via pickle) and CVE-2026-0846 (path traversal). However, with ENFORCE=False as the default:

  1. pathsec.open('/etc/passwd') succeeds (reads the file, emits warning)
  2. pathsec.validate_network_url('http://169.254.169.254/...') succeeds (warning only)
  3. pickle.loads() via nltk.data.load() proceeds despite unsafe source (warning only)

Every security gate follows the same pattern:

ENFORCE = os.environ.get('NLTK_PATHSEC_ENFORCE', '').lower() in ('1', 'true', 'yes')

def validate_something(path):
    if is_violation(path):
        if ENFORCE:
            raise SecurityError('...')  # Only raised when env var is set
        else:
            warnings.warn('...', RuntimeWarning)  # Default: warning only
    # Execution continues regardless

This means the security remediations for CVE-2024-39705 and CVE-2026-0846 are effectively disabled by default. Any user who installed NLTK 3.9.x expecting the security fixes to be active is still vulnerable unless they manually set NLTK_PATHSEC_ENFORCE=1.

PoC:

import nltk.pathsec
import warnings

# Show that ENFORCE is False by default
print(f'ENFORCE = {nltk.pathsec.ENFORCE}')  # False

# Attempt to read /etc/passwd through pathsec -- should be blocked
with warnings.catch_warnings(record=True) as w:
    warnings.simplefilter('always')
    result = nltk.pathsec.open('/etc/passwd', 'r')
    print(f'File opened: {result.name}')  # /etc/passwd
    print(f'Warning emitted: {w[0].message}')  # RuntimeWarning (not an exception)
    # Attack succeeds -- file is readable

The correct default is fail-secure: ENFORCE should be True unless explicitly disabled. The current default makes the security module opt-in rather than opt-out, defeating its purpose.

Suggested fix: Change default to ENFORCE=True. Users who need backwards compatibility can set NLTK_PATHSEC_ENFORCE=0 to explicitly disable.

Text from GitHub Advisory Database

Affected versions 54

  • nltk, pip<= 3.9.4GitHub
  • nltkaffected: all versions before 3.10.0CVE List
  • nltkunaffected: 3.10.0CVE List
  • nltk, PyPIfrom first release, fixed in 3.10.0OSV
  • nltk, PyPI0.8OSV
  • nltk, PyPI0.9OSV
  • nltk, PyPI0.9.3OSV
  • nltk, PyPI0.9.4OSV
  • nltk, PyPI0.9.5OSV
  • nltk, PyPI0.9.6OSV
  • nltk, PyPI0.9.7OSV
  • nltk, PyPI0.9.8OSV
  • nltk, PyPI0.9.9OSV
  • nltk, PyPI2.0.1OSV
  • nltk, PyPI2.0.1rc1OSV
  • nltk, PyPI2.0.1rc2-gitOSV
  • nltk, PyPI2.0.1rc3OSV
  • nltk, PyPI2.0.1rc4OSV
  • nltk, PyPI2.0.2OSV
  • nltk, PyPI2.0.3OSV
  • nltk, PyPI2.0.4OSV
  • nltk, PyPI2.0.5OSV
  • nltk, PyPI2.0b4OSV
  • nltk, PyPI2.0b5OSV
  • nltk, PyPI2.0b6OSV
  • nltk, PyPI2.0b7OSV
  • nltk, PyPI2.0b8OSV
  • nltk, PyPI2.0b9OSV
  • nltk, PyPI3.0.0OSV
  • nltk, PyPI3.0.0b1OSV
  • nltk, PyPI3.0.0b2OSV
  • nltk, PyPI3.0.1OSV
  • nltk, PyPI3.0.2OSV
  • nltk, PyPI3.0.3OSV
  • nltk, PyPI3.0.4OSV
  • nltk, PyPI3.0.5OSV
  • nltk, PyPI3.1OSV
  • nltk, PyPI3.2OSV
  • nltk, PyPI3.2.1OSV
  • nltk, PyPI3.2.2OSV
  • nltk, PyPI3.2.3OSV
  • nltk, PyPI3.2.4OSV
  • nltk, PyPI3.2.5OSV
  • nltk, PyPI3.3OSV
  • nltk, PyPI3.4OSV
  • nltk, PyPI3.4.1OSV
  • nltk, PyPI3.4.2OSV
  • nltk, PyPI3.4.3OSV
  • nltk, PyPI3.4.4OSV
  • nltk, PyPI3.4.5OSV
  • nltk, PyPI3.5OSV
  • nltk, PyPI3.5b1OSV
  • nltk, PyPI3.6OSV
  • nltk, PyPI3.6.1OSV

References 8