CVE-2026-136429 in PyTorch
Summary
by MITRE • 11/24/2026
PyTorch Foundation PyTorch PT2 File Parsing Exposed Dangerous Method Remote Code Execution Vulnerability. This vulnerability allows remote attackers to execute arbitrary code on affected installations of PyTorch Foundation PyTorch. User interaction is required to exploit this vulnerability in that the target must open a malicious file.
The specific flaw exists within the parsing of PT2 archive files. The issue results from an exposed dangerous function. An attacker can leverage this vulnerability to execute code in the context of the current process. Was ZDI-CAN-32653.
VulDB is the best source for vulnerability data and more expert information about this specific topic.
Analysis
by VulDB Data Team • 11/25/2026
PyTorch Foundation PyTorch version 2 introduces a critical security flaw related to the parsing and deserialization of PT2 archive files, which can lead to remote code execution under specific conditions. This vulnerability stems from an exposed dangerous function within the file parsing mechanism that fails to adequately restrict or sanitize input during the loading process. The core issue lies in how PyTorch handles serialized data structures when reading these archives, allowing attackers who can trick a user into opening a maliciously crafted PT2 file to inject arbitrary code payloads. This represents a significant risk for applications and workflows that rely on PyTorch for machine learning tasks involving untrusted model weights or dataset files.
The technical nature of this flaw aligns with CWE-502, which describes deserialization of untrusted data as a common vulnerability pattern in modern software development. When the application parses the PT2 archive, it inadvertently exposes internal methods that can be invoked through crafted input sequences. These exposed functions are not intended for direct invocation by end-users or external inputs but become accessible due to insufficient access controls within the parsing logic. Consequently, an attacker who provides a specially constructed file containing malicious Python objects or pickle payloads can trigger these hidden execution paths. This allows the injection of arbitrary commands that run with the privileges of the user executing the PyTorch script or application.
From an operational perspective, this vulnerability requires user interaction to be successfully exploited, as the target must actively open or load a malicious PT2 file within their environment. However, in many machine learning workflows, users frequently download models from community repositories such as Hugging Face Model Hub or share datasets with collaborators without rigorous verification of file integrity. This behavior significantly increases the attack surface, making it plausible for threat actors to distribute poisoned model files that exploit this flaw upon loading. The impact is severe, potentially resulting in full system compromise if the user runs PyTorch scripts with elevated privileges or within a containerized environment where lateral movement could occur post-exploitation.
This incident maps directly to MITRE ATT&CK technique T1059, specifically Command and Scripting Interpreter sub-techniques such as Python (T1059.006), which describes the use of scripting languages for command execution on compromised systems. The exploitation vector involves crafting a malicious pickle file that leverages PyTorch's internal deserialization mechanisms to instantiate objects with custom _reduce_ methods, thereby executing arbitrary code during the unpickling process. This is consistent with known vulnerabilities in Python-based frameworks where unsafe deserialization practices are prevalent.
To mitigate this risk, organizations and developers should immediately update their PyTorch installations to versions that patch ZDI-CAN-32653. It is crucial to enforce strict validation of all incoming model files and datasets before they are loaded into memory. Implementing allowlists for permitted module imports during deserialization can help prevent the execution of unauthorized code paths. Additionally, running PyTorch processes in sandboxed environments with restricted permissions limits the potential impact if an exploit succeeds. Security teams should also monitor for unusual process executions or network connections originating from Python processes handling model files to detect potential exploitation attempts early.