CVE-2022-29211: TensorFlow - Segfault if `tf.histogram_fixed_width` is called with NaN values

tensorflow Updated 02 Oct 2025

Summary

24/05/2022
Yes i
Moderate
5.5

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

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.

Free scan

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.

Check my app free

No signup required · Results in about 60 seconds

Sponsored Devnack Your last release was probably never penetration tested Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

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.4 2.6.4
    pip install --upgrade "tensorflow==2.6.4"
  • >= 2.7.0, < 2.7.2 2.7.2
    pip install --upgrade "tensorflow==2.7.2"
  • >= 2.8.0, < 2.8.1 2.8.1
    pip 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 →

Share this vulnerability

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

Related vulnerabilities

Recent vulnerabilities recorded for tensorflow.

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.4 2.6.4
    pip install --upgrade "tensorflow==2.6.4"
  • >= 2.7.0, < 2.7.2 2.7.2
    pip install --upgrade "tensorflow==2.7.2"
  • >= 2.8.0, < 2.8.1 2.8.1
    pip 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 →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback