CWE-96: Improper Neutralization of Directives in Statically Saved Code ('Static Code Injection')

Base Draft Simple

CWE版本: 4.18

更新日期: 2025-09-09

弱点描述

The product receives input from an upstream component, but it does not neutralize or incorrectly neutralizes code syntax before inserting the input into an executable resource, such as a library, configuration file, or template.

常见后果

影响范围: 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.

影响范围: Non-Repudiation

技术影响: Hide Activities

说明: Often the actions performed by injected control code are unlogged.

潜在缓解措施

阶段: Implementation

策略: Input Validation

阶段: Implementation

策略: Output Encoding

描述: Perform proper output validation and escaping to neutralize all code syntax from data written to code files.

观察示例

参考: 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.

参考: CVE-2007-6652

chain: execution after redirect allows non-administrator to perform static code injection.

引入模式

阶段 说明
Implementation REALIZATION: This weakness is caused during implementation of an architectural security tactic.
Implementation This issue is frequently found in PHP applications that allow users to set configuration variables that are stored within executable PHP files. Technically, this could also be performed in some compiled code (e.g., by byte-patching an executable), although it is highly unlikely.

适用平台

编程语言
PHP (Undetermined) Perl (Undetermined) Interpreted (Undetermined)

分类映射

分类名称 条目ID 条目名称 映射适配度
PLOVER - Direct Static Code Injection -
Software Fault Patterns SFP24 Tainted Input to Command -
关键信息

CWE ID: CWE-96

抽象级别: Base

结构: Simple

状态: Draft

相关弱点
相关攻击模式
CAPEC-35 CAPEC-73 CAPEC-77 CAPEC-81 CAPEC-85