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

Heap OOB in `ResourceScatterUpdate` in TensorFlow

CVE-2021-37655

Description

TensorFlow is an end-to-end open source platform for machine learning. In affected versions an attacker can trigger a read from outside of bounds of heap allocated data by sending invalid arguments to tf.raw_ops.ResourceScatterUpdate. The implementation has an incomplete validation of the relationship between the shapes of indices and updates: instead of checking that the shape of indices is a prefix of the shape of updates (so that broadcasting can happen), code only checks that the number of elements in these two tensors are in a divisibility relationship. We have patched the issue in GitHub commit 01cff3f986259d661103412a20745928c727326f. 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
01cff3f98625

Fix heap OOB due to dimension mismatch in `ResourceScatterUpdate`

https://github.com/tensorflow/tensorflowMihai MaruseacAug 2, 2021via ghsa
1 file changed · +6 5
  • tensorflow/core/kernels/resource_variable_ops.cc+6 5 modified
    @@ -955,11 +955,12 @@ class ResourceScatterUpdateOp : public OpKernel {
                             params->dim_size(0), ")"));
           } else {
             int64_t num_updates = updates.NumElements();
    -        OP_REQUIRES(c, num_updates % N == 0,
    -                    errors::InvalidArgument(
    -                        "shape of indices (", indices.shape().DebugString(),
    -                        ") is not compatible with the shape of updates (",
    -                        updates.shape().DebugString(), ")"));
    +        OP_REQUIRES(
    +            c, TensorShapeUtils::StartsWith(updates.shape(), indices.shape()),
    +            errors::InvalidArgument(
    +                "The shape of indices (", indices.shape().DebugString(),
    +                ") must be a prefix of the shape of updates (",
    +                updates.shape().DebugString(), ")"));
             auto updates_flat = updates.shaped<T, 2>({N, num_updates / N});
     
             functor::ScatterFunctor<Device, T, Index, op> functor;
    

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.