CVE-2022-21740: Heap Overflow in TensorFlow
Summary
CVE-2022-21740: Tensorflow is an Open Source Machine Learning Framework. Affects tensorflow-cpu across 4 version ranges.
< 2.5.3
>= 2.6.0, < 2.6.3
< 2b7100d6cdff36aa21010a82269bc05a6d1cc74a
< adbbabdb0d3abb3cdeac69e38a96de1d678b24b3
Fixed in 2.5.3 or 2.6.3, depending on the release line you run. How to fix ↓
Also tracked for
- tensorflow · PyPI
- tensorflow · Bitnami
- tensorflow · PyPI
- tensorflow-gpu · PyPI
The same CVE-2022-21740 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 deploying machine learning models. It provides a comprehensive set of tools and libraries for building and training neural networks. TensorFlow is vulnerable to a heap overflow in the implementation of SparseCountSparseOutput.
Vulnerability Detail
The vulnerability in TensorFlow allows an attacker to trigger a heap overflow, potentially leading to remote code execution or denial of service. This vulnerability can be exploited by crafting a malicious input that triggers the overflow during the execution of the affected function. The issue has been identified and fixed in TensorFlow 2.8.0. However, earlier versions including TensorFlow 2.7.1, TensorFlow 2.6.3, and TensorFlow 2.5.3 are also affected.
How To Fix
Latest published version: 2.21.0 as of 22 Oct 2026
pip install --upgrade "tensorflow-cpu==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-cpu==2.5.3" -
>= 2.6.0, < 2.6.32.6.3pip install --upgrade "tensorflow-cpu==2.6.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 update to the fixed versions of TensorFlow as mentioned above.
Conclusion
TensorFlow is vulnerable to a heap overflow, which can be exploited to execute arbitrary code or cause a denial of service. It is crucial to update to the fixed versions of TensorFlow or apply the provided patches to mitigate this vulnerability. For further support on vulnerability remediation, you can reach out to DevNack.com.
See every vulnerability recorded for tensorflow-cpu →
FAQ
TensorFlow is an open-source machine learning framework used for building and training neural networks.
A heap overflow is a type of buffer overflow vulnerability where data is written beyond the allocated memory buffer, potentially leading to code execution or denial of service.
This vulnerability can be exploited by an attacker to execute arbitrary code or cause a denial of service on systems running vulnerable versions of TensorFlow.
The vulnerability affects TensorFlow versions 2.5.3, 2.6.3, 2.7.1, and earlier. It has been fixed in TensorFlow 2.8.0.
To update TensorFlow, you can use the package manager or follow the installation instructions provided by the TensorFlow project.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow-cpu.