CVE-2021-41226: Heap OOB in TensorFlow
Summary
CVE-2021-41226: Heap OOB in SparseBinCount. Affects tensorflow across 3 version ranges.
< 2.4.4
>= 2.5.0, < 2.5.2
>= 2.6.0, < 2.6.1
Fixed in 2.4.4, 2.5.2 or 2.6.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-41226 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 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 identified in TensorFlow that could potentially lead to a heap out-of-bounds (OOB) issue.
Vulnerability Detail
The vulnerability, identified as CVE-2021-41226, resides in the implementation of the SparseBinCount function in TensorFlow. This function is used for counting the occurrences of values in a sparse tensor. The issue arises due to missing validation between the elements of the values argument and the shape of the sparse output. An attacker could exploit this vulnerability by providing malicious input, leading to a heap OOB condition. This could potentially result in memory corruption, crashes, or even remote code execution.
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.4.42.4.4pip install --upgrade "tensorflow==2.4.4" -
>= 2.5.0, < 2.5.22.5.2pip install --upgrade "tensorflow==2.5.2" -
>= 2.6.0, < 2.6.12.6.1pip install --upgrade "tensorflow==2.6.1"
Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →
Workaround
No specific workaround has been provided for this vulnerability.
Conclusion
The vulnerability in TensorFlow (CVE-2021-41226) poses a risk of heap out-of-bounds (OOB) condition, potentially leading to memory corruption, crashes, or remote code execution. Users are advised to update their TensorFlow installations to the patched versions once they become available. For further support on vulnerability remediation, you can contact DevNack.com.
See every vulnerability recorded for tensorflow →
FAQ
TensorFlow is an open-source machine learning framework developed by Google. It provides a comprehensive ecosystem of tools, libraries, and resources for building and deploying machine learning models.
The vulnerability in TensorFlow could potentially lead to a heap out-of-bounds (OOB) condition. This could result in memory corruption, crashes, or even remote code execution.
To fix this vulnerability, users should update their TensorFlow installations to the patched versions once they become available. The fix will be included in TensorFlow 2.7.0 and will also be backported to TensorFlow 2.6.1, TensorFlow 2.5.2, and TensorFlow 2.4.4.
No specific workaround has been provided for this vulnerability.
For more information about this vulnerability, you can refer to the TensorFlow security guide and the GitHub commit f410212e373eb2aec4c9e60bf3702eba99a38aba.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow.