CVE-2021-41210: TensorFlow Heap Read Out-of-Bounds in SparseCountSparseOutput Shape Inference
Summary
CVE-2021-41210: TensorFlow is an open source platform for machine learning. Affects tensorflow-cpu across 5 version ranges.
< 2.4.4
>= 2.5.0, < 2.5.2
>= 2.6.0, < 2.6.1
>= 2.7.0rc0, < 2.7.0
< 701cfaca222a82afbeeb17496bd718baa65a67d2
Fixed in 4 releases; the minimum fixed version depends on the release line you run. How to fix ↓
Also tracked for
- tensorflow · Bitnami
- tensorflow · PyPI
- tensorflow · PyPI
- tensorflow-gpu · PyPI
The same CVE-2021-41210 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 platform for machine learning. It provides a comprehensive ecosystem of tools, libraries, and resources for developing and deploying machine learning models. TensorFlow includes various functions and APIs for performing operations on tensors, which are multi-dimensional arrays. One of the functionalities in TensorFlow is shape inference, which determines the shape of tensors based on the operations performed on them. This vulnerability specifically affects the shape inference functions for SparseCountSparseOutput in TensorFlow.
Vulnerability Detail
The vulnerability in TensorFlow's shape inference functions for SparseCountSparseOutput can trigger a read outside of the bounds of a heap-allocated array. This can lead to memory corruption and potentially allow an attacker to execute arbitrary code or cause a denial of service. The issue arises due to improper bounds checking in the affected functions. The vulnerability has been assigned CVE-2021-41210 and has been reported as PYSEC-2021-619. It was discovered by the TensorFlow security team.
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.4.42.4.4pip install --upgrade "tensorflow-cpu==2.4.4" -
>= 2.5.0, < 2.5.22.5.2pip install --upgrade "tensorflow-cpu==2.5.2" -
>= 2.6.0, < 2.6.12.6.1pip install --upgrade "tensorflow-cpu==2.6.1" -
>= 2.7.0rc0, < 2.7.02.7.0pip install --upgrade "tensorflow-cpu==2.7.0"
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 fix provided by the TensorFlow team as soon as it is available.
Conclusion
In conclusion, the vulnerability in TensorFlow's shape inference functions for SparseCountSparseOutput can lead to memory corruption and potential code execution or denial of service. Users are advised to update their TensorFlow installations to the fixed versions as soon as they are available. 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 platform for machine learning that provides a comprehensive ecosystem of tools, libraries, and resources for developing and deploying machine learning models.
Shape inference in TensorFlow is the process of determining the shape of tensors based on the operations performed on them. It helps in understanding the dimensions and sizes of tensors at different stages of a machine learning model.
SparseCountSparseOutput is a function in TensorFlow that performs a specific operation on sparse tensors. It is used in various machine learning tasks, such as natural language processing and recommendation systems.
This vulnerability can lead to memory corruption and potentially allow an attacker to execute arbitrary code or cause a denial of service. It is important to update TensorFlow installations to the fixed versions as soon as they are available to mitigate these risks.
You can use the Vulert Playground (https://vulert.com/scanner) to check if your application is affected by this vulnerability. Simply provide your Pipfile.lock and the playground will analyze it for any open-source vulnerabilities, including this one.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow-cpu.