CVE-2022-29216: CWE-94: Improper Control of Generation of Code ('Code Injection') in tensorflow tensorflow
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 Analysis
Technical Summary
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.
Affected Countries
Germany, France, United Kingdom, Netherlands, Sweden, Finland, Denmark, Belgium, Italy, Spain
CVE-2022-29216: CWE-94: Improper Control of Generation of Code ('Code Injection') in tensorflow 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
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.
For access to advanced analysis and higher rate limits, contact root@offseq.com
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
Related Threats
CVE-2025-9091: Hard-coded Credentials in Tenda AC20
LowCVE-2025-9090: Command Injection in Tenda AC20
MediumCVE-2025-9092: CWE-400 Uncontrolled Resource Consumption in Legion of the Bouncy Castle Inc. Bouncy Castle for Java - BC-FJA 2.1.0
LowCVE-2025-9089: Stack-based Buffer Overflow in Tenda AC20
HighCVE-2025-9088: Stack-based Buffer Overflow in Tenda AC20
HighActions
Updates to AI analysis are available only with a Pro account. Contact root@offseq.com for access.
External Links
Need enhanced features?
Contact root@offseq.com for Pro access with improved analysis and higher rate limits.