Skip to main content
CVE Vulnerability Database
Vulnerability Database/CVE-2025-55554

CVE-2025-55554: PyTorch Buffer Overflow Vulnerability

CVE-2025-55554 is a buffer overflow vulnerability in PyTorch v2.8.0 affecting the torch.nan_to_num-.long() component. This flaw poses risks to applications using this function. This article covers technical details, impact, and mitigation.

Published:

CVE-2025-55554 Overview

CVE-2025-55554 is an integer overflow vulnerability in PyTorch version 2.8.0. The flaw resides in the torch.nan_to_num().long() component, where numeric conversion fails to validate input boundaries. An attacker supplying crafted tensor values can trigger the overflow, producing incorrect numeric results or terminating the process. The issue is classified under [CWE-190] (Integer Overflow or Wraparound) and affects PyTorch deployments that process untrusted input through this API. Because PyTorch is widely used in machine learning pipelines, applications performing inference on attacker-influenced data are exposed to availability impact.

Critical Impact

Attackers can trigger an integer overflow in torch.nan_to_num().long() to cause limited availability disruption in PyTorch-based ML services.

Affected Products

  • Linux Foundation PyTorch v2.8.0
  • PyTorch Python distributions using the affected torch.nan_to_num code path
  • Downstream ML frameworks and services bundling PyTorch 2.8.0

Discovery Timeline

  • 2025-09-25 - CVE-2025-55554 published to the National Vulnerability Database (NVD)
  • 2026-06-17 - Last updated in the NVD database

Technical Details for CVE-2025-55554

Vulnerability Analysis

The vulnerability affects torch.nan_to_num, a PyTorch tensor operation that replaces NaN, positive infinity, and negative infinity values with finite numeric substitutes. When the result is subsequently cast to a 64-bit integer through .long(), PyTorch does not validate that the floating-point replacement values fit within the target integer range. Values outside the representable int64 range wrap around, producing undefined numeric results.

The issue is limited to numeric correctness and process stability. It does not corrupt memory in a way that yields code execution, and it does not disclose sensitive data. The impact is availability — the operation can raise an unhandled exception or return garbage values that break downstream inference logic.

Root Cause

The root cause is missing boundary validation between floating-point conversion and integer casting. torch.nan_to_num accepts caller-supplied posinf and neginf arguments, or defaults to the maximum and minimum finite representable float. When these values exceed int64 bounds during the .long() cast, an integer overflow occurs. See the GitHub Issue Discussion for maintainer analysis.

Attack Vector

Exploitation requires an attacker to supply tensor input or posinf/neginf parameters to a Python process that invokes torch.nan_to_num().long(). In network-exposed ML inference services that accept user-controlled tensors or JSON-encoded numeric arrays, the attack can be delivered remotely without authentication. A proof-of-concept is published at the GitHub Gist PoC. The vulnerability produces incorrect output or process failure rather than remote code execution.

Detection Methods for CVE-2025-55554

Indicators of Compromise

  • Unhandled Python exceptions or crashes originating from torch.nan_to_num or subsequent .long() calls in application logs
  • Anomalous ML inference results — sudden appearance of extreme negative or positive integer values in downstream tensors
  • Repeated crashes of PyTorch worker processes tied to specific input payloads

Detection Strategies

  • Inventory installed PyTorch versions across development, training, and inference hosts using pip show torch or software bill of materials (SBOM) tooling
  • Scan Python source and Jupyter notebooks for calls to torch.nan_to_num chained with integer casts such as .long(), .int(), or .to(torch.int64)
  • Enable structured logging on ML inference endpoints to capture input tensor shapes and dtypes for post-incident analysis

Monitoring Recommendations

  • Monitor PyTorch process exit codes and stderr output for RuntimeError and OverflowError events
  • Alert on unusual spikes in inference latency or worker restarts that may correlate with malformed input
  • Track outbound tensor value distributions and flag results that saturate int64 boundaries

How to Mitigate CVE-2025-55554

Immediate Actions Required

  • Identify all services running PyTorch 2.8.0 and prioritize those exposing inference APIs to untrusted callers
  • Validate and clamp numeric input ranges before invoking torch.nan_to_num on user-controlled tensors
  • Wrap affected code paths in exception handlers to prevent worker crashes from propagating to service consumers

Patch Information

No fixed PyTorch release is referenced in the NVD record at the time of the last update. Track the GitHub Issue Discussion for upstream remediation status and apply the official patch once released by the PyTorch project.

Workarounds

  • Explicitly pass finite posinf and neginf arguments to torch.nan_to_num that fit within int64 bounds before casting with .long()
  • Replace the vulnerable pattern with a two-step conversion that clamps values using torch.clamp prior to the integer cast
  • Reject inference requests whose tensor values fall outside expected numeric ranges at the API gateway layer
bash
# Example: clamp values before casting to int64
python -c "import torch; x = torch.tensor([float('nan'), float('inf')]); \
y = torch.nan_to_num(x, posinf=2**62, neginf=-(2**62)).clamp(-(2**62), 2**62-1).long(); print(y)"

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Default Legacy - Prefooter | Experience the World’s Most Advanced Cybersecurity Platform

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.