CVE-2021-41228: TensorFlow: eval() in saved_model_cli allows RCE
HIGH PoC AVAILABLEAny 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 |
Do you use tensorflow? You're affected.
Severity & Risk
Attack Surface
Recommended Action
1 step-
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:
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 References
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
AI Threat Alert