VYPR
Moderate severityNVD Advisory· Published Apr 16, 2025· Updated May 22, 2025

PyTorch LossCTC.cpp torch.nn.functional.ctc_loss denial of service

CVE-2025-3730

Description

A vulnerability, which was classified as problematic, was found in PyTorch 2.6.0. Affected is the function torch.nn.functional.ctc_loss of the file aten/src/ATen/native/LossCTC.cpp. The manipulation leads to denial of service. An attack has to be approached locally. The exploit has been disclosed to the public and may be used. The real existence of this vulnerability is still doubted at the moment. The name of the patch is 46fc5d8e360127361211cb237d5f9eef0223e567. It is recommended to apply a patch to fix this issue. The security policy of the project warns to use unknown models which might establish malicious effects.

Affected packages

Versions sourced from the GitHub Security Advisory.

PackageAffected versionsPatched versions
torchPyPI
< 2.8.02.8.0

Affected products

1

Patches

2
46fc5d8e3601

Add check for ctc_loss targets param (#150981)

https://github.com/timocafe/tewart-pytorchzeshengzongApr 14, 2025via ghsa
3 files changed · +11 0
  • aten/src/ATen/native/cuda/LossCTC.cu+1 0 modified
    @@ -219,6 +219,7 @@ ctc_loss_log_alpha_gpu_kernel(scalar_t* __restrict__ log_alpha_data,
     // backward. The dispatch function will only return the loss.
     template<typename scalar_t, ScalarType target_scalar_type>
     std::tuple<Tensor, Tensor> ctc_loss_gpu_template(const Tensor& log_probs, const Tensor& targets, IntArrayRef input_lengths, IntArrayRef target_lengths, int64_t BLANK) {
    +  TORCH_CHECK(log_probs.numel() > 0, "log_probs tensor must not be empty");
       // log_probs: input_len x batch_size x num_labels
       // targets [int64]: batch_size x target_length OR sum(target_lengths)
       CheckedFrom c = "ctc_loss_gpu";
    
  • aten/src/ATen/native/LossCTC.cpp+1 0 modified
    @@ -126,6 +126,7 @@ std::tuple<Tensor, Tensor, size_t, std::vector<int64_t>> ctc_loss_allocate_outpu
     // the alphas from the user by only returning the loss.
     template<typename scalar_t, ScalarType target_scalar_type>
     std::tuple<Tensor, Tensor> ctc_loss_cpu_template(const Tensor& log_probs, const Tensor& targets, IntArrayRef input_lengths, IntArrayRef target_lengths, int64_t BLANK) {
    +  TORCH_CHECK(log_probs.numel() > 0, "log_probs tensor must not be empty");
       // log_probs: input_len x batch_size x num_labels
       // targets [int64]: batch_size x target_length OR sum(target_lengths)
       constexpr scalar_t neginf = -std::numeric_limits<scalar_t>::infinity();
    
  • test/test_nn.py+9 0 modified
    @@ -11532,6 +11532,15 @@ def test_ctc_loss_cudnn_tensor(self, device):
             grad_cudnn, = torch.autograd.grad(loss_cudnn, log_probs, grad_out)
             self.assertEqual(grad_cudnn, grad_native, atol=1e-4, rtol=0)
     
    +    @expectedFailureMPS
    +    def test_ctc_loss_error(self, device):
    +        log_probs = torch.rand(0, 0, 4, device=device)
    +        targets = torch.tensor([], device=device, dtype=torch.long)
    +        input_lengths = torch.tensor([], device=device, dtype=torch.long)
    +        target_lengths = torch.tensor([], device=device, dtype=torch.long)
    +        with self.assertRaisesRegex(RuntimeError, "log_probs tensor must not be empty"):
    +            F.ctc_loss(log_probs, targets, input_lengths, target_lengths, reduction='none')
    +
         @expectedFailureMPS  # RuntimeError: LSTM with projections is not currently supported with MPS.
         @dtypesIfCUDA(torch.half, torch.float, torch.double)
         @dtypes(torch.float)
    
01f226bfb8f2

Add check for ctc_loss targets param (#150981)

https://github.com/pytorch/pytorchzeshengzongApr 14, 2025via ghsa
3 files changed · +11 0
  • aten/src/ATen/native/cuda/LossCTC.cu+1 0 modified
    @@ -219,6 +219,7 @@ ctc_loss_log_alpha_gpu_kernel(scalar_t* __restrict__ log_alpha_data,
     // backward. The dispatch function will only return the loss.
     template<typename scalar_t, ScalarType target_scalar_type>
     std::tuple<Tensor, Tensor> ctc_loss_gpu_template(const Tensor& log_probs, const Tensor& targets, IntArrayRef input_lengths, IntArrayRef target_lengths, int64_t BLANK) {
    +  TORCH_CHECK(log_probs.numel() > 0, "log_probs tensor must not be empty");
       // log_probs: input_len x batch_size x num_labels
       // targets [int64]: batch_size x target_length OR sum(target_lengths)
       CheckedFrom c = "ctc_loss_gpu";
    
  • aten/src/ATen/native/LossCTC.cpp+1 0 modified
    @@ -126,6 +126,7 @@ std::tuple<Tensor, Tensor, size_t, std::vector<int64_t>> ctc_loss_allocate_outpu
     // the alphas from the user by only returning the loss.
     template<typename scalar_t, ScalarType target_scalar_type>
     std::tuple<Tensor, Tensor> ctc_loss_cpu_template(const Tensor& log_probs, const Tensor& targets, IntArrayRef input_lengths, IntArrayRef target_lengths, int64_t BLANK) {
    +  TORCH_CHECK(log_probs.numel() > 0, "log_probs tensor must not be empty");
       // log_probs: input_len x batch_size x num_labels
       // targets [int64]: batch_size x target_length OR sum(target_lengths)
       constexpr scalar_t neginf = -std::numeric_limits<scalar_t>::infinity();
    
  • test/test_nn.py+9 0 modified
    @@ -11532,6 +11532,15 @@ def test_ctc_loss_cudnn_tensor(self, device):
             grad_cudnn, = torch.autograd.grad(loss_cudnn, log_probs, grad_out)
             self.assertEqual(grad_cudnn, grad_native, atol=1e-4, rtol=0)
     
    +    @expectedFailureMPS
    +    def test_ctc_loss_error(self, device):
    +        log_probs = torch.rand(0, 0, 4, device=device)
    +        targets = torch.tensor([], device=device, dtype=torch.long)
    +        input_lengths = torch.tensor([], device=device, dtype=torch.long)
    +        target_lengths = torch.tensor([], device=device, dtype=torch.long)
    +        with self.assertRaisesRegex(RuntimeError, "log_probs tensor must not be empty"):
    +            F.ctc_loss(log_probs, targets, input_lengths, target_lengths, reduction='none')
    +
         @expectedFailureMPS  # RuntimeError: LSTM with projections is not currently supported with MPS.
         @dtypesIfCUDA(torch.half, torch.float, torch.double)
         @dtypes(torch.float)
    

Vulnerability mechanics

Generated by null/stub on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.

References

10

News mentions

0

No linked articles in our index yet.