CVE-2025-46148 Overview
CVE-2025-46148 affects PyTorch through version 2.6.0. The vulnerability causes nn.PairwiseDistance(p=2) to produce incorrect numerical results when eager execution mode is used. This defect impacts the integrity of distance computations used in machine learning models, similarity search, clustering, and other downstream tasks that depend on accurate L2 pairwise distances. The issue is tracked in PyTorch Issue #151198 and addressed in PyTorch Pull Request #152993.
Critical Impact
Incorrect PairwiseDistance outputs in eager mode can silently corrupt model computations, affecting confidentiality of information derived from distance-based logic without raising errors.
Affected Products
- Linux Foundation PyTorch versions up to and including 2.6.0
- PyTorch Python distribution package
- Any downstream framework or application relying on torch.nn.PairwiseDistance(p=2) in eager mode
Discovery Timeline
- 2025-09-25 - CVE-2025-46148 published to NVD
- 2026-06-17 - Last updated in NVD database
Technical Details for CVE-2025-46148
Vulnerability Analysis
The defect resides in the eager-mode implementation of torch.nn.PairwiseDistance when the L2 norm order parameter p=2 is specified. The module computes the pairwise distance between two input tensors along a given dimension. Under eager execution, the returned tensor contains numerically incorrect values compared to the mathematical definition of Euclidean distance.
The issue is categorized under [NVD-CWE-noinfo] because the maintainer report focuses on incorrect output rather than a classic memory safety class. It falls under numerical correctness and input validation error categories. The bug does not trigger an exception, meaning consuming code cannot detect the fault through standard error handling.
Machine learning pipelines that rely on this operator, including contrastive loss training, k-nearest neighbor scoring, embedding similarity, and anomaly detection, receive degraded or misleading results. The information exposure vector reflects the possibility that incorrect distance values leak or reveal unintended relationships between inputs.
Root Cause
The root cause is an implementation defect in the eager-mode kernel path for PairwiseDistance with p=2. Reference reproductions are provided in the linked GitHub gists demonstrating divergence between expected and observed distance tensors. The fix in PR #152993 corrects the computation path so eager-mode outputs match the mathematical specification.
Attack Vector
The CVSS vector describes a network attack path with no privileges or user interaction required. In practice, exploitation requires an adversary to influence tensor inputs processed by a vulnerable PyTorch deployment, for example through a model-serving endpoint that accepts user-supplied vectors and returns similarity results. An attacker can craft inputs that exercise the faulty path to obtain distance outputs inconsistent with true values.
The vulnerability manifests without code execution or memory corruption. Consult the PyTorch Issue #151198, GitHub Gist Example 1, and GitHub Gist Example 2 for reproduction details.
Detection Methods for CVE-2025-46148
Indicators of Compromise
- PyTorch installations reporting torch.__version__ at or below 2.6.0 running inference or training workloads that invoke nn.PairwiseDistance(p=2).
- Divergence between eager-mode and compiled-mode outputs for the same PairwiseDistance operator on identical inputs.
- Unexpected drops in model accuracy, retrieval precision, or clustering quality without corresponding code changes.
Detection Strategies
- Inventory Python environments and identify PyTorch versions using pip show torch or software composition analysis tooling.
- Add unit tests comparing nn.PairwiseDistance(p=2) results against a manual torch.norm(x1 - x2, p=2, dim=1) reference implementation.
- Compare eager-mode results with torch.compile or torch.jit traced equivalents to surface numerical drift.
Monitoring Recommendations
- Log PyTorch version metadata in model registries and CI pipelines to flag pre-patch releases.
- Track model performance metrics such as retrieval recall and loss convergence for anomalous shifts that correlate with vulnerable versions.
- Monitor GitHub advisory feeds and the PyTorch Pull Request #152993 for backport availability.
How to Mitigate CVE-2025-46148
Immediate Actions Required
- Upgrade PyTorch to a release that includes the fix from PyTorch Pull Request #152993 once available on the release channel.
- Audit codebases for usages of torch.nn.PairwiseDistance(p=2) and validate outputs against a reference L2 distance implementation.
- Retrain or re-evaluate models whose training or evaluation loops used the vulnerable operator to confirm result validity.
Patch Information
The upstream fix is delivered through PyTorch Pull Request #152993. Track the PyTorch release notes for the version that ships the merged fix and update production environments accordingly.
Workarounds
- Replace nn.PairwiseDistance(p=2) with an explicit torch.linalg.norm(x1 - x2, ord=2, dim=1) or torch.sqrt(((x1 - x2) ** 2).sum(dim=1)) computation until the patched release is deployed.
- Execute the operator under torch.compile where the numerical path differs from eager mode, after validating output correctness for the workload.
- Pin PyTorch versions in dependency manifests to prevent silent regressions and require review before upgrading past the fix boundary.
# Configuration example
pip install --upgrade "torch>2.6.0"
python -c "import torch; print(torch.__version__)"
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

