CVE-2021-37651: Heap buffer overflow in tensorflow
Summary
CVE-2021-37651: Heap buffer overflow in FractionalAvgPoolGrad. 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-37651 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 developed by Google. It provides a comprehensive ecosystem of tools, libraries, and community resources for building and deploying machine learning models. TensorFlow is widely used in various domains, including research, industry, and academia. However, a vulnerability has been discovered in TensorFlow that could potentially lead to a heap buffer overflow.
Vulnerability Detail
The vulnerability, identified as CVE-2021-37651, affects the tf.raw_ops.FractionalAvgPoolGrad implementation in TensorFlow. This vulnerability can be exploited to trick the implementation into accessing data outside the bounds of heap allocated buffers. By providing specific input parameters, an attacker could cause the code to construct an empty EigenDoubleMatrixMap and then access this buffer with indices that are outside of the empty area. This can result in a heap buffer overflow, potentially leading to arbitrary code execution or a denial of service condition.
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 apply the patch or update to the latest patched version of TensorFlow as soon as possible.
Conclusion
The vulnerability in TensorFlow (CVE-2021-37651) can lead to a heap buffer overflow, potentially resulting in arbitrary code execution or a denial of service condition. It is crucial to update your TensorFlow installation to one of the patched versions or apply the provided patch as soon as possible. For further support on vulnerability remediation, you can reach out to DevNack.com.
See every vulnerability recorded for tensorflow →
FAQ
TensorFlow is an open-source machine learning framework developed by Google. It provides tools and libraries for building and deploying machine learning models.
The vulnerability can lead to a heap buffer overflow, which may result in arbitrary code execution or a denial of service condition.
To fix the vulnerability, update your TensorFlow installation to one of the patched versions: TensorFlow 2.3.4, TensorFlow 2.4.3, TensorFlow 2.5.1, or TensorFlow 2.6.0 (upcoming release).
There is no known workaround for this vulnerability. It is recommended to apply the patch or update to the latest patched version of TensorFlow.
This vulnerability was reported by members of the Aivul Team from Qihoo 360.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow.