Critical

PyTorch: `torch.load` with `weights_only=True` leads to remote code execution

  • Disclosed: 18.04.2025
  • Updated: 11.10.2026 14:19

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 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 software

Click a technology to see all vulnerabilities affecting it.

PlatformPackageVulnerable versionsFixed in
Python (PyPI) torch < 2.6.0 2.6.0

References

CVSS score -
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
Weakness (CWE)
CWE-502
Platform
Python (PyPI)
Package
torch
Disclosed
18.04.2025
Updated
11.10.2026 14:19

Sources and licenses

OSV / GitHub Advisory Database - PYSEC-2025-41 - PyPA Advisory Database; CC BY 4.0

OSV / GitHub Advisory Database - GHSA-53q9-r3pm-6pq6 - CC BY 4.0

Vulnerability history: torch

All published vulnerabilities of this package (Python (PyPI)), newest first. Shows whether this is a one-off slip or a package that needs watching.

All (31) in the archive
Total entries
31
First → latest
11.2022 03.2026
Without a fix
9
Exploited in attacks
0

Severity breakdown

  • Critical 3
  • High 10
  • Medium 11
  • Low 5
  • Unrated 2

Disclosures per year

  1. 2022: 1
  2. 2023: 0
  3. 2024: 4
  4. 2025: 24
  5. 2026: 2
Severity:
  1. PyTorch: `torch.load` with `weights_only=True` leads to remote code execution this entry
    Critical CVE-2025-32434 < 2.6.0 2.6.0

Know which vulnerabilities affect your application

With the DockRay integration and software inventory enabled, DockRay checks reported component versions against known vulnerabilities and notifies you about confirmed matches. Coverage depends on the supported technology and available advisory data.

Connect your application
DockRay newsletter

Application security in your inbox

Important vulnerabilities, actionable guidance and practical advice for your applications. Choose your technologies and follow what matters to your project.

  • A daily digest of new vulnerabilities, critical ones included.
  • Notifications about important updates.
  • Practical advice on application security and monitoring.

Leave empty to receive updates for every technology.

Free to subscribe. Unsubscribe with one click in any email.