CWEweakness
CWE-95 Improper Neutralization of Directives in Dynamically Evaluated Code
Medium
Official page ↗
- Alternate terms
- Eval Injection
- Abstraction
- Variant
- Structure
- Simple
- Status
- Incomplete
- Likelihood of exploit
- Medium
- Languages
- Interpreted, Java, JavaScript, PHP, Perl, Python, Ruby
- CWE version
- 5.0
Description
The product receives input from an upstream component, but it does not neutralize or incorrectly neutralizes code syntax before using the input in a dynamic evaluation call (e.g. "eval").
Common consequences
• Confidentiality: Read Files or Directories, Read Application Data — The injected code could access restricted data / files.
• Access Control: Bypass Protection Mechanism — In some cases, injectable code controls authentication; this may lead to a remote vulnerability.
• Access Control: Gain Privileges or Assume Identity — Injected code can access resources that the attacker is directly prevented from accessing.
• Integrity, Confidentiality, Availability, Other: Execute Unauthorized Code or Commands — Code injection attacks can lead to loss of data integrity in nearly all cases as the control-plane data injected is always incidental to data recall or writing. Additionally, code injection can often result in the execution of arbitrary code or at least modify what code can be executed.
• Non-Repudiation: Hide Activities — Often the actions performed by injected control code are unlogged.
Potential mitigations
• [Architecture and Design, Implementation] If possible, refactor your code so that it does not need to use eval() at all.
• [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, denylists can be useful for detecting potential attacks or determining which inputs are so malformed that they should be rejected outright.
• [Implementation] Inputs should be decoded and canonicalized to the application's current internal representation before being validated (CWE-180, CWE-181). Make sure that your application does not inadvertently decode the same input twice (CWE-174). Such errors could be used to bypass allowlist schemes by introducing dangerous inputs after they have been checked. Use libraries such as the OWASP ESAPI Canonicalization control.
Consider performing repeated canonicalization until your input does not change any more. This will avoid double-decoding and similar scenarios, but it might inadvertently modify inputs that are allowed to contain properly-encoded dangerous content.
• [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].
Detection methods
• Automated Static Analysis: Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)
Observed examples
• 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-2021-22205: Chain: backslash followed by a newline can bypass a validation step (CWE-20), leading to eval injection (CWE-95), 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.
Related
Attack pattern · CAPEC (1)
- CAPEC-35 Leverage Executable Code in Non-Executable Files attack pattern
Observed example · CVE (16)
- CVE-2024-4181 A command injection vulnerability exists in the RunGptLLM class of the llama_index library, version 0.9.47, used by the RunGpt framework… vulnerability
- CVE-2022-2054 Code Injection in GitHub repository nuitka/nuitka prior to 0.9. vulnerability
- CVE-2021-22204 Improper neutralization of user data in the DjVu file format in ExifTool versions 7.44 and up allows arbitrary code execution when parsing… vulnerability
- CVE-2021-22205 An issue has been discovered in GitLab CE/EE affecting all versions starting from 11.9. vulnerability
- CVE-2008-5305 Eval injection vulnerability in TWiki before 4.2.4 allows remote attackers to execute arbitrary Perl code via the %SEARCH{}% variable. vulnerability
- CVE-2008-5071 Multiple eval injection vulnerabilities in itpm_estimate.php in Yoxel 1.23beta and earlier allow remote authenticated users to execute… vulnerability
- CVE-2007-1253 Eval injection vulnerability in the (a) kmz_ImportWithMesh.py Script for Blender 0.1.9h, as used in (b) Blender before 2.43, allows… vulnerability
- CVE-2005-3302 Eval injection vulnerability in bvh_import.py in Blender 2.36 allows attackers to execute arbitrary Python code via a hierarchy element in… vulnerability
- CVE-2005-2837 Multiple eval injection vulnerabilities in PlainBlack Software WebGUI before 6.7.3 allow remote attackers to execute arbitrary Perl code… vulnerability
- CVE-2005-1527 Eval injection vulnerability in awstats.pl in AWStats 6.4 and earlier, when a URLPlugin is enabled, allows remote attackers to execute… vulnerability
- CVE-2005-2498 Eval injection vulnerability in PHPXMLRPC 1.1.1 and earlier (PEAR XML-RPC for PHP), as used in multiple products including (1) Drupal, (2)… vulnerability
- CVE-2005-1921 Eval injection vulnerability in PEAR XML_RPC 1.3.0 and earlier (aka XML-RPC or xmlrpc) and PHPXMLRPC (aka XML-RPC For PHP or php-xmlrpc)… vulnerability
- CVE-2002-1750 csGuestbook.cgi in CGISCRIPT.NET csGuestbook 1.0 allows remote attackers to execute arbitrary Perl code via the setup parameter, which is… vulnerability
- CVE-2002-1752 csChatRBox.cgi in CGIScript.net csChat-R-Box allows remote attackers to execute arbitrary Perl code via the setup parameter, which is… vulnerability
- CVE-2002-1753 csNewsPro.cgi in CGIScript.net csNews Professional (csNewsPro) allows remote attackers to execute arbitrary Perl code via the setup… vulnerability
- CVE-2001-1471 prefs.php in phpBB 1.4.0 and earlier allows remote authenticated users to execute arbitrary PHP code via an invalid language value, which… vulnerability
Child of · CWE (1)
- CWE-94 Improper Control of Generation of Code weakness
Referenced by CAPEC · weakness (1)
- CAPEC-35 Leverage Executable Code in Non-Executable Files attack pattern
Referenced by CVE · weakness (219)
- CVE-2026-119121 Crawl4AI from 0.9.0 before 0.9.5 contains a JavaScript injection vulnerability in the Docker API server that allows authenticated API… vulnerability
- CVE-2026-90872 Improper neutralization of directives in dynamically evaluated code in the Manager web console of Progress Software WS_FTP Server versions… vulnerability
- CVE-2026-44179 XWiki Remote Macros provides XWiki rendering macros that are useful when migrating content from Confluence. vulnerability
- CVE-2026-78497 JQ::Lite versions before 2.51 for Perl execute Perl code embedded in a query's regular expression by compiling it with string eval. vulnerability
- CVE-2026-111865 A security flaw has been discovered in THU-MIG yoloe up to 40cd606cabdbe2b566d6f14a6b162c89206e9a1b. vulnerability
- CVE-2026-111212 A security flaw has been discovered in ImprintLab Medical-SAM-Adapter 0.1.0-alpha/0.1.0. vulnerability
- CVE-2026-111237 A weakness has been identified in Ultralytics FastSAM up to b4ed20c2fed75eadc5aa7d8b09fedd137b873b52. vulnerability
- CVE-2026-111391 SGLang 0.5.10 through 0.5.22 contains a code injection vulnerability in _evaluate_filter() that allows remote attackers to execute Python… vulnerability
- CVE-2026-111687 WeRSS (we-mp-rss) through 1.5.3 contains a remote code execution vulnerability that allows unauthenticated attackers to run code via the… vulnerability
- CVE-2026-86002 Dokku is a docker-powered platform as a service. vulnerability
- CVE-2026-63350 Affected devices do not properly restrict executable content contained in imported trace files. vulnerability
- CVE-2026-65141 NVIDIA Isaac Lab contains a vulnerability where an attacker could cause an eval injection. vulnerability
- CVE-2026-65954 PHPCSUtils is a suite of utility functions for use with PHP_CodeSniffer. vulnerability
- CVE-2026-108263 Astron Agent is an agentic workflow platform for building and running AI agents. vulnerability
- CVE-2026-85486 Brocade ASCG before 3.5.0 improperly processes user input by evaluating form data prior to validation. vulnerability
- CVE-2026-105315 A vulnerability has been found in django-haystack up to 3.3.0. vulnerability
- CVE-2026-55094 Taskcluster is the task execution framework that supports Mozilla's continuous integration and release processes. vulnerability
- CVE-2026-69662 The application uses unsafe functions that allow execution of inline scripts and string evaluation functions. vulnerability
- CVE-2024-42002 A code injection vulnerability has been discovered in the Robot Operating System 2 (ROS 2) 'ros2topic' command-line tool, affecting all ROS… vulnerability
- CVE-2026-101861 Langflow 1.0.16 before 1.12.0 and 0.0.94 before 1.12.0 contain an unsafe eval() vulnerability in schema.py that allows authenticated… vulnerability
- CVE-2026-100741 Eval injection in the JScript event-script dispatcher in Progressive Robot Ltd's hMailServer, versions 6.0.0 through 6.3.3 on Windows,… vulnerability
- CVE-2026-100840 MONAI through 1.6.0 contains a remote code execution vulnerability in the bundle configuration engine that resolves _target_ values to… vulnerability
- CVE-2026-100842 MONAI through 1.6.0 contains an eval injection vulnerability in _get_fake_spatial_shape() in monai/bundle/scripts.py. vulnerability
- CVE-2026-57149 plone.app.portlets.portlets provides a Plone-specific user interface for plone.portlets, as well as a standard set of portlets that ship… vulnerability
- CVE-2026-76974 SAP Fiori Launchpad does not sufficiently validate certain user-controlled input. vulnerability
- CVE-2026-78847 An issue in gray-matter All versions (verified on 4.0.3) allows the JavaScript engine in lib/engines.js using eval() to parse front matter… vulnerability
- CVE-2025-53837 XWiki Rendering is a generic rendering system that converts textual input in a given syntax (wiki syntax, HTML, etc) into another syntax… vulnerability
- CVE-2026-63325 Redocly CLI makes OpenAPI validation, linting, and documentation workflows easier. vulnerability
- CVE-2026-19780 Koha Eval Code Injection Remote Code Execution Vulnerability. vulnerability
- CVE-2026-45579 DIRAC is an interware, meaning a software framework for distributed computing. vulnerability
Referenced by CWE · has member (1)
- CWE-884 CWE Cross-section view