CVE-2025-32434: PyTorch: `torch.load` with `weights_only=True` leads to remote code execution
Description I found a Remote Command Execution (RCE) vulnerability in PyTorch. When loading model using torch.load with weightsonly=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 weightsonly=True to be safe. !image Since everyone knows that weightsonly=False is unsafe, so they will use the weightsonly=True to mitigate the seucirty issue. But now, I just proved that even if you use weightsonly=True, it can still achieve RCE.
Credit This vulnerability was found by Ji'an Zhou.
Other sources
PyTorch is a Python package that provides tensor computation with strong GPU acceleration and deep neural networks built on a tape-based autograd system. In version 2.5.1 and prior, a Remote Command Execution (RCE) vulnerability exists in PyTorch when loading a model using torch.load with weightsonly=True. This issue has been patched in version 2.6.0.
— NVD
PyTorch: torch.load with weightsonly=True leads to remote code execution
— Microsoft
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
pip/torchto a version that resolves this vulnerability.Fixed in 2.6.0 - Upgrade
Upgrade to a fixed release to a version that resolves this vulnerability.
Fixed in 2.2.2-6 - Upgrade
Upgrade to a fixed release to a version that resolves this vulnerability.
Fixed in 2.0.0-8 - Upgrade
Upgrade
pytorchto a version that resolves this vulnerability.Fixed in 2.6.0
Event History
Frequently Asked Questions
What is the severity of CVE-2025-32434?
CVE-2025-32434 is classified as a high-severity vulnerability due to its potential for Remote Command Execution.
How do I fix CVE-2025-32434?
To fix CVE-2025-32434, upgrade the PyTorch library to version 2.6.0 or later.
Which versions of PyTorch are affected by CVE-2025-32434?
CVE-2025-32434 affects all PyTorch versions up to and including 2.5.1.
What is the impact of CVE-2025-32434?
The impact of CVE-2025-32434 is that attackers can execute arbitrary commands on the server through the vulnerable model loading function.
Is CVE-2025-32434 related to any specific function in PyTorch?
Yes, CVE-2025-32434 is specifically related to the 'torch.load' function when used with 'weights_only=True'.