CVE-2021-41212: TensorFlow - Out-of-Bounds Read in Shape Inference Code
Summary
CVE-2021-41212: TensorFlow is an open source platform for machine learning. Affects tensorflow 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
< fa6b7782fbb14aa08d767bc799c531f5e1fb3bb8
Fixed in 4 releases; the minimum fixed version depends on the release line you run. How to fix ↓
Also tracked for
- tensorflow · Bitnami
- tensorflow-cpu · PyPI
- tensorflow-gpu · PyPI
The same CVE-2021-41212 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 is widely used in various industries and research domains for tasks such as image recognition, natural language processing, and recommendation systems. However, a vulnerability has been discovered in TensorFlow that can lead to an out-of-bounds read in the shape inference code for tf.ragged.cross.
Vulnerability Detail
The vulnerability in TensorFlow arises from the shape inference code for tf.ragged.cross. This code can trigger a read outside the bounds of a heap-allocated array. An attacker could potentially exploit this vulnerability to read sensitive information from the memory or cause a denial-of-service condition. The issue has been assigned the CVE identifier CVE-2021-41212 and has been reported to the TensorFlow development team.
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" -
>= 2.7.0rc0, < 2.7.02.7.0pip install --upgrade "tensorflow==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
If you are unable to immediately update to a fixed version of TensorFlow, you can consider implementing the following workaround to mitigate the vulnerability. [Workaround description or code snippet]
Conclusion
The vulnerability in TensorFlow's shape inference code for tf.ragged.cross can lead to an out-of-bounds read, potentially enabling an attacker to read sensitive information or cause a denial-of-service condition. It is crucial to update to the latest available version of TensorFlow to mitigate this vulnerability. If immediate update is not possible, consider implementing the provided workaround. 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 platform for machine learning that provides tools and resources for developing and deploying machine learning models.
This vulnerability can potentially allow an attacker to read sensitive information from memory or cause a denial-of-service condition.
The vulnerability affects TensorFlow versions 2.4.4, 2.5.2, 2.6.1, and 2.7.0rc0. It has been fixed in TensorFlow versions 2.4.4, 2.5.2, 2.6.1, and 2.7.0.
To update TensorFlow, you can use the command 'pip install --upgrade tensorflow'. Make sure to update all dependencies and verify that your code functions correctly after the update.
If you are unable to immediately update to a fixed version of TensorFlow, you can consider implementing a workaround. [Workaround description or code snippet]
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow.