CVE-2021-41228: TensorFlow saved_model_cli Code Injection Vulnerability
Summary
CVE-2021-41228: 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
< 8b202f08d52e8206af2bdb2112a62fafbc546ec7
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-41228 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's saved_model_cli tool is used for inspecting and manipulating TensorFlow SavedModels. SavedModels are a serialized format for TensorFlow models that can be used for inference and transfer learning. The saved_model_cli tool allows users to perform various operations on SavedModels, such as listing the available signatures, inspecting the inputs and outputs, and running inference. However, a vulnerability has been discovered in the saved_model_cli tool that allows for code injection.
Vulnerability Detail
The vulnerability in TensorFlow's saved_model_cli tool arises from the use of the eval function on user-supplied strings. This allows an attacker to inject arbitrary code into the tool, which can then be executed on the platform where the CLI tool is run. Although the impact of this vulnerability is not severe, as the tool is typically run manually, it still poses a risk as it can be exploited by attackers to execute unauthorized code. The vulnerability has been assigned the identifier CVE-2021-41228 and has been reported to the TensorFlow 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 specific workaround mentioned for this vulnerability. However, users can minimize the risk by exercising caution when using the saved_model_cli tool and avoiding the use of untrusted or unknown inputs.
Conclusion
In conclusion, TensorFlow's saved_model_cli tool is vulnerable to a code injection that allows for the execution of arbitrary code. While the impact of this vulnerability is not severe, it is still important to apply the necessary fixes and updates to ensure the security of the platform. The TensorFlow team has addressed this vulnerability by adding a safe flag and an explicit warning to the tool. Users are advised to update to the latest version of TensorFlow once the fix is released. For further support on 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.
The saved_model_cli tool is a command-line interface provided by TensorFlow for inspecting and manipulating TensorFlow SavedModels.
A SavedModel is a serialized format for TensorFlow models that can be used for inference and transfer learning.
Code injection is a vulnerability that allows an attacker to insert and execute arbitrary code in an application or system.
The impact of this vulnerability is not severe, as the saved_model_cli tool is typically run manually. However, it can still be exploited by attackers to execute unauthorized code on the platform where the tool is run.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow-cpu.