Advisory

GHSA-53q9-r3pm-6pq6

Also known as: BIT-pytorch-2025-32434, CVE-2025-32434, PYSEC-2025-41

Summary

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

Details

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.

Severity

Critical Basis: The source's own band: CRITICAL

Dates

Published
2025-04-18 15:19 UTC
Modified
2026-08-07 08:12 UTC

Affected packages and fixes

torch

PyPI · All systems

Affected

  • introduced 0, fixed 2.6.0 (ecosystem)

Fixed versions

2.6.0

Fix

  • Fixed version 2.6.0
    pip install --upgrade torch==2.6.0

Fix commands are the export's own generic commands. Ojuju never runs them. Check them against your setup first.

Check your own computer: guard packages check

View this record on OSV.dev

Source

Source: GitHub Advisory Database (reviewed advisories) · CC BY 4.0

Sources & licences