CVE-2021-37690
JSON

6.6medium

Use after free and segfault in shape inference functions in TensorFlow

Severity
6.6medium CVSS:3.1 by GitHub_M
Exploit likelihood
0.16% (higher than 5% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
GitHub_M
Also known as
GHSA-3hxh-8cp2-g4hgBIT-TENSORFLOW-2021-37690PYSEC-2021-312PYSEC-2021-603PYSEC-2021-801

Description

TensorFlow is an end-to-end open source platform for machine learning. In affected versions when running shape functions, some functions (such as `MutableHashTableShape`) produce extra output information in the form of a `ShapeAndType` struct. The shapes embedded in this struct are owned by an inference context that is cleaned up almost immediately; if the upstream code attempts to access this shape information, it can trigger a segfault. `ShapeRefiner` is mitigating this for normal output shapes by cloning them (and thus putting the newly created shape under ownership of an inference context that will not die), but we were not doing the same for shapes and types. This commit fixes that by doing similar logic on output shapes and types. We have patched the issue in GitHub commit ee119d4a498979525046fba1c3dd3f13a039fbb1. 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 ee119d4a498979525046fba1c3dd3f13a039fbb1, 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 ee119d4a498979525046fba1c3dd3f13a039fbb1, 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 ee119d4a498979525046fba1c3dd3f13a039fbb1, 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_M6.6medium CVSS:3.1CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:H
GitHub6.6medium CVSS:3.1CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:H
GitHubmedium CVSS:4.0CVSS:4.0/AV:L/AC:L/AT:N/PR:L/UI:N/VC:L/VI:L/VA:H/SC:N/SI:N/SA:N
NVD6.6medium CVSS:3.1CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:H
NVD4.6medium CVSS:2.0AV:L/AC:L/Au:N/C:P/I:P/A:P
Bitnami Vulnerability Databasemedium rating

Classification

What each source says

CVE List

TensorFlow is an end-to-end open source platform for machine learning. In affected versions when running shape functions, some functions (such as `MutableHashTableShape`) produce extra output information in the form of a `ShapeAndType` struct. The shapes embedded in this struct are owned by an inference context that is cleaned up almost immediately; if the upstream code attempts to access this shape information, it can trigger a segfault. `ShapeRefiner` is mitigating this for normal output shapes by cloning them (and thus putting the newly created shape under ownership of an inference context that will not die), but we were not doing the same for shapes and types. This commit fixes that by doing similar logic on output shapes and types. We have patched the issue in GitHub commit ee119d4a498979525046fba1c3dd3f13a039fbb1. 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

When running shape functions, some functions (such as MutableHashTableShape) produce extra output information in the form of a ShapeAndType struct. The shapes embedded in this struct are owned by an inference context that is cleaned up almost immediately; if the upstream code attempts to access this shape information, it can trigger a segfault.

ShapeRefiner is mitigating this for normal output shapes by cloning them (and thus putting the newly created shape under ownership of an inference context that will not die), but we were not doing the same for shapes and types. This commit fixes that by doing similar logic on output shapes and types.

Patches

We have patched the issue in GitHub commit ee119d4a498979525046fba1c3dd3f13a039fbb1.

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.

NVD (es)

TensorFlow es una plataforma de código abierto de extremo a extremo para el aprendizaje automático.&#xa0;En las versiones afectadas cuando se ejecutan funciones de forma, algunas funciones (como "MutableHashTableShape") producen información de salida adicional en forma de una estructura" ShapeAndType".&#xa0;Las formas insertadas en esta estructura pertenecen a un contexto de inferencia que se limpia casi de inmediato;&#xa0;si el código ascendente intenta acceder a esta información de forma, puede desencadenar un fallo de segmento.&#xa0;"ShapeRefiner" está mitigando esto para las formas de salida normales al clonarlas (y así poner la forma recién creada bajo la propiedad de un contexto de inferencia que no morirá), pero no estábamos haciendo lo mismo para las formas y los tipos.&#xa0;Este commit corrige eso al hacer una lógica similar en formas y tipos de salida.&#xa0;Hemos solucionado el problema en el commit de GitHub ee119d4a498979525046fba1c3dd3f13a039fbb1.&#xa0;La corrección será incluida en TensorFlow versión 2.6.0.&#xa0;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 aún se encuentran en el rango admitido.

References

Sources

SourceRecordLicence
CVE ListCVE-2021-37690 changed 2024-08-04CVE Terms of Use
GitHub Advisory DatabaseGHSA-3hxh-8cp2-g4hg changed 2026-07-08CC-BY-4.0
NVDCVE-2021-37690 changed 2026-06-17Public domain
PyPA Advisory DatabasePYSEC-2021-312 changed 2023-12-06CC-BY-4.0
PyPA Advisory DatabasePYSEC-2021-603 changed 2023-12-06CC-BY-4.0
PyPA Advisory DatabasePYSEC-2021-801 changed 2023-12-06CC-BY-4.0
Bitnami Vulnerability DatabaseBIT-TENSORFLOW-2021-37690 changed 2026-09-08Apache-2.0