CVE-2021-37660: Division by 0 in inplace operations in TensorFlow
Summary
CVE-2021-37660: Division by 0 in inplace operations. Affects tensorflow across 3 version ranges.
< 2.3.4
>= 2.4.0, < 2.4.3
>= 2.5.0, < 2.5.1
Fixed in 2.3.4, 2.4.3 or 2.5.1, 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-37660 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 widely used for developing and training deep learning models. It provides a comprehensive set of tools and libraries for building and deploying machine learning applications. TensorFlow is available for multiple programming languages, including Python, C++, and Java. This vulnerability affects the TensorFlow package and its variants, including tensorflow-cpu and tensorflow-gpu.
Vulnerability Detail
The vulnerability (CVE-2021-37660) in TensorFlow arises from a logic error in the implementation of inplace operations. An attacker can exploit this vulnerability by calling inplace operations with crafted arguments that result in a division by zero. For example, the following code snippet triggers the vulnerability:
import tensorflow as tf
tf.raw_ops.InplaceSub(x=[],i=[-99,-1,-1],v=[1,1,1])
When x and v are empty, the code should skip processing. However, due to the logic error, the code proceeds and triggers a floating-point exception. This vulnerability can be leveraged by an attacker to cause a denial of service (DoS) attack or potentially execute arbitrary code.
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.42.3.4pip install --upgrade "tensorflow==2.3.4" -
>= 2.4.0, < 2.4.32.4.3pip install --upgrade "tensorflow==2.4.3" -
>= 2.5.0, < 2.5.12.5.1pip install --upgrade "tensorflow==2.5.1"
Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →
Workaround
There is no known workaround for this vulnerability. It is recommended to update to the patched versions of TensorFlow as soon as possible.
Conclusion
In conclusion, the vulnerability (CVE-2021-37660) in TensorFlow allows an attacker to trigger a floating-point exception by exploiting a logic error in inplace operations. This can lead to a denial of service (DoS) attack or potential arbitrary code execution. Users are advised to update their TensorFlow installation to one of the patched versions mentioned above to mitigate the risk. For further support on vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for tensorflow →
FAQ
TensorFlow is an open-source machine learning framework used for developing and training deep learning models.
This vulnerability allows an attacker to trigger a floating-point exception by calling inplace operations with crafted arguments, potentially leading to a denial of service (DoS) attack or arbitrary code execution.
To fix this vulnerability, update your TensorFlow installation to one of the patched versions: TensorFlow 2.6.0 (upcoming release), TensorFlow 2.5.1, TensorFlow 2.4.3, or TensorFlow 2.3.4.
No, there is no known workaround for this vulnerability. It is recommended to update to the patched versions of TensorFlow.
This vulnerability was reported by members of the Aivul Team from Qihoo 360.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow.