/

CVE-2026-78683

Severity:

CRITICAL RISK

(9.6)

Unsafe Pickle Deserialization (CWE-502) in Python NLTK

CVE-2026-78683

Analyzed

Vulnerability type

Category:

Unsafe Deserialization

CWE:

CWE-502

Impact:

Arbitrary Code Execution

Severity:

CRITICAL RISK

(9.6)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

A critical unsafe pickle deserialization vulnerability in NLTK's TransitionParser.parse() method allows attacker-controlled model files to resolve arbitrary Python classes during loading.

If an application loads a crafted model file, embedded pickle gadget chains may execute arbitrary Python code with the privileges of the application process.

Affected context

The vulnerability affects NLTK applications using the TransitionParser.parse() model-loading path in affected releases through 3.9.4. Risk arises when a model file can be supplied, replaced, or otherwise influenced by an attacker and is then deserialized by the application. The production path uses a WarningUnpickler that does not restrict class resolution, even though NLTK includes a separate RestrictedUnpickler for safer handling.

Exploit preconditions

  • Attack surface: NLTK model-file loading through TransitionParser.parse()
  • Required access: Ability to cause the application to load an attacker-crafted or modified model file
  • Trigger point: Pickle deserialization during model loading
  • Why exploitation is possible: The default deserialization path permits arbitrary class resolution, allowing embedded gadget chains to execute Python code

Why this happens

The underlying bug is unsafe deserialization of untrusted pickle data. The affected code invokes pickle_load() without enabling its restricted mode, routing execution through a deserializer that does not override find_class() to constrain which classes may be resolved. This maps to CWE-502: Deserialization of Untrusted Data, because serialized input can influence object construction and trigger executable behavior before the application can establish sufficient trust or validation.

Potential impact

  • Arbitrary Python code execution in the application process
  • Access to data and resources available to the application account
  • Modification or deletion of application files
  • Credential or secret exposure from the runtime environment
  • Further compromise of connected services or systems

General mitigation guidance

Mitigation generally focuses on eliminating unsafe pickle deserialization for untrusted or insufficiently trusted model files.

Common defensive patterns include:

  • Use restricted or allowlisted deserialization mechanisms that do not permit arbitrary class resolution
  • Prefer non-executable, schema-validated model formats where practical
  • Treat model files as untrusted inputs and verify their provenance and integrity before loading
  • Separate model acquisition from application execution and restrict write access to model storage
  • Run model-loading processes with least-privilege identities, limited filesystem access, and constrained network permissions
  • Apply dependency governance and security review controls for serialization code paths

How teams detect issues like this

Organizations can identify similar risks through:

  • Static analysis rules for pickle.load, pickle.loads, and wrapper functions that deserialize without restricted class resolution
  • Code review checks for custom unpicklers that fail to constrain find_class()
  • Searches for model-loading paths that accept files from uploads, network locations, shared storage, or user-controlled configuration
  • Dependency and software composition analysis for unsafe deserialization advisories
  • Runtime monitoring for unexpected child processes, filesystem changes, or outbound connections during model loading
  • Policy enforcement requiring approved, schema-based serialization formats for untrusted artifacts

Sources

SourceLink
github.comgithub.com/nltk/nltk/security/advisories/GHSA-rhp5-r9x4-f5g2
vulncheck.comvulncheck.com/advisories/nltk-before-remote-code-execution-via-unsafe-pickle-deserialization

Frequently asked

questions

It can be exploitable remotely when an application accepts, retrieves, or loads model files that an attacker can influence. The vulnerability itself is triggered locally during deserialization, so exploitability depends on how model artifacts enter the application.

An attacker generally needs the ability to provide, replace, or tamper with a model file that the application subsequently loads. This may result from an exposed upload feature, compromised artifact repository, writable shared storage, or an upstream supply-chain issue.

Avoid deserializing untrusted pickle data with unrestricted class resolution. Use a restricted allowlist-based deserializer or a non-executable, schema-validated model format, and verify artifact integrity before loading.

Treat serialized models as untrusted input, enforce provenance and integrity checks, apply least privilege to model-loading processes, and use static analysis and review policies that flag unsafe deserialization APIs.

Find out what's already
exploitable in your codebase.