2.5low
Heap buffer overflow 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-4278-2v5v-65r4BIT-TENSORFLOW-2021-29512PYSEC-2021-149PYSEC-2021-440PYSEC-2021-638
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
| Product or package | Versions | Reported by |
|---|---|---|
| tensorflow tensorflow | >=2.3.0, < 2.3.3, >= 2.4.0, < 2.4.2 | CVE List |
| tensorflow (PyPI) | from 2.3.0 before 2.3.3, from 2.4.0 before 2.4.2, before eebb96c2830d48597d055d247c0e9aebaea94cd5 | GitHub 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 | GitHub 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 | GitHub Advisory Database, PyPA Advisory Database |
| google tensorflow | from 2.3.0 before 2.3.3, from 2.4.0 before 2.4.2 | NVD |
| tensorflow (Bitnami) | from 2.3.0 before 2.3.3, from 2.4.0 before 2.4.2 | Bitnami Vulnerability Database |
All scores
| GitHub_M | 2.5low CVSS:3.1 | CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:N/A:L |
| GitHub | 2.5low CVSS:3.1 | CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:N/A:L |
| GitHub | low CVSS:4.0 | CVSS:4.0/AV:L/AC:L/AT:P/PR:L/UI:P/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N |
| NVD | 7.8high CVSS:3.1 | CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H |
| NVD | 4.6medium CVSS:2.0 | AV:L/AC:L/Au:N/C:P/I:P/A:P |
| Bitnami Vulnerability Database | high 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-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.
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=[0], values=[1,1,1,1,1], size=5, weights=[1,2,3,4], 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++;
}
...
}
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.
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. 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. 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-L433). Antes del bucle "for","batch_idx" es ajustado en 0. El usuario controla la matriz "splits", haciendo que contenga solo un elemento, 0. Por lo tanto, el código en el bucle "while" incrementaría "batch_idx" y luego intenta leer "splits(1)", que está fuera de límites. La corrección será incluída en TensorFlow versión 2.5.0. También seleccionaremos este commit en TensorFlow versión 2.4.2 y TensorFlow versión 2.3.3, ya que estos también están afectados
References
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2021-29512 changed 2024-08-03 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-4278-2v5v-65r4 changed 2026-07-08 | CC-BY-4.0 |
| NVD | CVE-2021-29512 changed 2026-06-17 | Public domain |
| PyPA Advisory Database | PYSEC-2021-149 changed 2023-12-06 | CC-BY-4.0 |
| PyPA Advisory Database | PYSEC-2021-440 changed 2023-12-06 | CC-BY-4.0 |
| PyPA Advisory Database | PYSEC-2021-638 changed 2023-12-06 | CC-BY-4.0 |
| Bitnami Vulnerability Database | BIT-TENSORFLOW-2021-29512 changed 2026-09-08 | Apache-2.0 |