Miggo Logo

CVE-2025-32434: PyTorch: `torch.load` with `weights_only=True` leads to remote code execution

9.3

CVSS Score
4.0

Basic Information

EPSS Score
0.5564%
Published
4/18/2025
Updated
4/18/2025
KEV Status
No
Technology
TechnologyPython

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 NameEcosystemVulnerable VersionsFirst Patched Version
torchpip<= 2.5.12.6.0

Vulnerability Intelligence
Miggo AIMiggo AI

Miggo AIRoot Cause Analysis

The vulnerability occurs when torch.load is called with weights_only=True on a specially crafted legacy .tar model file.

  1. torch.load is the user-facing API and the entry point for the vulnerability. It dispatches the loading process.
  2. For legacy .tar files, torch.load calls the internal function torch.serialization._legacy_load.
  3. The core of the vulnerability lay within _legacy_load (specifically, its persistent_load helper function that handles tar files). When weights_only=True was set, the pickle_module used was _weights_only_unpickler. However, _legacy_load did not adequately ensure that this unpickler could safely process all contents of a legacy .tar file under weights_only constraints.
  4. The patch introduces an explicit check within _legacy_load (in persistent_load) to raise an error if an attempt is made to load a legacy .tar file with weights_only=True, thereby mitigating the RCE. This confirms that _legacy_load was the function performing the unsafe deserialization under these conditions. Both torch.load (as the entry point) and torch.serialization._legacy_load (as the function containing the flawed deserialization logic for this specific case) are identified as vulnerable.

Vulnerable functions

Only Mi**o us*rs **n s** t*is s**tion

WAF Protection Rules

WAF Rule

# **s*ription I *oun* * R*mot* *omm*n* *x**ution (R**) vuln*r**ility in t** PyTor**. W**n lo** mo**l usin* tor**.lo** wit* w*i**ts_only=Tru*, it **n still ***i*v* R**. # ***k*roun* knowl**** *ttps://*it*u*.*om/pytor**/pytor**/s**urity *s you **n

Reasoning

T** vuln*r**ility o**urs w**n `tor**.lo**` is **ll** wit* `w*i**ts_only=Tru*` on * sp**i*lly *r**t** l****y `.t*r` mo**l *il*. *. `tor**.lo**` is t** us*r-***in* *PI *n* t** *ntry point *or t** vuln*r**ility. It *isp*t***s t** lo**in* pro**ss. *. *o