/

CVE-2025-71378

Severity:

HIGH RISK

(8.1)

Unsafe Deserialization (CWE-502) in picklescan Scanner

CVE-2025-71378

Analyzed

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

A deserialization bypass in picklescan allows malicious pickle files using cProfile.runctx to evade detection.

When such files are later loaded with pickle.load(), attackers can execute arbitrary code in the context of the loading application.

Affected context

This vulnerability affects Python applications that rely on picklescan as a safeguard against malicious pickle files.

It becomes relevant when applications both:

  • Accept or process pickle data from semi-trusted or untrusted sources, and
  • Depend on picklescan's scanning logic to block dangerous constructs before calling pickle.load() or similar APIs.

In this context, pickle payloads that use cProfile.runctx in their reduce methods can pass through scanning and still perform dangerous actions when deserialized.

Exploit preconditions

  • Attack surface: Any component that ingests external pickle data and uses picklescan for security filtering.
  • Required access: Ability to supply or influence pickle files consumed by the target application (e.g., file upload, message queue, cached objects, or shared storage).
  • Trigger point: Invocation of pickle.load() (or equivalent) on a malicious pickle that has successfully passed picklescan scanning.
  • Why exploitation is possible: picklescan's detection logic does not recognize cProfile.runctx-based execution paths within reduce methods, allowing attacker-controlled functions or code objects to be executed during deserialization.

Why this happens

The underlying issue is an incomplete detection strategy for unsafe deserialization patterns in pickle payloads.

While picklescan aims to detect dangerous global references and reduce-method constructs, its ruleset does not account for cProfile.runctx being leveraged as an execution primitive.

This aligns with CWE-502: Unsafe Deserialization, because untrusted serialized data can still trigger arbitrary code execution when deserialized, due to inadequate filtering of all known execution vectors within pickle protocols.

Potential impact

  • Execution of arbitrary Python code in the application process.
  • Compromise of application integrity, including modification or exfiltration of data.
  • Installation of backdoors or persistence mechanisms via malicious payloads.
  • Use of the compromised process as a pivot point for broader system or network attacks.

General mitigation guidance

Mitigation typically focuses on minimizing reliance on pickle for untrusted data and hardening deserialization paths.

Useful defensive patterns include:

  • Treating all pickle input as untrusted and avoiding it for external or cross-trust-boundary data where possible.
  • Introducing explicit allowlists of expected types and modules, and rejecting anything outside that set before deserialization.
  • Running deserialization logic in a constrained environment (e.g., separate process, restricted permissions, sandbox) so that potential execution has limited impact.
  • Applying defense-in-depth by combining scanning tools with protocol-level restrictions and strong authentication/authorization on data sources.

How teams detect issues like this

Detection generally combines code-level review and runtime monitoring.

Possible strategies include:

  • Static analysis rules or linters flagging use of pickle.load, pickle.loads, or similar APIs on data that can be influenced by external users.
  • Code review checklists that call out deserialization paths and verify they are not used across trust boundaries without strict validation.
  • Policy-based controls (e.g., internal security guidelines) that require justification and approval for using pickle in production systems.
  • Use of automated scanning tools to identify unsafe deserialization patterns and monitor for suspicious serialized payloads in logs or storage.

Sources

SourceLink
github.comgithub.com/mmaitre314/picklescan/security/advisories/GHSA-9w88-8rmg-7g2p
vulncheck.comvulncheck.com/advisories/picklescan-remote-code-execution-via-undetected-cprofile-runctx-in-pickle-files

Frequently asked

questions

It can be, if an attacker can deliver pickle data over a network interface—such as an API, message broker, or file upload—that the application deserializes after scanning.

The attacker must be able to supply or modify pickle files that the application processes. No direct shell or system access is required; control over serialized input is sufficient if deserialization occurs.

The most robust pattern is to avoid using pickle for any data that crosses trust boundaries and to replace it with safer serialization formats like JSON or protocol buffers, which do not execute code during decoding.

Establish a policy that discourages general-purpose deserialization of untrusted data, enforce architectural reviews for any serialization mechanism, and integrate static and policy checks in CI/CD to flag unsafe deserialization patterns early.

Find out what's already
exploitable in your codebase.