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

Heap out of bounds access in sparse reduction operations in TensorFlow

CVE-2021-37635

Description

TensorFlow is an end-to-end open source platform for machine learning. In affected versions the implementation of sparse reduction operations in TensorFlow can trigger accesses outside of bounds of heap allocated data. The implementation fails to validate that each reduction group does not overflow and that each corresponding index does not point to outside the bounds of the input tensor. We have patched the issue in GitHub commit 87158f43f05f2720a374f3e6d22a7aaa3a33f750. The fix will be included in TensorFlow 2.6.0. We will also cherrypick this commit on TensorFlow 2.5.1, TensorFlow 2.4.3, and TensorFlow 2.3.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.3.42.3.4
tensorflowPyPI
>= 2.4.0, < 2.4.32.4.3
tensorflowPyPI
>= 2.5.0, < 2.5.12.5.1
tensorflow-cpuPyPI
< 2.3.42.3.4
tensorflow-cpuPyPI
>= 2.4.0, < 2.4.32.4.3
tensorflow-cpuPyPI
>= 2.5.0, < 2.5.12.5.1
tensorflow-gpuPyPI
< 2.3.42.3.4
tensorflow-gpuPyPI
>= 2.4.0, < 2.4.32.4.3
tensorflow-gpuPyPI
>= 2.5.0, < 2.5.12.5.1

Affected products

1

Patches

1
87158f43f05f

Prevent heap OOB in sparse reduction ops.

https://github.com/tensorflow/tensorflowMihai MaruseacJul 31, 2021via ghsa
1 file changed · +13 0
  • tensorflow/core/kernels/sparse_reduce_op.cc+13 0 modified
    @@ -219,7 +219,20 @@ class SparseReduceOp : public OpKernel {
         sp.Reorder<T>(reduction.reorder_dims);
         for (const auto &g : sp.group(reduction.group_by_dims)) {
           Op::template Run<T>(ctx, reduced_val, g.template values<T>());
    +      OP_REQUIRES(ctx,
    +                  output_strides.empty() ||
    +                  (g.group().size() == output_strides.size()),
    +                  errors::Internal(
    +                      "Expected group size and output_strides size to match",
    +                      ", but got ", g.group().size(), " and ",
    +                      output_strides.size()));
           const int64_t idx = CoordinatesToFlatIndex(g.group(), output_strides);
    +      OP_REQUIRES(ctx,
    +                  idx >= 0 && idx < out_flat.size(),
    +                  errors::Internal(
    +                      "Obtained a write index of ", idx,
    +                      " which is outside of bounds of [0, ",
    +                      out_flat.size(), ")"));
           out_flat(idx) = reduced_val();
           VLOG(2) << "coords: " << absl::StrJoin(g.group(), ",")
                   << "; idx: " << idx << "; group " << Op::Name() << ": "
    

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.