CVE-2022-29211: TensorFlow - Segfault if `tf.histogram_fixed_width` is called with NaN values
Summary
CVE-2022-29211: Segfault if tf.histogram_fixed_width is called with NaN values in TensorFlow. Affects tensorflow across 3 version ranges.
< 2.6.4
>= 2.7.0, < 2.7.2
>= 2.8.0, < 2.8.1
Fixed in 2.6.4, 2.7.2 or 2.8.1, depending on the release line you run. How to fix ↓
Also tracked for
- tensorflow-cpu · PyPI
- tensorflow-gpu · PyPI
- tensorflow · Bitnami
The same CVE-2022-29211 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.
Check if this vulnerability affects your application
Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.
No signup required · Results in about 60 seconds
Background
TensorFlow is an open-source machine learning framework developed by Google. It provides a comprehensive ecosystem of tools, libraries, and resources for building and deploying machine learning models. TensorFlow is widely used in various domains, including research, industry, and academia. However, a vulnerability has been discovered in the implementation of tf.histogram_fixed_width function, which can lead to a segfault when called with NaN (Not a Number) values. This vulnerability affects versions 0 to 2.6.4 of TensorFlow, TensorFlow CPU, TensorFlow GPU, as well as versions 2.7.0 to 2.7.2 and 2.8.0 to 2.8.1 of TensorFlow CPU and TensorFlow GPU.
Vulnerability Detail
The vulnerability arises from the assumption made in the implementation of tf.histogram_fixed_width that all floating-point operations are defined. When the values array passed to the function contains NaN elements, the division operation results in NaN, and the subsequent cast to int32 leads to a crash. This vulnerability affects the CPU implementation of TensorFlow. An attacker could potentially exploit this vulnerability to cause a denial-of-service (DoS) condition or execute arbitrary code on a vulnerable system.
How To Fix
Latest published version: 2.21.0 as of 22 Oct 2026
pip install --upgrade "tensorflow==2.21.0"
Upgrading to it may include breaking changes; the versions below are the minimum fixed release for this vulnerability.
If you can't move to the latest
The minimum fixed version depends on the release line you run.
-
< 2.6.42.6.4pip install --upgrade "tensorflow==2.6.4" -
>= 2.7.0, < 2.7.22.7.2pip install --upgrade "tensorflow==2.7.2" -
>= 2.8.0, < 2.8.12.8.1pip install --upgrade "tensorflow==2.8.1"
Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →
Workaround
As a workaround, users can check for NaN values in the values array before calling tf.histogram_fixed_width. If NaN values are present, they can be replaced with a suitable default value or removed from the array. Here's an example of how to check for NaN values and replace them with zeros:
import tensorflow as tf
import numpy as np
values = np.array([1.0, 2.0, np.nan, 3.0])
values[np.isnan(values)] = 0.0
tf.histogram_fixed_width(values=values, value_range=[1, 3])
Conclusion
The vulnerability in TensorFlow's tf.histogram_fixed_width function can lead to a segfault when called with NaN values. It is recommended to update your TensorFlow installation to the fixed versions or apply the provided workaround. For further assistance or support in vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for tensorflow →
FAQ
TensorFlow is an open-source machine learning framework developed by Google. It provides a comprehensive ecosystem of tools, libraries, and resources for building and deploying machine learning models.
The vulnerability can lead to a segfault when the tf.histogram_fixed_width function is called with NaN values. This can result in a denial-of-service (DoS) condition or allow an attacker to execute arbitrary code on a vulnerable system.
Versions 0 to 2.6.4 of TensorFlow, TensorFlow CPU, TensorFlow GPU, as well as versions 2.7.0 to 2.7.2 and 2.8.0 to 2.8.1 of TensorFlow CPU and TensorFlow GPU are affected.
Yes, the vulnerability has been patched in TensorFlow commit e57fd691c7b0fd00ea3bfe43444f30c1969748b5. The fix will be included in TensorFlow 2.9.0. For versions 2.6.4, 2.7.2, and 2.8.1, the fix has been cherrypicked and included.
To update your TensorFlow installation, you can run the following command:
pip install --upgrade tensorflow
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow.