CVE-2021-41228: TensorFlow: eval() in saved_model_cli allows RCE

HIGH PoC AVAILABLE
Published November 5, 2021
CISO Take

Any environment using TensorFlow's saved_model_cli on versions prior to 2.7.0/2.6.1/2.5.2/2.4.4 is vulnerable to arbitrary code execution via Python eval() on attacker-controlled input. The local attack vector limits exposure but is a real risk in shared ML infrastructure — JupyterHub clusters, CI/CD runners, and data science workstations. Patch immediately and audit any pipeline that invokes saved_model_cli programmatically.

Risk Assessment

CVSS 7.8 High. Local attack vector reduces broad internet exposure, but ML environments routinely run shared compute (JupyterHub, MLflow, Kubeflow) where local access is not a high bar. Exploitation requires zero AI/ML knowledge — any attacker with shell access can craft a malicious string argument. Not in CISA KEV and patched since Nov 2021; unpatched instances represent neglected technical debt with tangible blast radius on ML infrastructure.

Affected Systems

Package Ecosystem Vulnerable Range Patched
tensorflow pip No patch
195.0K OpenSSF 7.2 3.7K dependents Pushed 6d ago 4% patched ~1372d to patch Full package profile →

Do you use tensorflow? You're affected.

Severity & Risk

CVSS 3.1
7.8 / 10
EPSS
0.0%
chance of exploitation in 30 days
Higher than 12% of all CVEs
Exploitation Status
Exploit Available
Exploitation: MEDIUM
Sophistication
Trivial
Exploitation Confidence
medium
Public PoC indexed (trickest/cve)
Composite signal derived from CISA KEV, CISA SSVC, EPSS, trickest/cve, and Nuclei templates.

Attack Surface

AV AC PR UI S C I A
AV Local
AC Low
PR Low
UI None
S Unchanged
C High
I High
A High

Recommended Action

1 step
  1. 1) Upgrade to TensorFlow 2.7.0+ or cherry-pick patches for 2.6.1, 2.5.2, 2.4.4. 2) Verify the patched --safe flag is active (defaults True post-patch) — this disables eval() on untrusted input. 3) Audit CI/CD pipelines and automation scripts calling saved_model_cli; ensure all inputs originate from trusted, controlled sources. 4) Isolate saved_model_cli execution to containers with no network egress and no cloud credential access. 5) Detect exploitation by monitoring for unexpected child processes spawned from Python or TensorFlow CLI processes, or anomalous outbound connections from ML workstations.

Classification

Compliance Impact

This CVE is relevant to:

EU AI Act
Article 15 - Accuracy, robustness and cybersecurity
ISO 42001
A.6.2 - AI system risk management
NIST AI RMF
MANAGE-2.4 - Residual risks and vulnerabilities are managed
OWASP LLM Top 10
LLM03:2025 - Supply Chain Vulnerabilities

Frequently Asked Questions

What is CVE-2021-41228?

Any environment using TensorFlow's saved_model_cli on versions prior to 2.7.0/2.6.1/2.5.2/2.4.4 is vulnerable to arbitrary code execution via Python eval() on attacker-controlled input. The local attack vector limits exposure but is a real risk in shared ML infrastructure — JupyterHub clusters, CI/CD runners, and data science workstations. Patch immediately and audit any pipeline that invokes saved_model_cli programmatically.

Is CVE-2021-41228 actively exploited?

Proof-of-concept exploit code is publicly available for CVE-2021-41228, increasing the risk of exploitation.

How to fix CVE-2021-41228?

1) Upgrade to TensorFlow 2.7.0+ or cherry-pick patches for 2.6.1, 2.5.2, 2.4.4. 2) Verify the patched --safe flag is active (defaults True post-patch) — this disables eval() on untrusted input. 3) Audit CI/CD pipelines and automation scripts calling saved_model_cli; ensure all inputs originate from trusted, controlled sources. 4) Isolate saved_model_cli execution to containers with no network egress and no cloud credential access. 5) Detect exploitation by monitoring for unexpected child processes spawned from Python or TensorFlow CLI processes, or anomalous outbound connections from ML workstations.

What systems are affected by CVE-2021-41228?

This vulnerability affects the following AI/ML architecture patterns: training pipelines, model serving, MLOps CI/CD pipelines, data science workstations.

What is the CVSS score for CVE-2021-41228?

CVE-2021-41228 has a CVSS v3.1 base score of 7.8 (HIGH). The EPSS exploitation probability is 0.04%.

Technical Details

NVD Description

TensorFlow is an open source platform for machine learning. In affected versions TensorFlow's `saved_model_cli` tool is vulnerable to a code injection as it calls `eval` on user supplied strings. This can be used by attackers to run arbitrary code on the plaform where the CLI tool runs. However, given that the tool is always run manually, the impact of this is not severe. We have patched this by adding a `safe` flag which defaults to `True` and an explicit warning for users. The fix will be included in TensorFlow 2.7.0. We will also cherrypick this commit on TensorFlow 2.6.1, TensorFlow 2.5.2, and TensorFlow 2.4.4, as these are also affected and still in supported range.

Exploitation Scenario

An attacker with local access to a shared JupyterHub environment or data science workstation crafts a malicious argument string for saved_model_cli — e.g., by poisoning a shared model directory or intercepting a CI/CD artifact. When the ML engineer runs the tool as part of their normal model validation workflow, the eval() call executes attacker-supplied Python: establishing a reverse shell, exfiltrating saved model weights and training datasets, or dumping cloud credentials (AWS keys, GCP service accounts) stored in the environment to enable lateral movement.

Weaknesses (CWE)

CVSS Vector

CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H

Timeline

Published
November 5, 2021
Last Modified
November 21, 2024
First Seen
November 5, 2021

Related Vulnerabilities