CVE-2021-41195
JSON

5.5medium

Crash in `tf.math.segment_*` operations

Severity
5.5medium CVSS:3.1 by GitHub_M
Exploit likelihood
0.21% (higher than 12% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
GitHub_M
Also known as
GHSA-cq76-mxrc-vchhBIT-TENSORFLOW-2021-41195PYSEC-2021-842PYSEC-2021-844PYSEC-2021-846

Description

TensorFlow is an open source platform for machine learning. In affected versions the implementation of `tf.math.segment_*` operations results in a `CHECK`-fail related abort (and denial of service) if a segment id in `segment_ids` is large. This is similar to CVE-2021-29584 (and similar other reported vulnerabilities in TensorFlow, localized to specific APIs): the implementation (both on CPU and GPU) computes the output shape using `AddDim`. However, if the number of elements in the tensor overflows an `int64_t` value, `AddDim` results in a `CHECK` failure which provokes a `std::abort`. Instead, code should use `AddDimWithStatus`. 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 e9c81c1e1a9cd8dd31f4e83676cab61b60658429GitHub 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 e9c81c1e1a9cd8dd31f4e83676cab61b60658429GitHub 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 e9c81c1e1a9cd8dd31f4e83676cab61b60658429GitHub 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 the implementation of `tf.math.segment_*` operations results in a `CHECK`-fail related abort (and denial of service) if a segment id in `segment_ids` is large. This is similar to CVE-2021-29584 (and similar other reported vulnerabilities in TensorFlow, localized to specific APIs): the implementation (both on CPU and GPU) computes the output shape using `AddDim`. However, if the number of elements in the tensor overflows an `int64_t` value, `AddDim` results in a `CHECK` failure which provokes a `std::abort`. Instead, code should use `AddDimWithStatus`. 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

The implementation of tf.math.segment_* operations results in a CHECK-fail related abort (and denial of service) if a segment id in segment_ids is large.

import tensorflow as tf

tf.math.segment_max(data=np.ones((1,10,1)), segment_ids=[1676240524292489355])
tf.math.segment_min(data=np.ones((1,10,1)), segment_ids=[1676240524292489355])
tf.math.segment_mean(data=np.ones((1,10,1)), segment_ids=[1676240524292489355])    
tf.math.segment_sum(data=np.ones((1,10,1)), segment_ids=[1676240524292489355])
tf.math.segment_prod(data=np.ones((1,10,1)), segment_ids=[1676240524292489355])

This is similar to CVE-2021-29584 (and similar other reported vulnerabilities in TensorFlow, localized to specific APIs): the implementation (both on CPU and GPU) computes the output shape using AddDim. However, if the number of elements in the tensor overflows an int64_t value, AddDim results in a CHECK failure which provokes a std::abort. Instead, code should use AddDimWithStatus.

Patches

We have patched the issue in GitHub commit e9c81c1e1a9cd8dd31f4e83676cab61b60658429 (merging #51733).

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 a GitHub issue.

NVD (es)

TensorFlow es una plataforma de código abierto para el aprendizaje automático. En las versiones afectadas, la implementación de las operaciones "tf.math.segment_*" resulta en un aborto relacionado con el fallo "CHECK" (y a una denegación de servicio) si un id de segmento en "segment_ids" es grande. Esto es similar a CVE-2021-29584 (y otras vulnerabilidades similares reportadas en TensorFlow, localizadas en APIs específicas): la implementación (tanto en CPU como en GPU) computa la forma de salida usando "AddDim". Sin embargo, si el número de elementos en el tensor sobrepasa un valor "int64_t", "AddDim" resulta en un fallo "CHECK" que provoca un "std::abort". En su lugar, el código debería usar "AddDimWithStatus". 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-cq76-mxrc-vchhadvisory, exploit, third-party-advisory, web
https://github.com/tensorflow/tensorflow/issues/46888advisory, patch, report, third-party-advisory, web
https://github.com/tensorflow/tensorflow/pull/51733advisory, patch, third-party-advisory, web
https://github.com/tensorflow/tensorflow/commit/e9c81c1e1a9cd8dd31f4e83676cab61b60658429advisory, fix, patch, third-party-advisory, web
https://nvd.nist.gov/vuln/detail/CVE-2021-41195advisory, web
https://github.com/pypa/advisory-database/tree/main/vulns/tensorflow-cpu/PYSEC-2021-844.yamlweb
https://github.com/pypa/advisory-database/tree/main/vulns/tensorflow-gpu/PYSEC-2021-846.yamlweb
https://github.com/pypa/advisory-database/tree/main/vulns/tensorflow/PYSEC-2021-842.yamlweb
https://github.com/tensorflow/tensorflowpackage

Sources

SourceRecordLicence
CVE ListCVE-2021-41195 changed 2024-08-04CVE Terms of Use
GitHub Advisory DatabaseGHSA-cq76-mxrc-vchh changed 2026-07-08CC-BY-4.0
NVDCVE-2021-41195 changed 2026-06-17Public domain
PyPA Advisory DatabasePYSEC-2021-842 changed 2023-12-06CC-BY-4.0
PyPA Advisory DatabasePYSEC-2021-844 changed 2023-12-06CC-BY-4.0
PyPA Advisory DatabasePYSEC-2021-846 changed 2023-12-06CC-BY-4.0
Bitnami Vulnerability DatabaseBIT-TENSORFLOW-2021-41195 changed 2026-09-08Apache-2.0