CVE-2021-37646: TensorFlow GPU - Integer Overflow in StringNGrams
Summary
CVE-2021-37646: TensorFlow is an end-to-end open source platform for machine learning. Affects tensorflow-gpu across 3 version ranges.
>= 2.3.0, < 2.3.4
>= 2.4.0, < 2.4.3
< c283e542a3f422420cfdb332414543b62fc4e4a5
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 · PyPI
- tensorflow · PyPI
- tensorflow-cpu · PyPI
The same CVE-2021-37646 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 developing and deploying machine learning models. TensorFlow GPU is a variant of TensorFlow that leverages GPU acceleration for faster computation. It is widely used in various industries for deep learning tasks.
Vulnerability Detail
The vulnerability (CVE-2021-37646) exists in the implementation of tf.raw_ops.StringNGrams in TensorFlow GPU. It is caused by an integer overflow issue that occurs when converting a signed integer value to an unsigned one and then allocating memory based on this value. The vulnerable code can be found in the string_ngrams_op.cc file. The issue arises when negative ngram_widths are supplied by the user, leading to a negative value being passed to the reserve method. As a result, the negative value is implicitly converted to a large unsigned integer, causing an overflow. This vulnerability can be exploited by an attacker to trigger a buffer overflow or other memory-related issues.
How To Fix
Latest published version: 2.12.0 as of 22 Oct 2026
pip install --upgrade "tensorflow-gpu==2.12.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-gpu==2.3.4" -
>= 2.4.0, < 2.4.32.4.3pip install --upgrade "tensorflow-gpu==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
There is no known workaround for this vulnerability. It is recommended to apply the official patch or update to a fixed version of TensorFlow GPU.
Conclusion
The vulnerability (CVE-2021-37646) in TensorFlow GPU's tf.raw_ops.StringNGrams has been identified and patched. Users are strongly advised to update to the latest fixed version (2.6.0) or one of the backported versions (2.5.1, 2.4.3, 2.3.4) to mitigate the risk of exploitation. It is crucial to rebuild any affected applications or models using the updated TensorFlow GPU library and thoroughly test them for proper functionality and security. For further support on vulnerability remediation, contact DevNack.com.
See every vulnerability recorded for tensorflow-gpu →
FAQ
TensorFlow GPU is a variant of TensorFlow that utilizes GPU acceleration for faster machine learning computations. It is commonly used in deep learning tasks.
This vulnerability can be exploited by an attacker to trigger a buffer overflow or other memory-related issues. It could potentially lead to remote code execution or denial of service.
The vulnerability affects TensorFlow GPU versions 2.3.0 to 2.3.4, 2.4.0 to 2.4.3, and 2.5.1. The issue has been fixed in version 2.6.0.
The recommended mitigation is to update TensorFlow GPU to the latest fixed version (2.6.0) or one of the backported versions (2.5.1, 2.4.3, 2.3.4).
There is no known workaround for this vulnerability. It is advised to apply the official patch or update to a fixed version of TensorFlow GPU.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow-gpu.