CVE-2021-41227: TensorFlow - Arbitrary Memory Read in ImmutableConst Operation
Summary
CVE-2021-41227: TensorFlow is an open source platform for machine learning. Affects tensorflow across 6 version ranges.
< 1cb6bb6c2a6019417c9adaf9e6843ba75ee2580b
< 2.4.4
>= 2.5.0, < 2.5.2
>= 2.6.0, < 2.6.1
>= 2.7.0rc0, < 2.7.0
< 3712a2d3455e6ccb924daa5724a3652a86f6b585
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-41227 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 supports various operations and data types to facilitate machine learning tasks.
Vulnerability Detail
The vulnerability identified as CVE-2021-41227 affects TensorFlow versions prior to 2.7.0. It resides in the ImmutableConst operation within TensorFlow. The issue arises due to a lack of support for the tstring TensorFlow string class, specifically when dealing with memory mapped strings. This oversight allows an attacker to trick the ImmutableConst operation into reading arbitrary memory contents. Exploiting this vulnerability could lead to unauthorized access to sensitive information or the execution of arbitrary code.
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
There is no specific workaround provided for this vulnerability. However, users can follow general security best practices such as ensuring the integrity of their TensorFlow installation, restricting access to TensorFlow APIs, and regularly updating to the latest stable version of TensorFlow to minimize the risk of exploitation.
Conclusion
The vulnerability identified as CVE-2021-41227 in TensorFlow allows for arbitrary memory read, potentially leading to unauthorized access or code execution. Users are advised to update their TensorFlow installations to the latest available version to mitigate this vulnerability. For further assistance or support in vulnerability remediation, please reach out to DevNack.com.
See every vulnerability recorded for tensorflow →
FAQ
TensorFlow is an open source platform for machine learning that provides a comprehensive set of tools and resources for developing and deploying machine learning models.
Exploiting this vulnerability could allow an attacker to read arbitrary memory contents, potentially leading to unauthorized access to sensitive information or the execution of arbitrary code.
Versions of TensorFlow prior to 2.7.0 are affected. This includes TensorFlow 2.6.1, TensorFlow 2.5.2, and TensorFlow 2.4.4.
While no specific workaround is provided, users can follow general security best practices such as ensuring the integrity of their TensorFlow installation and regularly updating to the latest stable version.
To fix this vulnerability, it is recommended to update to the latest available version of TensorFlow, which includes the necessary patches.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow.