CVE-2021-41217: TensorFlow Control Flow Graph Null Pointer Exception
Summary
CVE-2021-41217: 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
< 05cbebd3c6bb8f517a158b0155debb8df79017ff
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-41217 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 building and deploying machine learning models. TensorFlow allows users to define and execute computational graphs, which represent the flow of data and operations in a machine learning model. These graphs are built using TensorFlow's API and are used for training and inference. However, in certain versions of TensorFlow, there is a vulnerability in the process of building the control flow graph for a model. This vulnerability can lead to a null pointer exception when nodes that should be paired are not, causing a crash in the code. The vulnerability affects the 'tensorflow-cpu' package in versions 2.4.4, 2.5.2, 2.6.1, and 2.7.0, as well as the corresponding versions of TensorFlow available on PyPI.
Vulnerability Detail
The vulnerability arises from an assumption made in the code that the first node in a pairing (e.g., an 'Enter' node) always exists when encountering the second node (e.g., an 'Exit' node). When this assumption is not met, the 'parent' node becomes a null pointer ('nullptr') and dereferencing it causes a crash. This vulnerability can be exploited by an attacker to cause a denial-of-service (DoS) condition in TensorFlow applications. The impact of this vulnerability can range from application crashes to potential security breaches if the crash is triggered in a critical part of the code.
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 currently no known workaround for this vulnerability. Users are strongly encouraged to apply the fix provided by updating to the patched versions of TensorFlow.
Conclusion
The vulnerability in TensorFlow's control flow graph building process can lead to a null pointer exception and subsequent crashes in affected versions. It is crucial for users to update their TensorFlow installations to the fixed versions as soon as they become available. This will ensure the stability and security of TensorFlow applications. For further support and assistance in vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for tensorflow-cpu →
FAQ
TensorFlow is an open source platform for machine learning that provides tools and resources for building and deploying machine learning models.
A control flow graph represents the flow of data and operations in a machine learning model. It is used for training and inference in TensorFlow.
A null pointer exception occurs when a program tries to dereference a null pointer, which is a pointer that does not point to a valid memory location. This can cause the program to crash.
The impact of this vulnerability can range from application crashes to potential security breaches if the crash occurs in a critical part of the code.
To update TensorFlow, you can use the package manager or the appropriate installation method for your environment. Once the fixed versions are available, you can upgrade your TensorFlow installation to the latest patched version.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow-cpu.