Skip to main content

CVE-2022-29216: CWE-94: Improper Control of Generation of Code ('Code Injection') in tensorflow tensorflow

Medium
Published: Fri May 20 2022 (05/20/2022, 23:35:13 UTC)
Source: CVE
Vendor/Project: tensorflow
Product: tensorflow

Description

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.

AI-Powered Analysis

AILast updated: 06/22/2025, 01:06:30 UTC

Technical Analysis

CVE-2022-29216 is a code injection vulnerability identified in TensorFlow's `saved_model_cli` tool, an open-source machine learning platform widely used for model management and deployment. The vulnerability arises from improper control over code generation (CWE-94) due to the use of Python's `eval` function with the `safe=False` argument during parsing of input arguments. This insecure practice allowed an attacker to inject arbitrary code, potentially enabling the execution of malicious commands such as opening a reverse shell on the host system. The vulnerability affects TensorFlow versions prior to 2.6.4, as well as certain release candidates and minor versions before 2.7.2, 2.8.1, and 2.9.0. The root cause was the need to maintain compatibility with test cases that used numpy expressions as arguments, which necessitated the use of `eval`. However, this introduced a critical security risk. The maintainers have since removed the unsafe `eval` usage by eliminating the `safe=False` argument, ensuring all parsing is done securely without evaluating arbitrary code. The patch is included in TensorFlow versions 2.6.4, 2.7.2, 2.8.1, and 2.9.0 and later. Notably, the `saved_model_cli` tool is typically run manually by users rather than automatically, which limits the attack surface and reduces the overall impact severity. There are no known exploits in the wild at this time, and the vulnerability requires local or authenticated access to run the tool, further mitigating risk. Nevertheless, the potential for remote code execution via reverse shell if exploited remains a significant concern in environments where untrusted users have access to run this tool.

Potential Impact

For European organizations, the impact of this vulnerability is primarily tied to environments where TensorFlow is used for machine learning model management, particularly in research institutions, technology companies, and industries leveraging AI/ML workflows. If exploited, an attacker could gain unauthorized code execution capabilities on systems running vulnerable TensorFlow versions, potentially leading to data exfiltration, lateral movement, or disruption of AI services. However, the manual nature of the `saved_model_cli` tool usage and the absence of known automated exploit vectors reduce the likelihood of widespread compromise. The confidentiality and integrity of machine learning models and associated data could be at risk, especially if attackers gain reverse shell access. Availability impact is limited unless the attacker deliberately disrupts services. Given the growing adoption of TensorFlow in European AI initiatives and digital transformation projects, organizations that do not update to patched versions may face targeted attacks, especially in sectors with high-value intellectual property or sensitive data. The vulnerability could also be leveraged in supply chain attacks if compromised models or environments are shared across organizations.

Mitigation Recommendations

1. Immediate upgrade to TensorFlow versions 2.6.4, 2.7.2, 2.8.1, 2.9.0, or later to ensure the patched `saved_model_cli` tool is in use. 2. Restrict access to systems and environments where TensorFlow and its CLI tools are installed, limiting usage to trusted administrators and developers only. 3. Implement strict user authentication and authorization controls to prevent unauthorized execution of the `saved_model_cli` tool. 4. Monitor and audit usage of the `saved_model_cli` tool, including command-line arguments and execution logs, to detect anomalous or suspicious activity indicative of exploitation attempts. 5. Employ network segmentation and host-based firewalls to limit outbound connections from systems running TensorFlow, reducing the risk of reverse shell communications. 6. Educate developers and data scientists about the risks of running untrusted code or inputs through TensorFlow tools and enforce secure coding and operational practices. 7. Integrate vulnerability scanning and patch management processes specifically targeting AI/ML infrastructure components to ensure timely updates. 8. Consider containerizing TensorFlow environments with strict runtime security policies to contain potential exploitation impacts.

Need more detailed analysis?Get Pro

Technical Details

Data Version
5.1
Assigner Short Name
GitHub_M
Date Reserved
2022-04-13T00:00:00.000Z
Cisa Enriched
true

Threat ID: 682d9848c4522896dcbf6586

Added to database: 5/21/2025, 9:09:28 AM

Last enriched: 6/22/2025, 1:06:30 AM

Last updated: 7/31/2025, 9:00:00 AM

Views: 19

Actions

PRO

Updates to AI analysis are available only with a Pro account. Contact root@offseq.com for access.

Please log in to the Console to use AI analysis features.

Need enhanced features?

Contact root@offseq.com for Pro access with improved analysis and higher rate limits.

Latest Threats