CVE-2021-41227: TensorFlow - Arbitrary Memory Read in ImmutableConst Operation

tensorflow Updated 02 Oct 2025

Summary

05/11/2021
Yes i
Moderate
6.6

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

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.

Free scan

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.

Check my app free

No signup required · Results in about 60 seconds

Sponsored MarkAI Find prospects already talking about the problem you solve AI watches the communities your customers use to find qualified prospects, then alerts you when a conversation is worth joining. See MarkAI

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.4 2.4.4
    pip install --upgrade "tensorflow==2.4.4"
  • >= 2.5.0, < 2.5.2 2.5.2
    pip install --upgrade "tensorflow==2.5.2"
  • >= 2.6.0, < 2.6.1 2.6.1
    pip install --upgrade "tensorflow==2.6.1"
  • >= 2.7.0rc0, < 2.7.0 2.7.0
    pip 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 →

Share this vulnerability

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.

Related vulnerabilities

Recent vulnerabilities recorded for tensorflow.

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.4 2.4.4
    pip install --upgrade "tensorflow==2.4.4"
  • >= 2.5.0, < 2.5.2 2.5.2
    pip install --upgrade "tensorflow==2.5.2"
  • >= 2.6.0, < 2.6.1 2.6.1
    pip install --upgrade "tensorflow==2.6.1"
  • >= 2.7.0rc0, < 2.7.0 2.7.0
    pip 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 →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback