/

CVE-2025-71369

Severity:

HIGH RISK

(8.1)

Unsafe Pickle Deserialization (CWE-502) in picklescan

CVE-2025-71369

Deferred

Vulnerability type

Category:

Unsafe Deserialization

CWE:

CWE-502

Impact:

Remote Code Execution

Severity:

HIGH RISK

(8.1)

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

picklescan before version 0.0.28 fails to recognize malicious pickle payloads that leverage torch.utils.data.datapipes.utils.decoder.basichandlers in reduce methods, allowing them to pass safety checks.

Remote attackers can embed undetected executable code into specially crafted pickle files, which may run during deserialization and lead to remote code execution in environments that trust picklescan's validation.

Affected context

This vulnerability impacts environments that rely on picklescan for security screening of Python pickle files, especially in ML and data processing pipelines that use PyTorch data utilities.

It becomes relevant when untrusted or semi-trusted pickle data is accepted from external sources and validated using picklescan, under the assumption that unsafe payloads will be reliably detected and blocked.

Exploit preconditions

  • Attack surface: Any application or service that accepts pickle files and uses picklescan (pre-0.0.28) to vet them before deserialization.
  • Required access: Ability to supply or influence serialized pickle content, such as uploading datasets, model artifacts, or configuration pickles.
  • Trigger point: The vulnerable condition occurs when a crafted pickle using torch.utils.data.datapipes.utils.decoder.basichandlers in its reduce methods is scanned by picklescan and then deserialized.
  • Why exploitation is possible: picklescan's detection logic does not recognize this handler-based pattern as malicious, allowing the payload to bypass checks and execute code during the normal unpickling process.

Why this happens

The underlying issue is incomplete coverage in the unsafe deserialization detection logic for Python pickles.

picklescan focuses on known dangerous patterns but fails to account for object construction paths that invoke torch.utils.data.datapipes.utils.decoder.basichandlers functions via reduce methods, which can be abused to run attacker-controlled code.

This maps to CWE-502: Unsafe Deserialization, where security tooling and application logic treat serialized data as safe and fail to constrain what objects and behaviors can be instantiated during deserialization.

Potential impact

  • Remote attackers may execute arbitrary Python code on systems that deserialize attacker-controlled pickle files.
  • Malicious pickles could modify or exfiltrate sensitive data processed by ML workflows and data pipelines.
  • Attackers can potentially deploy backdoors or alter model artifacts and datasets, leading to data poisoning or model integrity compromises.
  • Compromise of the hosting application or service, with possible lateral movement depending on runtime permissions and network access.

General mitigation guidance

Mitigation patterns should focus on reducing trust in serialized data and constraining deserialization behavior.

Common secure design approaches include:

  • Avoiding pickle for untrusted or user-supplied data, favoring safer, declarative formats such as JSON or protocol buffers.
  • Enforcing strict allowlists for deserializable types and modules, so that only benign, expected objects can be instantiated.
  • Treating security scanning tools like picklescan as one defensive layer, not a sole gatekeeper, and combining them with runtime isolation and least privilege.
  • Running deserialization code in tightly sandboxed environments with minimal filesystem, network, and process capabilities.
  • Applying explicit validation on data structures after deserialization and rejecting unexpected or opaque objects that expose dynamic behavior.

How teams detect issues like this

Detection efforts can target both application code and serialized data flows:

  • Use static analysis or code search to flag any use of Python's pickle, torch.load, or similar deserialization APIs on untrusted inputs, especially when guarded only by picklescan.
  • During code reviews, treat reliance on security scanners for pickle safety as a smell; look for explicit type restrictions, sandboxing, and safer data formats.
  • Apply policy-based checks in CI/CD that disallow or require justification for new pickle-based inputs, particularly in remote or multi-tenant services.
  • Incorporate automated scanning tools that analyze serialized artifacts for suspicious constructors and reduce methods, augmenting picklescan with additional rule sets where appropriate.

Sources

SourceLink
github.comgithub.com/mmaitre314/picklescan/security/advisories/GHSA-h3qp-7fh3-f8h4
vulncheck.comvulncheck.com/advisories/picklescan-unsafe-deserialization-via-torch-utils-data-datapipes-utils-decoder-basichandlers

Frequently asked

questions

Yes, if an attacker can remotely provide pickle files to a system that relies on picklescan for safety checks and subsequently deserializes those files, they may achieve remote code execution.

An attacker needs the ability to influence or upload serialized pickle content that will be scanned by picklescan and then unpickled by the application, such as dataset uploads, model artifact submissions, or configuration imports.

The most robust pattern is to avoid using pickle for any untrusted or externally supplied data, instead adopting safer serialization formats and enforcing strict type controls for any remaining deserialization paths.

Treat serialization and deserialization as high-risk operations: minimize use of generic object serialization, apply allowlists and sandboxing, regularly review security tooling coverage, and enforce architectural policies that restrict or ban unsafe deserialization mechanisms.

Find out what's already
exploitable in your codebase.