Summary
ThinkPHP 5.0.23 contains a remote code execution flaw where routing parameters can be abused to invoke arbitrary PHP functions.
By sending crafted requests to index.php with malicious function parameters, unauthenticated attackers can execute system commands under the application's privileges.
Affected context
This vulnerability affects applications built on ThinkPHP 5.0.23 that expose the index.php front controller and rely on its routing mechanism.
It is most relevant where routing parameters are mapped directly or indirectly to callable PHP functions without strict whitelisting or validation.
Deployments with publicly accessible entry points and minimal network-layer restrictions are particularly exposed, especially when the PHP process runs with elevated filesystem or system privileges.
Exploit preconditions
- Attack surface: Public HTTP(S) interface exposing index.php.
- Required access: No prior authentication; an attacker only needs network access to the application endpoint.
- Trigger point: Specially crafted HTTP requests that supply routing parameters causing ThinkPHP to resolve and invoke attacker-controlled function names and arguments.
- Why exploitation is possible: The routing/dispatch logic insufficiently restricts what functions can be reached via parameters, failing to enforce a strict whitelist or contextual checks. This allows untrusted input to influence which PHP functions are executed and with what arguments.
Why this happens
The core issue is a broken access control pattern where user-controllable routing parameters are trusted to select and invoke PHP functions.
Instead of confining requests to a predefined set of controller methods, the framework's routing/dispatch layer allows external input to steer execution toward arbitrary callables.
This maps to CWE-639: Insecure Direct Object Reference / Broken Access Control in the sense that internal functionality (function entry points) is exposed directly based on user-supplied identifiers, without sufficient authorization or validation.
Abstractly, this is an insecure design pattern where the control flow of the application (which function runs) is determined by untrusted data, enabling attackers to reach sensitive functions like system command execution APIs.
Potential impact
- Execution of arbitrary PHP code within the web server context.
- Execution of system commands with the privileges of the PHP/application user.
- Full compromise of the affected web application and its underlying data.
- Lateral movement to other services or hosts reachable from the compromised server.
- Installation of backdoors or web shells for persistent access.
- Use of the compromised server as a pivot for further attacks in the environment.
General mitigation guidance
Effective mitigation focuses on reducing the power of routing parameters and tightening access control around callable functionality:
- Enforce strict routing rules that map only to an explicit whitelist of controllers and methods, disallowing dynamic resolution based on raw user input.
- Avoid exposing generic function invocation mechanisms in URLs or query parameters; route only to high-level actions rather than low-level functions.
- Introduce centralized authorization checks that gate sensitive operations and ensure that internal functions are never directly referenced by externally supplied identifiers.
- Limit the privileges of the PHP runtime and web server user to reduce the blast radius of any successful exploitation.
- Apply defense-in-depth controls such as disabling or restricting high-risk PHP functions (e.g., command execution APIs) where they are not strictly required.
How teams detect issues like this
Detection approaches generally revolve around both code-centric and runtime analysis:
- Static analysis and manual code review focused on routing and dispatch logic, looking for patterns where user input selects functions, methods, or internal handlers without strict whitelisting.
- Search for dynamic function calls or reflection-based invocation paths that are influenced by GET/POST parameters or path segments.
- Web application firewall (WAF) or reverse proxy rules to flag or block requests containing suspicious function names or command-like arguments in routing parameters.
- Runtime monitoring and logging of unusual function invocation patterns or command execution events originating from web requests, coupled with anomaly detection.
- Automated security testing tools (SAST/DAST) configured to probe routing paths and attempt to escalate from normal controller access to unexpected internal functionality.

