CVE-2021-37653: TensorFlow ResourceGather Floating Point Exception
Summary
CVE-2021-37653: TensorFlow is an end-to-end open source platform for machine learning. Affects tensorflow across 3 version ranges.
>= 2.3.0, < 2.3.4
>= 2.4.0, < 2.4.3
< ac117ee8a8ea57b73d34665cdf00ef3303bc0b11
Fixed in 2.3.4 or 2.4.3, depending on the release line you run. How to fix ↓
Also tracked for
- tensorflow · Bitnami
- tensorflow-cpu · PyPI
- tensorflow-gpu · PyPI
The same CVE-2021-37653 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 end-to-end open source platform for machine learning. 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. It allows developers to create and train machine learning models using high-level APIs and provides efficient execution on a variety of hardware platforms. However, a vulnerability has been discovered in TensorFlow that can lead to a crash when certain operations are performed on a resource variable.
Vulnerability Detail
The vulnerability (CVE-2021-37653) in TensorFlow arises from a floating point exception in the tf.raw_ops.ResourceGather function. The implementation of this function fails to check if the value of a variable, batch_size, is zero before dividing by it. This can trigger a floating point exception and result in a crash. An attacker can exploit this vulnerability by providing a malicious input that triggers the problematic code path. The impact of this vulnerability is a denial of service (DoS) condition, as it causes the TensorFlow application to crash. This can disrupt the normal operation of the machine learning system and potentially lead to data loss or other adverse effects.
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.3.0, < 2.3.42.3.4pip install --upgrade "tensorflow==2.3.4" -
>= 2.4.0, < 2.4.32.4.3pip install --upgrade "tensorflow==2.4.3"
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 manually modify the affected code in their TensorFlow installation to include the necessary check for zero batch_size before performing the division. Here is an example of the modified code:
# Original code
batch_size = compute_batch_size()
result = tf.raw_ops.ResourceGather(resource, indices, batch_size)
# Modified code
batch_size = compute_batch_size()
if batch_size != 0:
result = tf.raw_ops.ResourceGather(resource, indices, batch_size)
else:
result = None
Conclusion
The vulnerability (CVE-2021-37653) in TensorFlow's tf.raw_ops.ResourceGather function can be exploited to trigger a floating point exception and crash the TensorFlow application. To mitigate this vulnerability, users should update their TensorFlow installations to one of the patched versions. Alternatively, a workaround is available by modifying the affected code to include a check for zero batch_size before performing the division. For further assistance and support in vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for tensorflow →
FAQ
TensorFlow is an open source platform for machine learning that provides a comprehensive ecosystem of tools and libraries for building and deploying machine learning models.
The vulnerability can lead to a denial of service (DoS) condition, causing the TensorFlow application to crash and potentially disrupting the normal operation of the machine learning system.
An attacker can exploit this vulnerability by providing a malicious input that triggers the problematic code path, resulting in a floating point exception and a crash of the TensorFlow application.
No, the vulnerability affects TensorFlow versions 2.3.0 and above. The issue has been patched in TensorFlow 2.6.0, TensorFlow 2.5.1, TensorFlow 2.4.3, and TensorFlow 2.3.4.
To fix this vulnerability, update your TensorFlow installation to one of the patched versions: TensorFlow 2.6.0, TensorFlow 2.5.1, TensorFlow 2.4.3, or TensorFlow 2.3.4.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow.