VAITP Dataset

← Back to the dataset

CVE-2026-126296

Path traversal in NLTK 3.10.4 save/load_maxent_params allows arbitrary file read/write.

  • CVSS 6.3
  • CWE-73
  • Input Validation and Sanitization
  • Remote

NLTK before 3.10.4 contains a path traversal vulnerability in save_maxent_params() and load_maxent_params() that bypasses the pathsec filesystem restriction mechanism. Attackers who control the tab_dir argument can read or overwrite model parameter files outside permitted data roots, because the functions call Python's built-in open() directly.

CVSS base score
6.3
Published
2026-11-13
OWASP
A01 Broken Access Control
Orthogonal defect classification
Checking
Code defect classification
Missing Check
Category
Input Validation and Sanitization
Subcategory
Path Traversal
Accessibility scope
Remote
Impact
Information Disclosure
Affected component
NLTK
Fixed by upgrading
Yes

Solution

Upgrade NLTK to version 3.10.4 or newer to remediate the path‑traversal issue.

Vulnerable code sample

import os
from nltk.maxent import MaxentModel

def load_model(tab_dir: str) -> MaxentModel:
    # VULNERABLE: directly opens user‑controlled path, allowing path traversal
    with open(os.path.join(tab_dir, "model.params"), "rb") as f:
        model = MaxentModel.load(f)
    return model

def save_model(model: MaxentModel, tab_dir: str) -> None:
    # VULNERABLE: directly opens user‑controlled path, allowing path traversal
    with open(os.path.join(tab_dir, "model.params"), "wb") as f:
        model.save(f)

Patched code sample

import os
from pathlib import Path
from nltk.maxent import MaxentModel

def load_model(tab_dir: str) -> MaxentModel:
    # FIX: resolve path and restrict to allowed base directory
    base = Path("/safe/models").resolve()
    target = (base / tab_dir / "model.params").resolve()
    if not str(target).startswith(str(base)):
        raise ValueError("Invalid model path")
    with open(target, "rb") as f:
        model = MaxentModel.load(f)
    return model

def save_model(model: MaxentModel, tab_dir: str) -> None:
    # FIX: resolve path and restrict to allowed base directory
    base = Path("/safe/models").resolve()
    target = (base / tab_dir / "model.params").resolve()
    if not str(target).startswith(str(base)):
        raise ValueError("Invalid model path")
    with open(target, "wb") as f:
        model.save(f)

Cite this entry

@misc{vaitp:cve2026126296,
  title        = {{Path traversal in NLTK 3.10.4 save/load_maxent_params allows arbitrary file read/write.}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2026},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2026-126296},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-126296/}}
}

Download this entry as JSON Download the whole dataset

Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.

The supreme art of war is to subdue the enemy without fighting.

Sun Tzu – “The Art of War”

:: Shaping the future through research and ingenuity ::

Before you use the VAITP AI models

Please read and accept the following disclaimer:

By choosing "I understand and accept", you acknowledge that you understand and agree to these terms.