VYPR
High severityNVD Advisory· Published Nov 5, 2021· Updated Aug 4, 2024

Heap OOB read in `tf.raw_ops.SparseCountSparseOutput`

CVE-2021-41210

Description

TensorFlow is an open source platform for machine learning. In affected versions the shape inference functions for SparseCountSparseOutput can trigger a read outside of bounds of heap allocated array. The fix will be included in TensorFlow 2.7.0. We will also cherrypick this commit on TensorFlow 2.6.1, TensorFlow 2.5.2, and TensorFlow 2.4.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.6.0, < 2.6.12.6.1
tensorflowPyPI
>= 2.5.0, < 2.5.22.5.2
tensorflowPyPI
< 2.4.42.4.4
tensorflow-cpuPyPI
>= 2.6.0, < 2.6.12.6.1
tensorflow-cpuPyPI
>= 2.5.0, < 2.5.22.5.2
tensorflow-cpuPyPI
< 2.4.42.4.4
tensorflow-gpuPyPI
>= 2.6.0, < 2.6.12.6.1
tensorflow-gpuPyPI
>= 2.5.0, < 2.5.22.5.2
tensorflow-gpuPyPI
< 2.4.42.4.4

Affected products

1

Patches

1
701cfaca222a

Fix heap out of bounds error in tf.raw_ops.SparseCountSparseOutput shape inference when it is called with invalid inputs, and add a test for it.

https://github.com/tensorflow/tensorflowRobert NealeOct 26, 2021via ghsa
2 files changed · +21 0
  • tensorflow/core/ops/count_ops.cc+2 0 modified
    @@ -41,6 +41,8 @@ Status DenseCountSparseOutputShapeFn(InferenceContext *c) {
     }
     
     Status SparseCountSparseOutputShapeFn(InferenceContext *c) {
    +  ShapeHandle unused;
    +  TF_RETURN_IF_ERROR(c->WithRank(c->input(0), 2, &unused));
       auto rank = c->Dim(c->input(0), 1);
       auto nvals = c->UnknownDim();
       c->set_output(0, c->Matrix(nvals, rank));  // out.indices
    
  • tensorflow/python/ops/bincount_ops_test.py+19 0 modified
    @@ -831,6 +831,25 @@ def test_ragged_input_different_shape_fails(self):
           self.evaluate(bincount_ops.sparse_bincount(x, weights=weights, axis=-1))
     
     
    +class RawOpsHeapOobTest(test.TestCase, parameterized.TestCase):
    +
    +  @test_util.run_v1_only("Test security error")
    +  def testSparseCountSparseOutputBadIndicesShapeTooSmall(self):
    +    indices = [1]
    +    values = [[1]]
    +    weights = []
    +    dense_shape = [10]
    +    with self.assertRaisesRegex(ValueError,
    +                                "Shape must be rank 2 but is rank 1 for"):
    +      self.evaluate(
    +          gen_count_ops.SparseCountSparseOutput(
    +              indices=indices,
    +              values=values,
    +              dense_shape=dense_shape,
    +              weights=weights,
    +              binary_output=True))
    +
    +
     @test_util.run_all_in_graph_and_eager_modes
     @test_util.disable_tfrt
     class RawOpsTest(test.TestCase, parameterized.TestCase):
    

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

7

News mentions

0

No linked articles in our index yet.