Goal Reached Thanks to every supporter — we hit 100%!

Goal: 1000 CNY · Raised: 1000 CNY

100.0%

CWE-94 (对生成代码的控制不恰当(代码注入)) — Vulnerability Class 1330

1330 vulnerabilities classified as CWE-94 (对生成代码的控制不恰当(代码注入)). AI Chinese analysis included.

CWE-94 represents a critical code injection weakness where software constructs executable code using untrusted input without proper sanitization. Attackers typically exploit this vulnerability by injecting malicious scripts or commands into user-supplied fields, such as web forms or API parameters, which the application then executes directly. This allows adversaries to bypass security controls, steal sensitive data, or gain unauthorized administrative access to the underlying system. To prevent such exploits, developers must rigorously validate and sanitize all external inputs, ensuring that only expected characters are processed. Implementing strict allow-listing strategies, utilizing parameterized queries for database interactions, and avoiding dynamic code execution functions like eval() are essential defensive measures. By treating all user input as potentially hostile and applying robust encoding techniques, organizations can effectively neutralize injection vectors and maintain application integrity.

MITRE CWE Description
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.
Common Consequences (4)
Access ControlBypass Protection Mechanism
In some cases, injectable code controls authentication; this may lead to a remote vulnerability.
Access ControlGain Privileges or Assume Identity
Injected code can access resources that the attacker is directly prevented from accessing.
Integrity, Confidentiality, AvailabilityExecute Unauthorized Code or Commands
When a product allows a user's input to contain code syntax, it might be possible for an attacker to craft the code in such a way that it will alter the intended control flow of the product. As a result, code injection can often result in the execution of arbitrary code. Code injection attacks can…
Non-RepudiationHide Activities
Often the actions performed by injected control code are unlogged.
Mitigations (5)
Architecture and DesignRefactor your program so that you do not have to dynamically generate code.
Architecture and DesignRun 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 s…
ImplementationAssume 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…
TestingUse 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.
OperationRun 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).
Examples (2)
This example attempts to write user messages to a message file and allow users to view them.
$MessageFile = "messages.out"; if ($_GET["action"] == "NewMessage") { $name = $_GET["name"]; $message = $_GET["message"]; $handle = fopen($MessageFile, "a+"); fwrite($handle, "<b>$name</b> says '$message'<hr>\n"); fclose($handle); echo "Message Saved!<p>\n"; } else if ($_GET["action"] == "ViewMessages") { include($MessageFile); }
Bad · PHP
name=h4x0r message=%3C?php%20system(%22/bin/ls%20-l%22);?%3E
Attack
edit-config.pl: This CGI script is used to modify settings in a configuration file.
use CGI qw(:standard); sub config_file_add_key { my ($fname, $key, $arg) = @_; # code to add a field/key to a file goes here } sub config_file_set_key { my ($fname, $key, $arg) = @_; # code to set key to a particular file goes here } sub config_file_delete_key { my ($fname, $key, $arg) = @_; # code to delete key from a particular file goes here } sub handleConfigAction { my ($fname, $action) = @_; my $key = param('key'); my $val = param('val'); # this is super-efficient code, especially if you have to invoke # any one of dozens of different functions! my $code = "config_file_$action_key(\$fnam
Bad · Perl
add_key(",","); system("/bin/ls");
Attack
CVE IDTitleCVSSSeverityPublished
CVE-2020-8129 script-manager npm package 代码注入漏洞 — script-manager 9.8 -2020-02-14
CVE-2019-7486 SonicWall SMA100 代码注入漏洞 — SMA100 8.8 -2019-12-19
CVE-2019-15597 node-df 代码注入漏洞 — node-df 9.8 -2019-12-18
CVE-2019-15598 tree-kill 操作系统命令注入漏洞 — treekill 9.8 -2019-12-18
CVE-2019-15599 tree-kill 代码注入漏洞 — tree-kill 9.8 -2019-12-18
CVE-2019-16774 Object injection in cookie driver — phpfastcache 4.4 Medium2019-12-12
CVE-2019-14867 Red Hat FreeIPA 代码注入漏洞 — ipa 8.8 -2019-11-27
CVE-2019-10211 PostgreSQL 输入验证错误漏洞 — postgresql 9.8 -2019-10-29
CVE-2019-3652 ENS code injection in EPSetup.exe — McAfee Endpoint Security (ENS) 5.0 Medium2019-10-09
CVE-2019-13558 Advantech WebAccess 代码注入漏洞 — WebAccess 9.8 -2019-09-18
CVE-2019-3759 Dell RSA Identity Governance and Lifecycle和RSA Via Lifecycle and Governance 代码注入漏洞 — RSA Identity Governance and Lifecycle 6.4 Medium2019-09-11
CVE-2019-2390 Code execution on Windows via OpenSSL engine injection — MongoDB Server 8.2 High2019-08-30
CVE-2019-9140 Happypoint mobile application information disclosure vulnerability — Happypoint mobile app 8.1 -2019-08-01
CVE-2019-10173 XStream 代码注入漏洞 — xstream 9.8 -2019-07-23
CVE-2019-6823 Schneider Electric ProClima 代码注入漏洞 — ProClima all versions prior to version 8.0.0 9.8 -2019-07-15
CVE-2019-5443 Haxx curl 代码问题漏洞 — curl 7.8 -2019-07-02
CVE-2014-5401 Hospira MedNet Code Injection — MedNet 9.8 -2019-03-26
CVE-2019-7610 Elasticsearch Kibana 命令注入漏洞 — Kibana 9.0 -2019-03-25
CVE-2019-7609 Elasticsearch Kibana 代码注入漏洞 — Kibana 9.6 -2019-03-25
CVE-2019-5413 npm package morgan 安全漏洞 — morgan 9.8 -2019-03-17
CVE-2018-19002 LCDS LAquis SCADA 代码注入漏洞 — LCDS Laquis SCADA 7.8 -2019-02-05
CVE-2018-19011 Omron CX-Supervisor 代码注入漏洞 — CX-Supervisor 7.3 -2019-01-22
CVE-2017-1002152 Bodhi 跨站脚本漏洞 — Bodhi 6.1 -2019-01-10
CVE-2018-0461 Cisco IP Phone 8800 Series Arbitrary Script Injection Vulnerability — Cisco IP Phone 8800 Series Software 8.3 -2019-01-10
CVE-2018-14667 RichFaces Framework 代码注入漏洞 — RichFaces 9.8 -2018-11-06
CVE-2016-5402 Red Hat CloudForms Management Engine 代码注入漏洞 — cfme 8.8 -2018-10-31
CVE-2018-3784 cryo 代码注入漏洞 — cryo 9.8 -2018-08-17
CVE-2017-16082 pg模块安全漏洞 — pg node module 9.8 -2018-06-07
CVE-2017-16100 dns-sync 安全漏洞 — dns-sync node module 9.8 -2018-06-07
CVE-2017-16151 Google Chromium Electron 安全漏洞 — electron node module 9.8 -2018-06-07

Vulnerabilities classified as CWE-94 (对生成代码的控制不恰当(代码注入)) represent 1330 CVEs. The CWE taxonomy describes the weakness; review individual CVEs for product-specific impact.