CVE-2022-21729: TensorFlow UnravelIndex Division by Zero Vulnerability
Summary
CVE-2022-21729: Overflow and uncaught divide by zero in Tensorflow. Affects tensorflow across 3 version ranges.
< 2.5.3
>= 2.6.0, < 2.6.3
>= 2.7.0, < 2.7.1
Fixed in 2.5.3, 2.6.3 or 2.7.1, depending on the release line you run. How to fix ↓
Also tracked for
- tensorflow · Bitnami
- tensorflow-gpu · PyPI
- tensorflow-cpu · PyPI
The same CVE-2022-21729 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 library developed by Google, widely used for building and training machine learning models. It provides a comprehensive ecosystem for various tasks, including deep learning, neural networks, and data flow programming. However, TensorFlow has a vulnerability in its implementation of the UnravelIndex operation, which can lead to critical runtime errors.
Vulnerability Detail
The vulnerability arises from an integer overflow in the UnravelIndex implementation, which can lead to a division by zero error. This issue can be exploited by providing specific input values, such as negative indices or excessively large dimensions, resulting in undefined behavior or application crashes. This vulnerability poses a risk to applications relying on TensorFlow for machine learning tasks, potentially leading to data corruption or loss of service.
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.5.32.5.3pip install --upgrade "tensorflow==2.5.3" -
>= 2.6.0, < 2.6.32.6.3pip install --upgrade "tensorflow==2.6.3" -
>= 2.7.0, < 2.7.12.7.1pip install --upgrade "tensorflow==2.7.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 temporary workaround, avoid using negative indices or excessively large dimensions when calling the UnravelIndex operation. For example, instead of using: 'tf.raw_ops.UnravelIndex(indices=-0x100000, dims=[0x100000, 0x100000])', ensure that both indices and dimensions are within valid ranges.
Conclusion
The CVE-2022-21729 vulnerability in TensorFlow's UnravelIndex operation poses significant risks due to potential division by zero errors. It is crucial for users to update to the patched versions to mitigate these risks and ensure the stability and security of their applications.
See every vulnerability recorded for tensorflow →
FAQ
CVE-2022-21729 is a vulnerability in TensorFlow's UnravelIndex operation that can lead to a division by zero error due to integer overflow.
You can use Vulert's playground at Vulert Scanner to check if your application is affected by this vulnerability without requiring any signup.
Exploiting this vulnerability can lead to application crashes, undefined behavior, and potential data corruption.
Affected versions include TensorFlow 2.5.3, 2.6.0, 2.7.0, and earlier versions. The vulnerability has been patched in versions 2.5.3, 2.6.3, 2.7.1, and 2.8.0.
For reporting new vulnerabilities, consult TensorFlow's security guide available at https://github.com/tensorflow/tensorflow/blob/master/SECURITY.md.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow.