CVE-2021-37655
JSON

7.3high

Heap OOB in `ResourceScatterUpdate` in TensorFlow

Severity
7.3high CVSS:3.1 by GitHub_M
Exploit likelihood
0.17% (higher than 6% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
GitHub_M
Also known as
GHSA-7fvx-3jfc-2cpcBIT-TENSORFLOW-2021-37655PYSEC-2021-277PYSEC-2021-568PYSEC-2021-766

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](https://github.com/tensorflow/tensorflow/blob/f24faa153ad31a4b51578f8181d3aaab77a1ddeb/tensorflow/core/kernels/resource_variable_ops.cc#L919-L923) 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

Product or packageVersionsReported by
tensorflow tensorflow>= 2.5.0, < 2.5.1, >= 2.4.0, < 2.4.3, < 2.3.4CVE List
tensorflow (PyPI)before 2.3.4, from 2.4.0 before 2.4.3, from 2.5.0 before 2.5.1, before 01cff3f986259d661103412a20745928c727326f, from 2.3.0 before 2.3.4GitHub Advisory Database, PyPA Advisory Database
tensorflow-cpu (PyPI)before 2.3.4, from 2.4.0 before 2.4.3, from 2.5.0 before 2.5.1, before 01cff3f986259d661103412a20745928c727326f, from 2.3.0 before 2.3.4GitHub Advisory Database, PyPA Advisory Database
tensorflow-gpu (PyPI)before 2.3.4, from 2.4.0 before 2.4.3, from 2.5.0 before 2.5.1, before 01cff3f986259d661103412a20745928c727326f, from 2.3.0 before 2.3.4GitHub Advisory Database, PyPA Advisory Database
google tensorflowfrom 2.3.0 before 2.3.4, from 2.4.0 before 2.4.3, 2.5.0, 2.6.0NVD
tensorflow (Bitnami)from 2.3.0 before 2.3.4, from 2.4.0 before 2.4.3, from 2.5.0 before 2.5.1Bitnami Vulnerability Database

All scores

GitHub_M7.3high CVSS:3.1CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:L/A:H
GitHub7.3high CVSS:3.1CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:L/A:H
GitHubhigh CVSS:4.0CVSS:4.0/AV:L/AC:L/AT:N/PR:L/UI:N/VC:H/VI:L/VA:H/SC:N/SI:N/SA:N
NVD7.3high CVSS:3.1CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:L/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. 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](https://github.com/tensorflow/tensorflow/blob/f24faa153ad31a4b51578f8181d3aaab77a1ddeb/tensorflow/core/kernels/resource_variable_ops.cc#L919-L923) 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.

GitHub Advisory Database
Impact

An attacker can trigger a read from outside of bounds of heap allocated data by sending invalid arguments to tf.raw_ops.ResourceScatterUpdate:

import tensorflow as tf

v = tf.Variable([b'vvv'])
tf.raw_ops.ResourceScatterUpdate(
  resource=v.handle,
  indices=[0],
  updates=['1', '2', '3', '4', '5'])

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.

Patches

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.

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. En las versiones afectadas un atacante puede desencadenar una lectura desde fuera de límites de los datos asignados a la pila mediante el envío de argumentos no válidos a "tf.raw_ops.ResourceScatterUpdate". La [implementación](https://github.com/tensorflow/tensorflow/blob/f24faa153ad31a4b51578f8181d3aaab77a1ddeb/tensorflow/core/kernels/resource_variable_ops.cc#L919-L923) presenta una comprobación incompleta de la relación entre las formas de "índices" y "updates": en lugar de comprobar que la forma de "índices" es un prefijo de la forma de "updates" (para que pueda producirse la difusión), el código sólo comprueba que el número de elementos de estos dos tensores está en una relación de divisibilidad. Hemos parcheado el problema en el commit de GitHub 01cff3f986259d661103412a20745928c727326f. La corrección será incluida en TensorFlow versión 2.6.0. También seleccionaremos este commit en TensorFlow versión 2.5.1, TensorFlow versión 2.4.3, y TensorFlow versión 2.3.4, ya que estos también están afectados y todavía están en el rango de soporte.

References

Sources

SourceRecordLicence
CVE ListCVE-2021-37655 changed 2024-08-04CVE Terms of Use
GitHub Advisory DatabaseGHSA-7fvx-3jfc-2cpc changed 2026-07-08CC-BY-4.0
NVDCVE-2021-37655 changed 2026-06-17Public domain
PyPA Advisory DatabasePYSEC-2021-277 changed 2023-12-06CC-BY-4.0
PyPA Advisory DatabasePYSEC-2021-568 changed 2023-12-06CC-BY-4.0
PyPA Advisory DatabasePYSEC-2021-766 changed 2023-12-06CC-BY-4.0
Bitnami Vulnerability DatabaseBIT-TENSORFLOW-2021-37655 changed 2026-09-08Apache-2.0