/

CVE-2025-71341

Severity:

HIGH RISK

(8.1)

Undetected Unsafe Pickle Use (CWE-502) in picklescan

CVE-2025-71341

Deferred

Vulnerability type

Category:

Unsafe Deserialization

CWE:

CWE-502

Impact:

Remote Code Execution via deserialization evasion

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

An evasion issue in picklescan before version 0.0.29 fails to recognize the dangerous use of profile.Profile.runctx within pickle payloads, leaving certain malicious constructs undetected during analysis.

Remote attackers can craft pickle files that leverage runctx in the __reduce__ method to execute arbitrary code when the pickle is loaded, posing a high risk wherever untrusted pickle data is deserialized.

Affected context

This vulnerability affects environments that rely on picklescan as a safety check before loading Python pickle data, particularly in services that process user-supplied or externally sourced pickle files.

It becomes relevant when pickle files are accepted as inputs and are expected to be scanned for dangerous object graphs, yet the scan is trusted as a gate to allow deserialization to proceed.

Exploit preconditions

  • Attack surface: Any interface that ingests and later deserializes pickle files (APIs, job queues, storage-backed workflows).
  • Required access: Ability to submit or influence pickle content that is scanned with vulnerable versions of picklescan and subsequently loaded.
  • Trigger point: Invocation of pickle.load/pickle.loads (or equivalent) on a malicious payload that passed picklescan analysis.
  • Why exploitation is possible: picklescan prior to 0.0.29 does not recognize profile.Profile.runctx as a risky callable in the __reduce__ chain, allowing attacker-controlled code execution primitives to bypass detection.

Why this happens

The underlying issue is incomplete coverage of dangerous call targets during pickle inspection, a variant of CWE-502: Unsafe Deserialization combined with inadequate validation of deserialization inputs.

picklescan's heuristic model for identifying malicious constructors and callables does not include profile.Profile.runctx, which can execute arbitrary Python code when invoked via a crafted __reduce__ sequence.

As a result, applications that treat a "clean" scan result as sufficient justification for deserialization may unintentionally deserialize untrusted data that can run attacker-controlled code.

Potential impact

  • Remote code execution in the context of the application that loads the pickle.
  • Compromise of application data and secrets accessible to the process.
  • Lateral movement within the host or environment, subject to existing privileges.
  • Deployment of backdoors, logic tampering, or service disruption through malicious payloads.

General mitigation guidance

Mitigation should focus on reducing trust in pickle-based data and strengthening deserialization safety boundaries.

Recommended patterns include:

  • Treating all pickle data as untrusted, and avoiding pickle for cross-boundary data exchange whenever possible.
  • Using serialization formats that do not support arbitrary code execution (e.g., JSON, protocol buffers) for user-supplied data.
  • Applying strict allowlists of safe types or schemas before deserialization, rather than relying solely on heuristic scanners.
  • Running deserialization logic in isolated, least-privilege environments to limit impact if unsafe behavior occurs.
  • Incorporating defense-in-depth controls such as process-level sandboxing, OS-level confinement, and hardening of runtime permissions.

How teams detect issues like this

Detection efforts can focus on both code and runtime behavior:

  • Static analysis rules that flag uses of pickle.load/pickle.loads on data originating from untrusted sources or network input.
  • Code review practices that question reliance on heuristic scanners as the sole gate for deserialization safety, and look for missing allowlists or schema validation.
  • Monitoring for unexpected use of introspection or profiling APIs such as profile.Profile.runctx inside deserialization-related modules.
  • Logging and anomaly detection around pickle handling components, including alerts for deserialization of externally supplied payloads.
  • Automated security testing tools that simulate malicious pickle payloads and validate whether defensive layers correctly block code execution.

Sources

SourceLink
github.comgithub.com/mmaitre314/picklescan/security/advisories/GHSA-6vqj-c2q5-j97w
vulncheck.comvulncheck.com/advisories/picklescan-remote-code-execution-via-undetected-profile-profile-runctx

Frequently asked

questions

No. The vulnerability lies in picklescan's failure to flag a specific dangerous pattern (profile.Profile.runctx via __reduce__), which allows malicious pickle payloads to evade detection. The underlying risk is the inherent danger of untrusted pickle deserialization.

An attacker must be able to submit or modify pickle data that is scanned with a vulnerable version of picklescan and then deserialized by the target application. This typically corresponds to remote access to an API, message queue, or import mechanism that accepts pickle files.

The safest pattern is to avoid using pickle for untrusted data entirely. Where pickle cannot be eliminated, combine strict type/schema allowlists, additional validation layers, and isolated runtime environments so that deserialization cannot directly execute arbitrary attacker-controlled code.

Adopt a policy that forbids unsafe serialization formats for cross-trust-boundary data, enforce architectural guidelines that require non-executable data formats, and integrate security reviews and automated checks around any introduction of deserialization logic. Treat heuristic scanners as supplemental, not as the sole defense.

Find out what's already
exploitable in your codebase.