VYPR
Moderate severityNVD Advisory· Published Nov 18, 2022· Updated Apr 22, 2025

`CHECK` fail via inputs in `SparseFillEmptyRowsGrad` in Tensorflow

CVE-2022-41898

Description

TensorFlow is an open source platform for machine learning. If SparseFillEmptyRowsGrad is given empty inputs, TensorFlow will crash. We have patched the issue in GitHub commit af4a6a3c8b95022c351edae94560acc61253a1b8. The fix will be included in TensorFlow 2.11. We will also cherrypick this commit on TensorFlow 2.10.1, 2.9.3, and TensorFlow 2.8.4, as these are also affected and still in supported range.

Affected packages

Versions sourced from the GitHub Security Advisory.

PackageAffected versionsPatched versions
tensorflowPyPI
< 2.8.42.8.4
tensorflowPyPI
>= 2.9.0, < 2.9.32.9.3
tensorflowPyPI
>= 2.10.0, < 2.10.12.10.1
tensorflow-cpuPyPI
< 2.8.42.8.4
tensorflow-gpuPyPI
< 2.8.42.8.4
tensorflow-cpuPyPI
>= 2.9.0, < 2.9.32.9.3
tensorflow-gpuPyPI
>= 2.9.0, < 2.9.32.9.3
tensorflow-cpuPyPI
>= 2.10.0, < 2.10.12.10.1
tensorflow-gpuPyPI
>= 2.10.0, < 2.10.12.10.1

Affected products

1

Patches

1
af4a6a3c8b95

Fix empty input crash for SparseFillEmptyRowsGrad.

https://github.com/tensorflow/tensorflowAntonio SanchezSep 30, 2022via ghsa
2 files changed · +33 17
  • tensorflow/core/kernels/sparse_fill_empty_rows_op_gpu.cu.cc+26 17 modified
    @@ -297,9 +297,12 @@ struct SparseFillEmptyRows<GPUDevice, T, Tindex> {
           empty_row_indicator = empty_row_indicator_t.vec<bool>().data();
         }
     
    -    TF_RETURN_IF_ERROR(wrap_kernel_call(ComputeEmptyRowIndicatorKernel<Tindex>,
    -                                        /*device=*/device, /*size=*/dense_rows,
    -                                        elements_per_row, empty_row_indicator));
    +    if (dense_rows > 0) {
    +      TF_RETURN_IF_ERROR(
    +          wrap_kernel_call(ComputeEmptyRowIndicatorKernel<Tindex>,
    +                           /*device=*/device, /*size=*/dense_rows,
    +                           elements_per_row, empty_row_indicator));
    +    }
     
         // For each row, the number of empty rows up to and including that row.
         Tensor num_empty_rows_through_t;
    @@ -405,14 +408,16 @@ struct SparseFillEmptyRows<GPUDevice, T, Tindex> {
                 done);
           }
     
    -      OP_REQUIRES_OK_ASYNC(
    -          context,
    -          wrap_kernel_call(ScatterNewElementsKernel<T, Tindex>,
    -                           /*device=*/device, /*size=*/dense_rows, rank,
    -                           default_value, num_empty_rows_through,
    -                           input_row_ends, empty_row_indicator, output_indices,
    -                           output_values),
    -          done);
    +      if (dense_rows > 0) {
    +        OP_REQUIRES_OK_ASYNC(
    +            context,
    +            wrap_kernel_call(ScatterNewElementsKernel<T, Tindex>,
    +                             /*device=*/device, /*size=*/dense_rows, rank,
    +                             default_value, num_empty_rows_through,
    +                             input_row_ends, empty_row_indicator,
    +                             output_indices, output_values),
    +            done);
    +      }
     
           done();
         };
    @@ -461,9 +466,11 @@ struct SparseFillEmptyRows<GPUDevice, T, Tindex> {
         TF_RETURN_IF_ERROR(
             context->allocate_temp(index_type, TensorShape({N}), &row_indices_t));
         auto row_indices = row_indices_t.flat<Tindex>();
    -    TF_RETURN_IF_ERROR(wrap_kernel_call(CopyRowIndicesKernel<Tindex>,
    -                                        /*device=*/device, /*size=*/N, rank,
    -                                        indices, row_indices));
    +    if (N > 0) {
    +      TF_RETURN_IF_ERROR(wrap_kernel_call(CopyRowIndicesKernel<Tindex>,
    +                                          /*device=*/device, /*size=*/N, rank,
    +                                          indices, row_indices));
    +    }
         // Allocate input_index_map.
         TF_RETURN_IF_ERROR(context->allocate_temp(index_type, TensorShape({N}),
                                                   input_index_map_t));
    @@ -528,9 +535,11 @@ struct SparseFillEmptyRowsGrad<GPUDevice, T, Tindex> {
         auto visited = visited_t.vec<bool>();
         visited.device(device) = visited.constant(false);
     
    -    TF_RETURN_IF_ERROR(wrap_kernel_call(
    -        GatherOriginalGradValuesKernel<T, Tindex>, /*device=*/device,
    -        /*size=*/N, reverse_index_map, grad_values, d_values, visited));
    +    if (N > 0) {
    +      TF_RETURN_IF_ERROR(wrap_kernel_call(
    +          GatherOriginalGradValuesKernel<T, Tindex>, /*device=*/device,
    +          /*size=*/N, reverse_index_map, grad_values, d_values, visited));
    +    }
     
         // Now we mask out the visited values and sum the remaining ones (which
         // correspond to the empty rows in the forward input) to compute
    
  • tensorflow/python/kernel_tests/sparse_ops/sparse_ops_test.py+7 0 modified
    @@ -514,6 +514,13 @@ def testFillNumber(self):
             self.assertAllEqual(empty_row_indicator_out,
                                 np.array([0, 0, 1, 0, 1]).astype(np.bool_))
     
    +  def testSparseFillEmptyRowsGradEmpty(self):
    +    with test_util.use_gpu():
    +      grad, _ = self.evaluate(
    +          sparse_ops.sparse_fill_empty_rows_grad(
    +              reverse_index_map=[], grad_values=[]))
    +      self.assertAllEqual(grad, [])
    +
       @test_util.run_deprecated_v1
       def testFillFloat(self):
         with self.session():
    

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

5

News mentions

0

No linked articles in our index yet.