CVE-2022-29216: TensorFlow Code Injection Vulnerability in saved_model_cli
Summary
CVE-2022-29216: Code injection in saved_model_cli in TensorFlow. Affects tensorflow across 3 version ranges.
< 2.6.4
>= 2.7.0, < 2.7.2
>= 2.8.0, < 2.8.1
Fixed in 2.6.4, 2.7.2 or 2.8.1, depending on the release line you run. How to fix ↓
Also tracked for
- tensorflow-cpu · PyPI
- tensorflow-gpu · PyPI
- tensorflow · Bitnami
The same CVE-2022-29216 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 machine learning framework that provides a comprehensive ecosystem for building and deploying machine learning models. It is widely used for various applications, including deep learning and artificial intelligence. The package includes a command-line tool called saved_model_cli, which is used for interacting with TensorFlow models. However, this tool has a vulnerability that allows for code injection, potentially leading to severe security risks.
Vulnerability Detail
The vulnerability in TensorFlow's saved_model_cli tool arises from an incomplete fix for a previous vulnerability (CVE-2021-41228). The tool allows users to execute arbitrary code through the input_exprs argument, which can be exploited to run malicious code. For example, an attacker could use the command 'saved_model_cli run --input_exprs 'x=print("malicious code to run")' --dir ./ --tag_set serve --signature_def serving_default' to execute harmful commands. This vulnerability can lead to unauthorized access and control over the system, including the ability to open a reverse shell.
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.6.42.6.4pip install --upgrade "tensorflow==2.6.4" -
>= 2.7.0, < 2.7.22.7.2pip install --upgrade "tensorflow==2.7.2" -
>= 2.8.0, < 2.8.12.8.1pip install --upgrade "tensorflow==2.8.1"
Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →
Workaround
As a temporary workaround, avoid using the saved_model_cli tool with the input_exprs argument until you can update to a patched version. If you must use it, ensure that you do not pass any untrusted input to the tool.
Conclusion
The CVE-2022-29216 vulnerability in TensorFlow's saved_model_cli tool poses a significant risk due to its potential for code injection. Users are advised to update to the latest patched versions to secure their systems and avoid using the vulnerable features until the update is applied.
See every vulnerability recorded for tensorflow →
FAQ
CVE-2022-29216 is a code injection vulnerability in TensorFlow's saved_model_cli tool that allows attackers to execute arbitrary code.
You can check if your application is affected by using Vulert, which monitors open-source vulnerabilities in real-time. Visit Vulert Scanner to check your application without needing to sign up.
The vulnerability can lead to unauthorized code execution, allowing attackers to gain control over the system, potentially leading to data breaches or system compromise.
You can update TensorFlow by running the command 'pip install --upgrade tensorflow' in your terminal or command prompt.
Yes, as a temporary measure, avoid using the saved_model_cli tool with the input_exprs argument until you can update to a patched version.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow.