Aphpkb — 1 vulnerability check
noctis ships 1 vulnerability check for Aphpkb, covering 1 CVE; each one has to observe the bug on the live service before it reports a finding.
← All products · Feeds on GitHub
Andy's PHP Knowledgebase 0.95.2 a_viewusers.php s SQL injection
| CVE | CVE-2011-1546 |
|---|---|
| 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/aphpkb/CVE-2011-1546.yaml |
Andy's PHP Knowledgebase 0.95.2 uses the s parameter of a_viewusers.php in an SQL query without any filtering, so an unauthenticated visitor can inject SQL into the knowledge base database.
Under the web root and the usual knowledge base paths, this check requests the registered users page with s=0 as a control, then with a UNION SELECT of seven columns whose first column is the sum of two random numbers written as an expression. The vulnerability is reported when the sum appears in the response to the injected request and not in the control. Nothing is written and no data is read from the database.
How noctis detects it
- Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{adir}}/a_viewusers.php?s=0 - HTTP(S) request
GET {{adir}}/a_viewusers.php?s=1%20UNION%20SELECT%20{{sc.expr}},null,null,null,null,null,… - Parses / computes the next value with a Rhai script
- Checks
res.foundfor^UNION$→ finding QoD 97: Andy's PHP Knowledgebase a_viewusers.php s SQL injection (CVE-2011-1546)
References:
Feed source — tests/vulnerabilities/aphpkb/CVE-2011-1546.yaml
# Andy's PHP Knowledgebase 0.95.2 — a_viewusers.php s SQL injection (CVE-2011-1546)
#
# a_viewusers.php (0.95.2) appends the s parameter to the query unfiltered:
# SELECT <7 columns> FROM authors AS au LIMIT $start, $display
# so "s=1 UNION SELECT <7 columns> limit 0" adds a row that the page prints in the
# user table (first column = author name). Fixed in 0.95.3 (s goes through mifi(), an
# is_numeric()/intval() filter). Source of both versions checked on SourceForge.
#
# Detection (QoD 97), per candidate install dir (web root, /aphpkb, /kb, /knowledgebase):
# 0. Control — a_viewusers.php?s=0 must be the Knowledgebase "View Registered Users"
# page and must not contain the random sum computed below.
# 1. s=1 UNION SELECT A+B,null,null,null,null,null,null limit 0 (random 6-digit A, B):
# the sum can only appear in the body when MySQL evaluated our arithmetic; the
# request itself carries only "A+B".
# Read-only: a constant SELECT, nothing is written, nothing is read from the database.
#
# Better than the source NASL: it reads /etc/passwd with load_file(), which needs the
# MySQL FILE privilege (false negative on any normally configured install) and does not
# prove injection where the privilege is missing; the computed sum needs no privilege.
# CVSS: NVD carries only a CVSS v2 score (7.5) for this CVE.
#
# Source: OpenVAS/Greenbone NVT 2011/gb_aphpkb_47097.nasl
# (OID 1.3.6.1.4.1.25623.1.0.103135, GPL-2.0-only).
uid: de9700ed-d3c8-416d-a708-e06a93dc8fb9
name: "Andy's PHP Knowledgebase 0.95.2 a_viewusers.php s SQL injection (CVE-2011-1546)"
description: |
Andy's PHP Knowledgebase 0.95.2 uses the s parameter of a_viewusers.php in an SQL
query without any filtering, so an unauthenticated visitor can inject SQL into the
knowledge base database.
Under the web root and the usual knowledge base paths, this check requests the
registered users page with s=0 as a control, then with a UNION SELECT of seven
columns whose first column is the sum of two random numbers written as an
expression. The vulnerability is reported when the sum appears in the response to
the injected request and not in the control. Nothing is written and no data is read
from the database.
cves: [CVE-2011-1546]
cvss: 7.5 # NVD publishes only a CVSS v2 base score (7.5) for this CVE
severity: high
category: sqli
confidence_base: 0.30
tags: [aphpkb, php, sqli, union-based]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2011-1546"
steps:
- id: gen-operands
action: script
code: |
let a = rand_int(100000, 999999);
let b = rand_int(100000, 999999);
#{ a: a, b: b, sum: "" + (a + b), expr: "" + a + "%2B" + b }
store_as: sc
# A loop: step runs together with every following non-loop step once per directory;
# pre-initialise the stored results a condition reads.
- id: init-ctl
action: set_var
var_name: ctl_resp
var_value: {status: 0, body: null}
loop:
over: ["", "/aphpkb", "/kb", "/knowledgebase"]
var: adir
- id: init-inj
action: set_var
var_name: inj_resp
var_value: {status: 0, body: null}
- id: control
action: http_request
method: GET
port: "{{port}}"
path: "{{adir}}/a_viewusers.php?s=0"
tls_insecure: true
follow_redirects: false
timeout_secs: 15
store_as: ctl_resp
- id: inject
action: http_request
method: GET
port: "{{port}}"
path: "{{adir}}/a_viewusers.php?s=1%20UNION%20SELECT%20{{sc.expr}},null,null,null,null,null,null%20limit%200"
condition: 'ctl_resp.status == 200 && type_of(ctl_resp.body) == "string" && ereg("View Registered Users", ctl_resp.body) && stridx(ctl_resp.body, sc.sum) < 0'
tls_insecure: true
follow_redirects: false
timeout_secs: 15
store_as: inj_resp
- id: check
action: script
code: |
let b = if type_of(inj_resp.body) == "string" { inj_resp.body } else { "" };
let ok = inj_resp.status == 200 && stridx(b, sc.sum) >= 0;
#{ ok: ok, found: if ok { "UNION" } else { "" } }
store_as: res
- id: report
action: match
source: res.found
pattern: "^UNION$"
condition: "res.ok"
on_match:
finding:
title: "Andy's PHP Knowledgebase a_viewusers.php s SQL injection (CVE-2011-1546)"
description: "The database evaluated arithmetic injected through a UNION SELECT in the s parameter of a_viewusers.php: an unauthenticated attacker can run arbitrary SQL against the knowledge base database and read its content, including author accounts."
remediation: "Upgrade Andy's PHP Knowledgebase to 0.95.3 or later, which filters s with an integer cast."
confidence_delta: 0.65
qod: 97
evidence: "UNION SELECT of 7 columns {{sc.a}}+{{sc.b}} on {{adir}}/a_viewusers.php: the response contains {{sc.sum}} (the control request s=0 does not)"
stop: true