CVE-2025-32434: PyTorch Remote Code Execution Vulnerability

CRITICAL
Advisory Identifier: GHSA-53q9-r3pm-6pq6
CWE-502
Published
Advisory Summary

CVE-2025-32434 is a CRITICAL remote code execution vulnerability (CWE-502: Deserialization of Untrusted Data) affecting PyTorch libraries in the PyPI ecosystem. The issue involves `torch.load` with `weights_only=true` leads to remote code execution. Remediation is available by upgrading affected packages to version 2.6.0.

CVE-2025-32434 at a Glance

CVE Identifier CVE-2025-32434
GHSA Identifier GHSA-53q9-r3pm-6pq6
Severity CRITICAL
CVSS v3.1 Base Score N/A
CWE Classification CWE-502: Deserialization of Untrusted Data
Affected Product PyTorch
Package Ecosystem PyPI
Published Date
Last Updated

How to Fix CVE-2025-32434

To remediate this vulnerability, upgrade all affected PyTorch dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

torch fixed: 2.6.0
pip install torch>=2.6.0
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show torch

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2025-32434, inspect your installed packages using pip:

pip show torch

Analyze the terminal output to locate any version of PyTorch in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.6.0), your application is affected.

Note: The pip show torch command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-502: Deserialization of Untrusted Data, where the product deserializes untrusted data without sufficiently ensuring that the resulting data will be valid. In PyTorch, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

# 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.

CVE-2025-32434 Affected PyTorch Versions

1 component(s)
Fixed Versions:
2.6.0
Product / Package Ecosystem Affected Versions Fixed Version
torch
PyPI
< 2.6.0
2.6.0

References

Frequently Asked Questions

What is CVE-2025-32434?
CVE-2025-32434 is a security vulnerability in PyTorch involving `torch.load` with `weights_only=True` leads to remote code execution under CWE-502: Deserialization of Untrusted Data.
Which PyTorch versions are affected?
Affected versions include releases prior to 2.6.0 across affected packages: torch.
What version fixes CVE-2025-32434?
Upgrading to 2.6.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is torch affected?
Yes, torch is affected in releases prior to 2.6.0. Upgrade your dependency to 2.6.0 or later.
What CWE is associated with CVE-2025-32434?
CVE-2025-32434 is classified under CWE-502: Deserialization of Untrusted Data (The product deserializes untrusted data without sufficiently ensuring that the resulting data will be valid.).
How can I check PyPI dependencies for CVE-2025-32434?
Run the dependency tree command: 'pip show torch'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-53q9-r3pm-6pq6",
  "modified" : "2025-08-29T19:45:46Z",
  "published" : "2025-04-18T15:19:28Z",
  "aliases" : [ "CVE-2025-32434" ],
  "summary" : "PyTorch: `torch.load` with `weights_only=True` leads to remote code execution",
  "details" : "# Description\nI found a Remote Command Execution (RCE) vulnerability in PyTorch. When loading model using torch.load with weights_only=True, it can still achieve RCE.  \n\n# Background knowledge\nhttps://github.com/pytorch/pytorch/security \n As you can see, the PyTorch official documentation considers using `torch.load()` with `weights_only=True` to be safe.\n![image](https://github.com/user-attachments/assets/fdaa8520-d66a-473a-ab1f-163d793de298)\nSince everyone knows that weights_only=False is unsafe, so they will use the  weights_only=True to mitigate the seucirty issue.\nBut now, I just proved that even if you use weights_only=True, it can still achieve RCE.\n\n# Credit\nThis vulnerability was found by Ji'an Zhou.",
  "severity" : [ {
    "type" : "CVSS_V4",
    "score" : "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"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "torch"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "2.6.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/pytorch/pytorch/security/advisories/GHSA-53q9-r3pm-6pq6"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2025-32434"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pytorch/pytorch/commit/8d4b8a920a2172523deb95bf20e8e52d50649c04"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pypa/advisory-database/tree/main/vulns/torch/PYSEC-2025-41.yaml"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/pytorch/pytorch"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-502" ],
    "severity" : "CRITICAL",
    "github_reviewed" : true,
    "github_reviewed_at" : "2025-04-18T15:19:28Z",
    "nvd_published_at" : "2025-04-18T16:15:23Z"
  }
}