CVE-2022-21735: TensorFlow Division by Zero Vulnerability
Summary
CVE-2022-21735: Division 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-21735 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 library widely used for machine learning and deep learning applications. It provides a flexible ecosystem for building and deploying machine learning models. However, like any software, TensorFlow is not immune to vulnerabilities, which can lead to unexpected behaviors or crashes in applications that rely on it.
Vulnerability Detail
The vulnerability arises from the implementation of the FractionalMaxPool operation in TensorFlow, which can lead to a division by zero error. This issue can cause a TensorFlow process to crash, potentially disrupting applications that depend on its functionality. The vulnerability is triggered when specific parameters are passed to the FractionalMaxPool operation, particularly when the pooling ratio is set in a way that results in a division by zero.
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
If you cannot update TensorFlow immediately, you can avoid triggering the vulnerability by ensuring that the pooling ratio passed to the FractionalMaxPool operation does not lead to a division by zero. For example, avoid using pooling ratios that are too high or improperly configured. Here is an example of how to call the operation safely:
import tensorflow as tf import numpy as np
Ensure pooling_ratio is configured correctly
pooling_ratio = [1.0, 1.0, 1.0, 1.0] # Adjusted to avoid division by zero
result = tf.raw_ops.FractionalMaxPool( value=tf.constant(value=[[[[1, 4, 2, 3]]]], dtype=tf.int64), pooling_ratio=pooling_ratio, pseudo_random=False, overlapping=False, deterministic=False, seed=0, seed2=0, name=None
)
Conclusion
The CVE-2022-21735 vulnerability in TensorFlow poses a risk of crashing applications due to a division by zero error in the FractionalMaxPool operation. It is crucial to update to the patched versions or implement workarounds to mitigate this risk. Regular monitoring using tools like Vulert can help maintain the security of your applications.
See every vulnerability recorded for tensorflow →
FAQ
CVE-2022-21735 is a vulnerability in TensorFlow that can lead to a division by zero error, causing a crash in TensorFlow processes.
You can use Vulert to monitor and alert for open-source vulnerabilities in your software. Check your application against the vulnerability using the Vulert playground.
The vulnerability affects TensorFlow versions prior to 2.5.3, 2.6.3, and 2.7.1.
You can implement workarounds by ensuring that the pooling ratio in the FractionalMaxPool operation does not lead to a division by zero.
The CVSS score for this vulnerability is 6.5, indicating a moderate severity level.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow.