CVE-2025-32434: PyTorch: `torch.load` with `weights_only=True` leads to remote code execution
9.3
CVSS Score
4.0
Basic Information
CVE ID
GHSA ID
EPSS Score
0.5564%
CWE
Published
4/18/2025
Updated
4/18/2025
KEV Status
No
Technology Python
Python
Technical Details
CVSS Vector
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X
| Package Name | Ecosystem | Vulnerable Versions | First Patched Version | 
|---|---|---|---|
| torch | pip | <= 2.5.1 | 2.6.0 | 
Vulnerability Intelligence Miggo AI
Miggo AI
 Root Cause Analysis
Root Cause Analysis
The vulnerability occurs when torch.load is called with weights_only=True on a specially crafted legacy .tar model file.
- torch.loadis the user-facing API and the entry point for the vulnerability. It dispatches the loading process.
- For legacy .tarfiles,torch.loadcalls the internal functiontorch.serialization._legacy_load.
- The core of the vulnerability lay within _legacy_load(specifically, itspersistent_loadhelper function that handles tar files). Whenweights_only=Truewas set, thepickle_moduleused was_weights_only_unpickler. However,_legacy_loaddid not adequately ensure that this unpickler could safely process all contents of a legacy.tarfile underweights_onlyconstraints.
- The patch introduces an explicit check within _legacy_load(inpersistent_load) to raise an error if an attempt is made to load a legacy.tarfile withweights_only=True, thereby mitigating the RCE. This confirms that_legacy_loadwas the function performing the unsafe deserialization under these conditions. Bothtorch.load(as the entry point) andtorch.serialization._legacy_load(as the function containing the flawed deserialization logic for this specific case) are identified as vulnerable.