CWEweakness

CWE-624 Executable Regular Expression Error

Official page ↗
Abstraction
Base
Structure
Simple
Status
Incomplete
Languages
PHP, Perl
CWE version
5.0

Description

The product uses a regular expression that either (1) contains an executable component with user-controlled inputs, or (2) allows a user to enable execution by inserting pattern modifiers.

Extended description

Case (2) is possible in the PHP preg_replace() function, and possibly in other languages when a user-controlled input is inserted into a string that is later parsed as a regular expression.

Common consequences

• Confidentiality, Integrity, Availability: Execute Unauthorized Code or Commands

Potential mitigations

• [Implementation] The regular expression feature in some languages allows inputs to be quoted or escaped before insertion, such as \Q and \E in Perl.

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-2006-2059: Executable regexp in PHP by inserting "e" modifier into first argument to preg_replace • CVE-2005-3420: Executable regexp in PHP by inserting "e" modifier into first argument to preg_replace • CVE-2006-2878: Complex curly syntax inserted into the replacement argument to PHP preg_replace(), which uses the "/e" modifier • CVE-2006-2908: Function allows remote attackers to execute arbitrary PHP code via the username field, which is used in a preg_replace function call with a /e (executable) modifier.

Related

Observed example · CVE (4)

  • CVE-2006-2908 The domecode function in inc/functions_post.php in MyBulletinBoard (MyBB) 1.1.2, and possibly other versions, allows remote attackers to… vulnerability
  • CVE-2006-2878 The spellchecker (spellcheck.php) in DokuWiki 2006/06/04 and earlier allows remote attackers to insert and execute arbitrary PHP code via… vulnerability
  • CVE-2006-2059 action_public/search.php in Invision Power Board (IPB) 2.1.x and 2.0.x before 20060425 allows remote attackers to execute arbitrary PHP… vulnerability
  • CVE-2005-3420 usercp_register.php in phpBB 2.0.17 allows remote attackers to modify regular expressions and execute PHP code via the signature_bbcode_uid… vulnerability

Child of · CWE (1)

  • CWE-77 Improper Neutralization of Special Elements used in a Command weakness

Referenced by CVE · weakness (4)

  • CVE-2026-113877 HTTP::Headers::ActionPack versions before 0.10 for Perl allow CPU exhaustion via Accept-Language ranges matched as regular expressions. vulnerability
  • CVE-2026-97076 Executable Regular Expression Error vulnerability in WP Media WP Rocket wp-rocket allows Code Injection.This issue affects WP Rocket: from… vulnerability
  • CVE-2026-25237 PEAR is a framework and distribution system for reusable PHP components. vulnerability
  • CVE-2024-41655 TF2 Item Format helps users format TF2 items to the community standards. vulnerability