CWE-94: Improper Control of Generation of Code
5772 CVEs have CWE-94 as their primary weakness. 72 of them are in the CISA KEV catalog. The highest EPSS score among them is 99.999%.
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.
Child of CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component
Mitigations
- 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.
- Implementation: Assume all input is malicious. Use an accept known good input validation strategy, i.e., use a list of acceptable inputs that strictly conform to specifications. Reject any input that does not strictly conform to specifications, or transform it into something that does. When performing input validation, consider all potentially relevant properties, including length, type of input, the full range of acceptable values, missing or extra inputs, syntax, consistency across related fields, and conformance to business rules. As an example of business rule logic, boat may be syntactically valid because it only contains alphanumeric characters, but it is not valid if the input is only expected to contain colors such as red or blue. Do not rely exclusively on looking for malicious or malformed inputs. This is likely to miss at least one undesirable input, especially if the code's environment changes. This can give attackers enough room to bypass the intended validation. However,…
- Testing: Use dynamic tools and techniques that interact with the product using large test suites with many diverse inputs, such as fuzz testing (fuzzing), robustness testing, and fault injection. The product's operation may slow down, but it should not become unstable, crash, or generate incorrect results.
- Operation: Run the code in an environment that performs automatic taint propagation and prevents any command execution that uses tainted variables, such as Perl's -T switch. This will force the program to perform validation steps that remove the taint, although you must be careful to correctly validate your inputs so that you do not accidentally mark dangerous inputs as untainted (see CWE-183 and CWE-184).
- Operation: Run the code in an environment that performs automatic taint propagation and prevents any command execution that uses tainted variables, such as Perl's -T switch. This will force the program to perform validation steps that remove the taint, although you must be careful to correctly validate your inputs so that you do not accidentally mark dangerous inputs as untainted (see CWE-183 and CWE-184).
- Implementation: For Python programs, it is frequently encouraged to use the ast.literal_eval() function instead of eval, since it is intentionally designed to avoid executing code. However, an adversary could still cause excessive memory or stack consumption via deeply nested structures [REF-1372], so the python documentation discourages use of ast.literal_eval() on untrusted data [REF-1373].
Observed examples
- CVE-2023-29374: Math component in an LLM framework translates user input into a Python expression that is input into the Python exec() method, allowing code execution - one variant of a prompt injection attack.
- CVE-2024-5565: Python-based library uses an LLM prompt containing user input to dynamically generate code that is then fed as input into the Python exec() method, allowing code execution - one variant of a prompt injection attack.
- CVE-2024-4181: Framework for LLM applications allows eval injection via a crafted response from a hosting provider.
- CVE-2022-2054: Python compiler uses eval() to execute malicious strings as Python code.
- CVE-2021-22204: Chain: regex in EXIF processor code does not correctly determine where a string ends (CWE-625), enabling eval injection (CWE-95), as exploited in the wild per CISA KEV.
- CVE-2020-8218: Code injection in VPN product, as exploited in the wild per CISA KEV.
- CVE-2008-5071: Eval injection in PHP program.
- CVE-2002-1750: Eval injection in Perl program.
- CVE-2008-5305: Eval injection in Perl program using an ID that should only contain hyphens and numbers.
- CVE-2002-1752: Direct code injection into Perl eval function.
- CVE-2002-1753: Eval injection in Perl program.
- CVE-2005-1527: Direct code injection into Perl eval function.
- CVE-2005-2837: Direct code injection into Perl eval function.
- CVE-2005-1921: MFV. code injection into PHP eval statement using nested constructs that should not be nested.
- CVE-2005-2498: MFV. code injection into PHP eval statement using nested constructs that should not be nested.
- CVE-2005-3302: Code injection into Python eval statement from a field in a formatted file.
- CVE-2007-1253: Eval injection in Python program.
- CVE-2001-1471: Chain: Resultant eval injection. An invalid value prevents initialization of variables, which can be modified by attacker and later injected into PHP eval statement.
- CVE-2002-0495: Perl code directly injected into CGI library file from parameters to another CGI program.
- CVE-2005-1876: Direct PHP code injection into supporting template file.
- CVE-2005-1894: Direct code injection into PHP script that can be accessed by attacker.
- CVE-2003-0395: PHP code from User-Agent HTTP header directly inserted into log file implemented as PHP script.
Top released CVEs
KEV first, then the highest EPSS score, the highest CVSS score and the newest.
| CVE | Published | Severity | CVSS | EPSS | Description |
|---|---|---|---|---|---|
| CVE-2017-9841 | 2017-06-27 | CRITICAL | 9.8 | 99.999% | Util/PHP/eval-stdin.php in PHPUnit before 4.8.28 and 5.x before 5.6.3 allows remote attackers to execute arbitrary PHP code via HTTP POST data beginning with a… |
| CVE-2015-1635 | 2015-04-14 | CRITICAL | 9.8 | 99.999% | HTTP.sys in Microsoft Windows 7 SP1, Windows Server 2008 R2 SP1, Windows 8, Windows 8.1, and Windows Server 2012 Gold and R2 allows remote attackers to execute… |
| CVE-2022-22954 | 2022-04-11 | CRITICAL | 9.8 | 99.998% | VMware Workspace ONE Access and Identity Manager contain a remote code execution vulnerability due to server-side template injection. A malicious actor with… |
| CVE-2025-49704 | 2025-07-08 | HIGH | 8.8 | 99.996% | Improper control of generation of code ('code injection') in Microsoft Office SharePoint allows an authorized attacker to execute code over a network. |
| CVE-2021-22204 | 2021-04-23 | MEDIUM | 6.8 | 99.981% | Improper neutralization of user data in the DjVu file format in ExifTool versions 7.44 and up allows arbitrary code execution when parsing the malicious image |
| CVE-2012-0158 | 2012-04-10 | HIGH | 8.8 | 99.976% | The (1) ListView, (2) ListView2, (3) TreeView, and (4) TreeView2 ActiveX controls in MSCOMCTL.OCX in the Common Controls in Microsoft Office 2003 SP3, 2007 SP2… |
| CVE-2022-22963 | 2022-04-01 | CRITICAL | 9.8 | 99.938% | In Spring Cloud Function versions 3.1.6, 3.2.2 and older unsupported versions, when using routing functionality it is possible for a user to provide a… |
| CVE-2022-24816 | 2022-04-13 | CRITICAL | 10.0 | 99.929% | JAI-EXT is an open-source project which aims to extend the Java Advanced Imaging (JAI) API. Programs allowing Jiffle script to be provided via network request… |
| CVE-2025-32432 | 2025-04-25 | CRITICAL | 10.0 | 99.792% | Craft is a flexible, user-friendly CMS for creating custom digital experiences on the web and beyond. Starting from version 3.0.0-RC1 to before 3.9.15… |
| CVE-2021-22205 | 2021-04-23 | CRITICAL | 10.0 | 99.731% | An issue has been discovered in GitLab CE/EE affecting all versions starting from 11.9. GitLab was not properly validating image files that were passed to a… |
| CVE-2019-16759 | 2019-09-24 | CRITICAL | 9.8 | 99.728% | vBulletin 5.x through 5.5.4 allows remote command execution via the widgetConfig[code] parameter in an ajax/render/widget_php routestring request. |
| CVE-2023-3519 | 2023-07-19 | CRITICAL | 9.8 | 99.715% | Unauthenticated remote code execution |
| CVE-2022-22965 | 2022-04-01 | CRITICAL | 9.8 | 99.638% | A Spring MVC or Spring WebFlux application running on JDK 9+ may be vulnerable to remote code execution (RCE) via data binding. The specific exploit requires… |
| CVE-2017-7494 | 2017-05-30 | CRITICAL | 9.8 | 99.448% | Samba since version 3.5.0 and before 4.6.4, 4.5.10 and 4.4.14 is vulnerable to remote code execution vulnerability, allowing a malicious client to upload a… |
| CVE-2014-6287 | 2014-10-07 | CRITICAL | 9.8 | 99.323% | The findMacroMarker function in parserLib.pas in Rejetto HTTP File Server (aks HFS or HttpFileServer) 2.3x before 2.3c allows remote attackers to execute… |
| CVE-2018-7602 | 2018-07-19 | CRITICAL | 9.8 | 99.172% | A remote code execution vulnerability exists within multiple subsystems of Drupal 7.x and 8.x. This potentially allows attackers to exploit multiple attack… |
| CVE-2021-44529 | 2021-12-08 | CRITICAL | 9.8 | 99.105% | A code injection vulnerability in the Ivanti EPM Cloud Services Appliance (CSA) allows an unauthenticated user to execute arbitrary code with limited… |
| CVE-2022-3236 | 2022-09-23 | CRITICAL | 9.8 | 98.905% | A code injection vulnerability in the User Portal and Webadmin allows a remote attacker to execute code in Sophos Firewall version v19.0 MR1 and older. |
| CVE-2008-4250 | 2008-10-23 | CRITICAL | 9.8 | 98.751% | The Server service in Microsoft Windows 2000 SP4, XP SP2 and SP3, Server 2003 SP1 and SP2, Vista Gold and SP1, Server 2008, and 7 Pre-Beta allows remote… |
| CVE-2026-1281 | 2026-01-29 | CRITICAL | 9.8 | 98.688% | A code injection in Ivanti Endpoint Manager Mobile allowing attackers to achieve unauthenticated remote code execution. |
Get more CVE data from the API.
curl 'https://api.contrastcyber.com/cwe_lookup/CWE-94'curl 'https://api.contrastcyber.com/cve_search?cwe_id=CWE-94'
Sources
- Vulnerability data from the National Vulnerability Database (NIST) and the CVE Program. CVE records: Copyright © 1999-2026, The MITRE Corporation, used under the CVE Program Terms of Use. CVE® is a registered trademark of The MITRE Corporation.
- CWE definitions: Copyright © 2006-2026, The MITRE Corporation, used under the CWE Terms of Use. CWE is a trademark of The MITRE Corporation.
- EPSS scores by FIRST.org EPSS, used with attribution.
- KEV catalog and SSVC decisions by CISA.
- Advisory data from the GitHub Advisory Database through OSV.dev (CC BY 4.0).
- Exploit metadata from the Exploit Database (GPL-2.0-only, metadata only).
- Nuclei template names from nuclei-templates (MIT).