CVE-2021-41197
JSON

5.5medium

Crashes due to overflow and `CHECK`-fail in ops with large tensor shapes

Severity
5.5medium CVSS:3.1 by GitHub_M
Exploit likelihood
0.32% (higher than 26% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
GitHub_M
Also known as
GHSA-prcg-wp5q-rv7pBIT-TENSORFLOW-2021-41197PYSEC-2021-390PYSEC-2021-607PYSEC-2021-805

Description

TensorFlow is an open source platform for machine learning. In affected versions TensorFlow allows tensor to have a large number of dimensions and each dimension can be as large as desired. However, the total number of elements in a tensor must fit within an `int64_t`. If an overflow occurs, `MultiplyWithoutOverflow` would return a negative result. In the majority of TensorFlow codebase this then results in a `CHECK`-failure. Newer constructs exist which return a `Status` instead of crashing the binary. This is similar to CVE-2021-29584. The fix will be included in TensorFlow 2.7.0. We will also cherrypick this commit on TensorFlow 2.6.1, TensorFlow 2.5.2, and TensorFlow 2.4.4, as these are also affected and still in supported range.

Affected

Product or packageVersionsReported by
tensorflow tensorflow>= 2.6.0, < 2.6.1, >= 2.5.0, < 2.5.2, < 2.4.4CVE List
tensorflow (PyPI)from 2.6.0 before 2.6.1, from 2.5.0 before 2.5.2, before 2.4.4, before a871989d7b6c18cdebf2fb4f0e5c5b62fbc19edf, before d81b1351da3e8c884ff836b64458d94e4a157c15, before 7c1692bd417eb4f9b33ead749a41166d6080af85, from 2.7.0rc0 before 2.7.0GitHub Advisory Database, PyPA Advisory Database
tensorflow-cpu (PyPI)from 2.6.0 before 2.6.1, from 2.5.0 before 2.5.2, before 2.4.4, before a871989d7b6c18cdebf2fb4f0e5c5b62fbc19edf, before d81b1351da3e8c884ff836b64458d94e4a157c15, before 7c1692bd417eb4f9b33ead749a41166d6080af85, from 2.7.0rc0 before 2.7.0GitHub Advisory Database, PyPA Advisory Database
tensorflow-gpu (PyPI)from 2.6.0 before 2.6.1, from 2.5.0 before 2.5.2, before 2.4.4, before a871989d7b6c18cdebf2fb4f0e5c5b62fbc19edf, before d81b1351da3e8c884ff836b64458d94e4a157c15, before 7c1692bd417eb4f9b33ead749a41166d6080af85, from 2.7.0rc0 before 2.7.0GitHub Advisory Database, PyPA Advisory Database
google tensorflowbefore 2.4.4, from 2.5.0 before 2.5.2, from 2.6.0 before 2.6.1NVD
tensorflow (Bitnami)before 2.4.4, from 2.5.0 before 2.5.2, from 2.6.0 before 2.6.1Bitnami Vulnerability Database

All scores

GitHub_M5.5medium CVSS:3.1CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H
GitHub5.5medium CVSS:3.1CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H
GitHubmedium CVSS:4.0CVSS:4.0/AV:L/AC:L/AT:N/PR:L/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N
NVD5.5medium CVSS:3.1CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H
NVD2.1low CVSS:2.0AV:L/AC:L/Au:N/C:N/I:N/A:P
Bitnami Vulnerability Databasemedium rating

Classification

What each source says

CVE List

TensorFlow is an open source platform for machine learning. In affected versions TensorFlow allows tensor to have a large number of dimensions and each dimension can be as large as desired. However, the total number of elements in a tensor must fit within an `int64_t`. If an overflow occurs, `MultiplyWithoutOverflow` would return a negative result. In the majority of TensorFlow codebase this then results in a `CHECK`-failure. Newer constructs exist which return a `Status` instead of crashing the binary. This is similar to CVE-2021-29584. The fix will be included in TensorFlow 2.7.0. We will also cherrypick this commit on TensorFlow 2.6.1, TensorFlow 2.5.2, and TensorFlow 2.4.4, as these are also affected and still in supported range.

GitHub Advisory Database
Impact

TensorFlow allows tensor to have a large number of dimensions and each dimension can be as large as desired. However, the total number of elements in a tensor must fit within an int64_t. If an overflow occurs, MultiplyWithoutOverflow would return a negative result. In the majority of TensorFlow codebase this then results in a CHECK-failure. Newer constructs exist which return a Status instead of crashing the binary.

For example AddDim calls should be replaced by AddDimWithStatus.

This is similar to CVE-2021-29584 (and similar other reported vulnerabilities in TensorFlow, localized to specific APIs).

Patches

We have patched the issue in GitHub commits 7c1692bd417eb4f9b33ead749a41166d6080af85 (merging #51732), d81b1351da3e8c884ff836b64458d94e4a157c15 (merging #51717), a871989d7b6c18cdebf2fb4f0e5c5b62fbc19edf (merging #51658), and d81b1351da3e8c884ff836b64458d94e4a157c15 (merging #51973). It is possible that other similar instances exist in TensorFlow, we will issue fixes as these are discovered.

The fix will be included in TensorFlow 2.7.0. We will also cherrypick this commit on TensorFlow 2.6.1, TensorFlow 2.5.2, and TensorFlow 2.4.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 externally via GitHub issue, GitHub issue and GitHub issue.

NVD (es)

TensorFlow es una plataforma de código abierto para el aprendizaje automático. En las versiones afectadas TensorFlow permite que el tensor tenga un gran número de dimensiones y cada dimensión puede ser tan grande como se desee. Sin embargo, el número total de elementos en un tensor debe caber dentro de un "int64_t". Si se produce un desbordamiento, "MultiplyWithoutOverflow" devolverá un resultado negativo. En la mayoría de los códigos de TensorFlow esto resulta en un fallo de "CHECK". Se presentan nuevas construcciones que devuelven un "Status" en lugar de bloquear el binario. Esto es similar a CVE-2021-29584. La corrección será incluida en TensorFlow versión 2.7.0. También será incluida este commit en TensorFlow versión 2.6.1, TensorFlow versión 2.5.2, y TensorFlow versión 2.4.4, ya que estos también están afectados y todavía están en el rango admitido

References

https://github.com/tensorflow/tensorflow/security/advisories/GHSA-prcg-wp5q-rv7padvisory, patch, third-party-advisory, web
https://github.com/tensorflow/tensorflow/issues/46890advisory, exploit, report, third-party-advisory, web
https://github.com/tensorflow/tensorflow/issues/51908advisory, exploit, report, third-party-advisory, web
https://github.com/tensorflow/tensorflow/commit/7c1692bd417eb4f9b33ead749a41166d6080af85advisory, fix, patch, third-party-advisory, web
https://github.com/tensorflow/tensorflow/commit/a871989d7b6c18cdebf2fb4f0e5c5b62fbc19edfadvisory, fix, patch, third-party-advisory, web
https://github.com/tensorflow/tensorflow/commit/d81b1351da3e8c884ff836b64458d94e4a157c15advisory, fix, patch, third-party-advisory, web
https://nvd.nist.gov/vuln/detail/CVE-2021-41197advisory, web
https://github.com/pypa/advisory-database/tree/main/vulns/tensorflow-cpu/PYSEC-2021-607.yamlweb
https://github.com/pypa/advisory-database/tree/main/vulns/tensorflow-gpu/PYSEC-2021-805.yamlweb
https://github.com/pypa/advisory-database/tree/main/vulns/tensorflow/PYSEC-2021-390.yamlweb
https://github.com/tensorflow/tensorflowpackage

Sources

SourceRecordLicence
CVE ListCVE-2021-41197 changed 2024-08-04CVE Terms of Use
GitHub Advisory DatabaseGHSA-prcg-wp5q-rv7p changed 2026-07-08CC-BY-4.0
NVDCVE-2021-41197 changed 2026-06-17Public domain
PyPA Advisory DatabasePYSEC-2021-390 changed 2023-12-06CC-BY-4.0
PyPA Advisory DatabasePYSEC-2021-607 changed 2023-12-06CC-BY-4.0
PyPA Advisory DatabasePYSEC-2021-805 changed 2023-12-06CC-BY-4.0
Bitnami Vulnerability DatabaseBIT-TENSORFLOW-2021-41197 changed 2026-09-08Apache-2.0