CVE-2021-41228: TensorFlow saved_model_cli Code Injection Vulnerability

tensorflow Updated 02 Oct 2025

Summary

05/11/2021
Yes i
Moderate
7.5

CVE-2021-41228: 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 < 8b202f08d52e8206af2bdb2112a62fafbc546ec7

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-41228 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 Devnack Your last release was probably never penetration tested Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

TensorFlow is an open source platform for machine learning. It provides a comprehensive ecosystem for building and deploying machine learning models. TensorFlow's saved_model_cli tool is a command-line interface used for inspecting and manipulating TensorFlow SavedModels. SavedModels are a serialized format for TensorFlow models, which 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 model's inputs and outputs, and running inference. However, the tool is vulnerable to a code injection attack, which can be exploited by attackers to execute arbitrary code on the platform where the CLI tool is run.

Vulnerability Detail

The vulnerability in TensorFlow's saved_model_cli tool arises from the fact that it calls eval on user-supplied strings without proper sanitization. This allows an attacker to inject malicious code into the tool's input, which will be executed when the eval function is called. As a result, an attacker can run arbitrary code on the platform where the CLI tool is run, potentially leading to unauthorized access, data exfiltration, or other malicious activities. However, it's important to note that the impact of this vulnerability is limited by the fact that the saved_model_cli tool is always run manually by users.

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 mentioned for this vulnerability. However, users can mitigate the risk by ensuring that they only run the saved_model_cli tool with trusted inputs and avoid passing user-supplied strings that may contain malicious code.

Conclusion

The vulnerability in TensorFlow's saved_model_cli tool allows for code injection, enabling attackers to execute arbitrary code on the platform. However, the impact is limited as the tool is manually run by users. The TensorFlow project has addressed this vulnerability by introducing a fix in TensorFlow 2.7.0 and backporting it to older supported versions. Users are advised to update to the patched versions to mitigate the risk. For further support on vulnerability remediation, please contact 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 ecosystem 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. It allows users to perform various operations on SavedModels, such as listing signatures, inspecting inputs and outputs, and running inference.

The vulnerability arises from the tool's use of the eval function on user-supplied strings without proper sanitization. This allows an attacker to inject malicious code into the tool's input, which will be executed when the eval function is called.

The vulnerability allows an attacker to execute arbitrary code on the platform where the saved_model_cli tool is run. However, the impact is limited by the fact that the tool is always run manually by users.

To fix this vulnerability, users should update to TensorFlow version 2.7.0, which includes the necessary fix. Users of older versions should update to the respective patched versions (2.6.1, 2.5.2, or 2.4.4).

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