Skip to content
PyTorchGHSA-53q9-r3pm-6pq6

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. ![image](https://github.com/user-attachments/assets/fdaa8520-d66a-473a-ab1f-163d793de298) 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.

GitHub advisory

Affected versions

PackageAffectedFixed in
torch
PyPI
< 2.6.02.6.0
Details and references

More PyTorch advisories

All PyTorch
Advisory
PyTorch Improper Resource Shutdown or Release vulnerability
Medium3.3Apr 16, 2025
PyTorch: memory corruption
Low3.3Apr 3, 2025
PyTorch: memory corruption
Medium5.5Apr 2, 2025
PyTorch is vulnerable to memory corruption through its torch.lstm_cell function
Low5.3Mar 31, 2025
PyTorch is Vulnerable to Memory Consumption through pad_packed_sequence Function
Medium5.3Mar 31, 2025
PyTorch is vulnerable to memory corruption through its torch.jit.script function
Low5.3Mar 31, 2025

Critical advisories by email

Wednesdays: the week’s critical and high advisories in the AI and data stack, with the fixed versions. Only in weeks that have some.

Double opt-in. Unsubscribe any time.