VYPR
Low severityNVD Advisory· Published May 14, 2021· Updated Aug 3, 2024

Heap buffer overflow in `RaggedBinCount`

CVE-2021-29512

Description

TensorFlow is an end-to-end open source platform for machine learning. If the splits argument of RaggedBincount does not specify a valid SparseTensor(https://www.tensorflow.org/api_docs/python/tf/sparse/SparseTensor), then an attacker can trigger a heap buffer overflow. This will cause a read from outside the bounds of the splits tensor buffer in the implementation of the RaggedBincount op(https://github.com/tensorflow/tensorflow/blob/8b677d79167799f71c42fd3fa074476e0295413a/tensorflow/core/kernels/bincount_op.cc#L430-L433). Before the for loop, batch_idx is set to 0. The user controls the splits array, making it contain only one element, 0. Thus, the code in the while loop would increment batch_idx and then try to read splits(1), which is outside of bounds. The fix will be included in TensorFlow 2.5.0. We will also cherrypick this commit on TensorFlow 2.4.2 and TensorFlow 2.3.3, as these are also affected.

Affected packages

Versions sourced from the GitHub Security Advisory.

PackageAffected versionsPatched versions
tensorflowPyPI
>= 2.3.0, < 2.3.32.3.3
tensorflowPyPI
>= 2.4.0, < 2.4.22.4.2
tensorflow-cpuPyPI
>= 2.3.0, < 2.3.32.3.3
tensorflow-cpuPyPI
>= 2.4.0, < 2.4.22.4.2
tensorflow-gpuPyPI
>= 2.3.0, < 2.3.32.3.3
tensorflow-gpuPyPI
>= 2.4.0, < 2.4.22.4.2

Affected products

1

Patches

1
eebb96c2830d

Fix an invalid address vulnerability in `tf.raw_ops.RaggedBincount`.

https://github.com/tensorflow/tensorflowAmit PatankarApr 13, 2021via ghsa
1 file changed · +9 0
  • tensorflow/core/kernels/bincount_op.cc+9 0 modified
    @@ -420,6 +420,15 @@ class RaggedBincountOp : public OpKernel {
         int num_values = values.size();
         int batch_idx = 0;
     
    +    OP_REQUIRES(ctx, splits(0) == 0,
    +                errors::InvalidArgument("Splits must start with 0, not with ",
    +                                        splits(0)));
    +
    +    OP_REQUIRES(ctx, splits(num_rows) == num_values,
    +                errors::InvalidArgument(
    +                    "Splits must end with the number of values, got ",
    +                    splits(num_rows), " instead of ", num_values));
    +
         Tensor* out_t;
         OP_REQUIRES_OK(
             ctx, ctx->allocate_output(0, TensorShape({num_rows, size}), &out_t));
    

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.