CVE-2021-29514
JSON

2.5low

Heap out of bounds write in `RaggedBinCount`

Severity
2.5low CVSS:3.1 by GitHub_M
Exploit likelihood
0.21% (higher than 11% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
GitHub_M
Also known as
GHSA-8h46-5m9h-7553BIT-TENSORFLOW-2021-29514PYSEC-2021-151PYSEC-2021-442PYSEC-2021-640

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-L446). Before the `for` loop, `batch_idx` is set to 0. The attacker sets `splits(0)` to be 7, hence the `while` loop does not execute and `batch_idx` remains 0. This then results in writing to `out(-1, bin)`, which is before the heap allocated buffer for the output tensor. 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

Product or packageVersionsReported by
tensorflow tensorflow< 2.3.3, >= 2.4.0, < 2.4.2CVE List
tensorflow (PyPI)from 2.3.0 before 2.3.3, from 2.4.0 before 2.4.2, before eebb96c2830d48597d055d247c0e9aebaea94cd5, before 2.2.0rc0, from 2.2.0 before 2.3.0rc0, from 2.3.0 before 2.3.4, from 2.4.0 before 2.4.3GitHub Advisory Database, PyPA Advisory Database
tensorflow-cpu (PyPI)from 2.3.0 before 2.3.3, from 2.4.0 before 2.4.2, before eebb96c2830d48597d055d247c0e9aebaea94cd5, before 2.2.0rc0, from 2.2.0 before 2.3.0rc0, from 2.3.0 before 2.3.4, from 2.4.0 before 2.4.3GitHub Advisory Database, PyPA Advisory Database
tensorflow-gpu (PyPI)from 2.3.0 before 2.3.3, from 2.4.0 before 2.4.2, before eebb96c2830d48597d055d247c0e9aebaea94cd5, before 2.2.0rc0, from 2.2.0 before 2.3.0rc0, from 2.3.0 before 2.3.4, from 2.4.0 before 2.4.3GitHub Advisory Database, PyPA Advisory Database
google tensorflowfrom 2.3.0 before 2.3.3, from 2.4.0 before 2.4.2NVD
tensorflow (Bitnami)from 2.3.0 before 2.3.3, from 2.4.0 before 2.4.2Bitnami Vulnerability Database

All scores

GitHub_M2.5low CVSS:3.1CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:N/A:L
GitHub2.5low CVSS:3.1CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:N/A:L
GitHublow CVSS:4.0CVSS:4.0/AV:L/AC:L/AT:P/PR:L/UI:P/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N
NVD7.8high CVSS:3.1CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
NVD4.6medium CVSS:2.0AV:L/AC:L/Au:N/C:P/I:P/A:P
Bitnami Vulnerability Databasehigh rating

Classification

What each source says

CVE List

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-L446). Before the `for` loop, `batch_idx` is set to 0. The attacker sets `splits(0)` to be 7, hence the `while` loop does not execute and `batch_idx` remains 0. This then results in writing to `out(-1, bin)`, which is before the heap allocated buffer for the output tensor. 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.

GitHub Advisory Database
Impact

If the splits argument of RaggedBincount does not specify a valid SparseTensor, then an attacker can trigger a heap buffer overflow:

import tensorflow as tf
tf.raw_ops.RaggedBincount(splits=[7,8], values= [5, 16, 51, 76, 29, 27, 54, 95],\
                          size= 59, weights= [0, 0, 0, 0, 0, 0, 0, 0],\
                          binary_output=False)

This will cause a read from outside the bounds of the splits tensor buffer in the implementation of the RaggedBincount op:

    for (int idx = 0; idx < num_values; ++idx) {
      while (idx >= splits(batch_idx)) {
        batch_idx++;
      }
      ...
      if (bin < size) {
        if (binary_output_) {
          out(batch_idx - 1, bin) = T(1);
        } else {
          T value = (weights_size > 0) ? weights(idx) : T(1);
          out(batch_idx - 1, bin) += value;
        }
      } 
    }

Before the for loop, batch_idx is set to 0. The attacker sets splits(0) to be 7, hence the while loop does not execute and batch_idx remains 0. This then results in writing to out(-1, bin), which is before the heap allocated buffer for the output tensor.

Patches

We have patched the issue in GitHub commit eebb96c2830d48597d055d247c0e9aebaea94cd5.

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.

For more information

Please consult our security guide for more information regarding the security model and how to contact us with issues and questions.

Attribution

This vulnerability has been reported by members of the Aivul Team from Qihoo 360.

NVD (es)

TensorFlow es una plataforma de código abierto de extremo a extremo para el aprendizaje automático.&#xa0;Si el argumento "splits" de "RaggedBincount" no especifica un "SparseTensor" válido (https://www.tensorflow.org/api_docs/python/tf/sparse/SparseTensor), entonces un atacante puede desencadenar un desbordamiento del búfer de la pila.&#xa0;Esto causará una lectura desde fuera de límites del búfer tensorial "splits" en una implementación de la operación "RaggedBincount" (https://github.com/tensorflow/tensorflow/blob/8b677d79167799f71c42fd3fa074476e0295413a/tensorflow/core/kernels/bincount_op. cc#L430-L446).&#xa0;Antes del bucle "for", "batch_idx" es establecido en 0. El atacante establece "splits (0)" en 7, por lo tanto, el bucle "while" no se ejecuta y "batch_idx" permanece en 0. Esto resulta en una escritura en "out (-1, bin)", que está ubicado antes del búfer asignado a la pila para el tensor de salida.&#xa0;La corrección será incluída en TensorFlow versión 2.5.0

References

Sources

SourceRecordLicence
CVE ListCVE-2021-29514 changed 2024-08-03CVE Terms of Use
GitHub Advisory DatabaseGHSA-8h46-5m9h-7553 changed 2026-07-08CC-BY-4.0
NVDCVE-2021-29514 changed 2026-06-17Public domain
PyPA Advisory DatabasePYSEC-2021-151 changed 2023-12-06CC-BY-4.0
PyPA Advisory DatabasePYSEC-2021-442 changed 2023-12-06CC-BY-4.0
PyPA Advisory DatabasePYSEC-2021-640 changed 2023-12-06CC-BY-4.0
Bitnami Vulnerability DatabaseBIT-TENSORFLOW-2021-29514 changed 2026-09-08Apache-2.0