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 package | Versions | Reported by |
|---|---|---|
| tensorflow tensorflow | >= 2.5.0, < 2.5.1, >= 2.4.0, < 2.4.3, < 2.3.4 | CVE 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.4 | GitHub 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.4 | GitHub 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.4 | GitHub Advisory Database, PyPA Advisory Database |
| google tensorflow | from 2.3.0 before 2.3.4, from 2.4.0 before 2.4.3, 2.5.0, 2.6.0 | NVD |
| 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.1 | Bitnami Vulnerability Database |
All scores
| GitHub_M | 6.6medium CVSS:3.1 | CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:H |
| GitHub | 6.6medium CVSS:3.1 | CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:H |
| GitHub | medium CVSS:4.0 | CVSS:4.0/AV:L/AC:L/AT:N/PR:L/UI:N/VC:L/VI:L/VA:H/SC:N/SI:N/SA:N |
| NVD | 6.6medium CVSS:3.1 | CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:H |
| NVD | 4.6medium CVSS:2.0 | AV:L/AC:L/Au:N/C:P/I:P/A:P |
| Bitnami Vulnerability Database | medium 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. 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". Las formas insertadas en esta estructura pertenecen a un contexto de inferencia que se limpia casi de inmediato; si el código ascendente intenta acceder a esta información de forma, puede desencadenar un fallo de segmento. "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. Este commit corrige eso al hacer una lógica similar en formas y tipos de salida. Hemos solucionado el problema en el commit de GitHub ee119d4a498979525046fba1c3dd3f13a039fbb1. 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 aún se encuentran en el rango admitido.
References
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2021-37690 changed 2024-08-04 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-3hxh-8cp2-g4hg changed 2026-07-08 | CC-BY-4.0 |
| NVD | CVE-2021-37690 changed 2026-06-17 | Public domain |
| PyPA Advisory Database | PYSEC-2021-312 changed 2023-12-06 | CC-BY-4.0 |
| PyPA Advisory Database | PYSEC-2021-603 changed 2023-12-06 | CC-BY-4.0 |
| PyPA Advisory Database | PYSEC-2021-801 changed 2023-12-06 | CC-BY-4.0 |
| Bitnami Vulnerability Database | BIT-TENSORFLOW-2021-37690 changed 2026-09-08 | Apache-2.0 |