PyTorch: `torch.load` with `weights_only=True` leads to remote code execution
CriticalCVE-2025-32434 · Published Apr 18, 2025 · updated Aug 7, 2026
# Description I found a Remote Command Execution (RCE) vulnerability in PyTorch. When loading model using torch.load with weights_only=True, it can still achieve RCE. # Background knowledge https://github.com/pytorch/pytorch/security As you can see, the PyTorch official documentation considers using `torch.load()` with `weights_only=True` to be safe.  Since everyone knows that weights_only=False is unsafe, so they will use the weights_only=True to mitigate the seucirty issue. But now, I just proved that even if you use weights_only=True, it can still achieve RCE. # Credit This vulnerability was found by Ji'an Zhou.
Affected versions
| Package | Affected | Fixed in |
|---|---|---|
| torch PyPI | < 2.6.0 | 2.6.0 |
Details and references
- CVSS 4.0
- 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
- Severity from
- GitHub (reviewed advisory)
- Weakness
- CWE-502
- Also known as
- BIT-pytorch-2025-32434, CVE-2025-32434, PYSEC-2025-41
More PyTorch advisories
All PyTorch| Date | Advisory | Severity | Fixed in |
|---|---|---|---|
| Apr 162025 | PyTorch Improper Resource Shutdown or Release vulnerability | Medium3.3 | 2.8.0 |
| Apr 32025 | PyTorch: memory corruption | Low3.3 | No fix yet |
| Apr 22025 | PyTorch: memory corruption | Medium5.5 | No fix yet |
| Mar 312025 | PyTorch is vulnerable to memory corruption through its torch.lstm_cell function | Low5.3 | 2.10.0 |
| Mar 312025 | PyTorch is Vulnerable to Memory Consumption through pad_packed_sequence Function | Medium5.3 | No fix yet |
| Mar 312025 | PyTorch is vulnerable to memory corruption through its torch.jit.script function | Low5.3 | 2.13.0 |