PhpWebGallery — 2 vulnerability checks
noctis ships 2 vulnerability checks for PhpWebGallery, covering 2 CVEs; each one has to observe the bug on the live service before it reports a finding.
← All products · Feeds on GitHub
PhpWebGallery isadmin.inc.php user[language] Local File Inclusion
| CVE | CVE-2008-4702 |
|---|---|
| Severity | high · CVSS 7.5 |
| Category | file-read — File read |
| Services | http, https |
| Detection | script, set_var, http_request, match · highest QoD 75 |
| Feed | tests/vulnerabilities/phpwebgallery/CVE-2008-4702.yaml |
Tests PhpWebGallery 1.3.4 and earlier for the local file inclusion in admin/include/isadmin.inc.php, which includes ../language/<user[language]>.php without validating the value. Under /phpwebgallery, /gallery, /photos, /phpwg and the web root, the feed requests the page with user[language]=../../language/english and a random marker in lang[access_forbiden]: when the gallery's own English language file is included, the page prints that file's text instead of the marker. A second request naming an absent language file must print the marker, which proves the request chose the included file. Only the gallery's own language file is included; nothing is written or executed beyond it.
How noctis detects it
- Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{dir}}/admin/include/isadmin.inc.php?lang%5Baccess_forbiden%5D={{sc.marker}}&user%5B… - HTTP(S) request
GET {{dir}}/admin/include/isadmin.inc.php?lang%5Baccess_forbiden%5D={{sc.marker}}&user%5B… - Parses / computes the next value with a Rhai script
- Checks
real_r.bodyforYou are not authorized to access this page→ finding QoD 75: PhpWebGallery isadmin.inc.php user[language] Local File Inclusion (CVE-2008-4702)
References:
Feed source — tests/vulnerabilities/phpwebgallery/CVE-2008-4702.yaml
# PhpWebGallery 1.3.4 isadmin.inc.php user[language] local file inclusion — CVE-2008-4702
#
# PhpWebGallery 1.3.4 and earlier include the language file chosen by
# $user['language'] without checking it:
# include_once( '../language/'.$user['language'].'.php' );
# in admin/include/isadmin.inc.php (and in include/init.inc.php, with
# user[template] in a second include). Requested directly, the guard's relative
# includes do not resolve, so $user is never filled from the database and, with
# register_globals on, user[language]=../../<file> from the request is included.
# The CVE record names user[language] / user[template] in init.inc.php and
# user[language] in isadmin.inc.php.
#
# Detection (benign — only includes the gallery's own English language file,
# which just defines text strings, and a random absent name):
# A GET <dir>/admin/include/isadmin.inc.php
# ?lang[access_forbiden]=<marker>&user[language]=../../language/english
# B GET <dir>/admin/include/isadmin.inc.php
# ?lang[access_forbiden]=<marker>&user[language]=../../language/<absent>
# The include of a real language file redefines $lang, so the page then shows
# the gallery's own "You are not authorized to access this page" text and not
# the marker. The absent name includes nothing and the marker is printed.
# A finding needs A to show the English text without the marker AND B to show
# the marker (QoD 75): the request really chose which file was included. This
# does not depend on display_errors, unlike matching the include warning.
# Payloads have no quote or NUL byte, so magic_quotes_gpc changes nothing.
#
# Improvements over the reference check: it only covered the XSS of the same
# file; the include is tested here, per CVE.
#
# CVSS: CVE-2008-4702 has only a v2 score in NVD (7.5), so there is no v3.x
# score to align on; 7.5 / high is the NVD v2 base score.
#
# Ported from OpenVAS/Greenbone NVT 2008/gb_phpwebgallery_mult_vuln_oct08.nasl
# (OID 1.3.6.1.4.1.25623.1.0.800115, GPL-2.0-only).
uid: 81f90866-592b-43e6-b722-dafebf1e5eee
name: "PhpWebGallery isadmin.inc.php user[language] Local File Inclusion (CVE-2008-4702)"
description: |
Tests PhpWebGallery 1.3.4 and earlier for the local file inclusion in
admin/include/isadmin.inc.php, which includes ../language/<user[language]>.php
without validating the value. Under /phpwebgallery, /gallery, /photos,
/phpwg and the web root, the feed requests the page with
user[language]=../../language/english and a random marker in
lang[access_forbiden]: when the gallery's own English language file is
included, the page prints that file's text instead of the marker. A second
request naming an absent language file must print the marker, which proves
the request chose the included file. Only the gallery's own language file is
included; nothing is written or executed beyond it.
cves: [CVE-2008-4702]
cvss: 7.5
severity: high
category: file-read
confidence_base: 0.30
tags: [phpwebgallery, piwigo, gallery, php, lfi, file-inclusion, unauthenticated]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2008-4702"
- "https://nvd.nist.gov/vuln/detail/CVE-2008-4591"
# OpenVAS/Greenbone NASL 2008/gb_phpwebgallery_mult_vuln_oct08.nasl (GPL-2.0-only)
steps:
- id: gen-marker
action: script
code: |
let m = "noctis" + oob_token.sub_string(0, 8) + oob_token.sub_string(9, 4);
#{ marker: m }
store_as: sc
# ── Loop group: every following step runs once per folder ────────────────
- id: init-real-r
action: set_var
var_name: real_r
var_value: {status: 0, body: ""}
loop:
var: dir
over: ["/phpwebgallery", "/gallery", "/photos", "/phpwg", ""]
- id: init-absent-r
action: set_var
var_name: absent_r
var_value: {status: 0, body: ""}
- id: init-hit
action: set_var
var_name: hit
var_value: false
# A: include the gallery's own English language file
- id: probe-real
action: http_request
method: GET
path: "{{dir}}/admin/include/isadmin.inc.php?lang%5Baccess_forbiden%5D={{sc.marker}}&user%5Blanguage%5D=../../language/english"
port: "{{port}}"
tls_insecure: true
timeout_secs: 15
store_as: real_r
# B: same request, absent language file
- id: probe-absent
action: http_request
method: GET
path: "{{dir}}/admin/include/isadmin.inc.php?lang%5Baccess_forbiden%5D={{sc.marker}}&user%5Blanguage%5D=../../language/{{sc.marker}}"
port: "{{port}}"
tls_insecure: true
timeout_secs: 15
condition: "real_r.status == 200"
store_as: absent_r
- id: check
action: script
condition: "real_r.status == 200"
code: |
let a = if type_of(real_r.body) == "string" { real_r.body } else { "" };
let b = if type_of(absent_r.body) == "string" { absent_r.body } else { "" };
absent_r.status == 200
&& a.contains("You are not authorized to access this page")
&& !a.contains(sc.marker)
&& b.contains(sc.marker)
store_as: hit
# ── Finding ───────────────────────────────────────────────────────────────
- id: report
action: match
source: real_r.body
pattern: "You are not authorized to access this page"
condition: "hit == true"
on_match:
finding:
title: "PhpWebGallery isadmin.inc.php user[language] Local File Inclusion (CVE-2008-4702)"
description: "An unauthenticated request to admin/include/isadmin.inc.php with user[language]=../../language/english made the page include the gallery's own English language file (its text replaced the random marker sent in lang[access_forbiden]), while an absent language name included nothing and printed the marker. The user[language] value is concatenated into an include path without validation, so an attacker can include and run other local PHP files, and with a NUL byte on old PHP, other local files."
remediation: "Upgrade PhpWebGallery to 1.6.0 or later (now Piwigo), which no longer ships this file, and turn register_globals off in PHP. As a stop-gap, deny web access to the admin/include/ folder."
confidence_delta: 0.50
qod: 75
evidence: "{{dir}}/admin/include/isadmin.inc.php?user[language]=../../language/english printed the gallery's English language text instead of the marker {{sc.marker}}; user[language]=../../language/{{sc.marker}} printed the marker"
stop: truePhpWebGallery isadmin.inc.php lang Reflected Cross-Site Scripting
| CVE | CVE-2008-4591 |
|---|---|
| Severity | medium · CVSS 4.3 |
| Category | xss — XSS |
| Services | http, https |
| Detection | script, set_var, http_request, match · highest QoD 75 |
| Feed | tests/vulnerabilities/phpwebgallery/CVE-2008-4591.yaml |
Tests PhpWebGallery 1.3.4 and earlier (and the 1.4.x / 1.5.x releases that keep the same file) for the reflected cross-site scripting in admin/include/isadmin.inc.php, which prints the lang[access_forbiden] and lang[ident_title] request parameters into its "access forbidden" page without escaping. Under /phpwebgallery, /gallery, /photos, /phpwg and the web root, the feed requests admin/include/isadmin.inc.php?lang[access_forbiden]=<script>alert(/marker/)</script>, where the marker is random for each scan, and reports the install when that exact script element comes back unescaped in a 200 reply. A control request sending the same payload to a random, absent .php file in the same folder must not reflect it, so a server that echoes any parameter is not reported. The script is harmless and only reaches the scanner.
How noctis detects it
- Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{dir}}/admin/include/isadmin.inc.php?lang%5Baccess_forbiden%5D=%3Cscript%3Ealert(/{{… - Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{dir}}/admin/include/{{sc.marker}}.php?lang%5Baccess_forbiden%5D=%3Cscript%3Ealert(/… - Parses / computes the next value with a Rhai script
- Checks
hitfor^reflected$→ finding QoD 75: PhpWebGallery isadmin.inc.php lang Reflected Cross-Site Scripting (CVE-2008-4591)
References:
Feed source — tests/vulnerabilities/phpwebgallery/CVE-2008-4591.yaml
# PhpWebGallery 1.3.4 admin/include/isadmin.inc.php reflected XSS — CVE-2008-4591
#
# PhpWebGallery 1.3.4 and earlier ship admin/include/isadmin.inc.php, a guard
# included by the admin pages. Requested directly, its relative includes
# ('../include/config.inc.php', ...) do not resolve, so $user stays undefined
# and the "access forbidden" branch prints $lang['access_forbiden'] and
# $lang['ident_title'] into the page unescaped. With register_globals on (the
# PHP 4 era default for such installs) both can be set from the request:
# lang[access_forbiden]=<script>...</script>. The language file that would
# overwrite them is never loaded because user[language] is empty, so the
# request values survive. The file itself is only removed in 1.6.0: 1.4.x and
# 1.5.x still print the same unescaped $lang values (their PHPWG_ROOT_PATH is
# undefined when the file is requested directly), so they stay exposed under
# register_globals even though NVD lists 1.3.4 only.
#
# Detection (benign — the injected script only names a random marker and is
# shown to nobody but the scanner): GET
# <dir>/admin/include/isadmin.inc.php?lang[access_forbiden]=<script>alert(/<marker>/)</script>
# (percent-encoded, no quote so magic_quotes_gpc cannot change it) and look
# for that exact unescaped script element in a 200 reply (QoD 75).
#
# Improvements over the reference check:
# - The reference only tries the folder its product detection found and
# matches a fixed string; the feed walks the usual install folders and
# sends a random marker per scan.
# - A control request sends the same payload to a random, absent .php file
# in the same folder: a server that reflects it there too is a generic
# parameter reflector, not PhpWebGallery, and is not reported
# (fail-closed: no control reply, no finding).
# - It tests the behaviour, not a version banner (the reference only reported
# under safe checks when the page footer showed <= 1.3.4), so 1.4.x and
# 1.5.x, which reflect the same way, are reported too.
#
# CVSS: CVE-2008-4591 has only a v2 score in NVD (4.3). The issue's 7.5 is the
# v2 score of the sibling CVE-2008-4702 (see CVE-2008-4702.yaml).
#
# Ported from OpenVAS/Greenbone NVT 2008/gb_phpwebgallery_mult_vuln_oct08.nasl
# (OID 1.3.6.1.4.1.25623.1.0.800115, GPL-2.0-only).
uid: 28943c6d-2f64-4ff3-b8b7-f340ea9a2621
name: "PhpWebGallery isadmin.inc.php lang Reflected Cross-Site Scripting (CVE-2008-4591)"
description: |
Tests PhpWebGallery 1.3.4 and earlier (and the 1.4.x / 1.5.x releases that keep the same file) for the reflected cross-site
scripting in admin/include/isadmin.inc.php, which prints the
lang[access_forbiden] and lang[ident_title] request parameters into its
"access forbidden" page without escaping. Under /phpwebgallery, /gallery,
/photos, /phpwg and the web root, the feed requests
admin/include/isadmin.inc.php?lang[access_forbiden]=<script>alert(/marker/)</script>,
where the marker is random for each scan, and reports the install when that
exact script element comes back unescaped in a 200 reply. A control request
sending the same payload to a random, absent .php file in the same folder
must not reflect it, so a server that echoes any parameter is not
reported. The script is harmless and only reaches the scanner.
cves: [CVE-2008-4591]
cvss: 4.3
severity: medium
category: xss
confidence_base: 0.30
tags: [phpwebgallery, piwigo, gallery, php, xss, reflected-xss, unauthenticated]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2008-4591"
- "https://nvd.nist.gov/vuln/detail/CVE-2008-4702"
# OpenVAS/Greenbone NASL 2008/gb_phpwebgallery_mult_vuln_oct08.nasl (GPL-2.0-only)
steps:
# ── Random marker and the exact script element to look for ───────────────
- id: gen-marker
action: script
code: |
let m = "noctis" + oob_token.sub_string(0, 8) + oob_token.sub_string(9, 4);
#{ marker: m, want: "<script>alert(/" + m + "/)</script>" }
store_as: sc
# ── Loop group: every following step runs once per folder ────────────────
- id: init-probe-r
action: set_var
var_name: probe_r
var_value: {status: 0, body: ""}
loop:
var: dir
over: ["/phpwebgallery", "/gallery", "/photos", "/phpwg", ""]
- id: init-ctrl-r
action: set_var
var_name: ctrl_r
var_value: {status: 0, body: ""}
- id: init-ctrl-clean
action: set_var
var_name: ctrl_clean
var_value: false
- id: init-hit
action: set_var
var_name: hit
var_value: ""
- id: probe
action: http_request
method: GET
path: "{{dir}}/admin/include/isadmin.inc.php?lang%5Baccess_forbiden%5D=%3Cscript%3Ealert(/{{sc.marker}}/)%3C/script%3E"
port: "{{port}}"
tls_insecure: true
timeout_secs: 15
store_as: probe_r
- id: check
action: script
code: |
let body = if type_of(probe_r.body) == "string" { probe_r.body } else { "" };
if probe_r.status == 200 && body.contains(sc.want) { "reflected" } else { "" }
store_as: hit
# ── Control: the same payload to a random, absent .php file ──────────────
- id: control
action: http_request
method: GET
path: "{{dir}}/admin/include/{{sc.marker}}.php?lang%5Baccess_forbiden%5D=%3Cscript%3Ealert(/{{sc.marker}}/)%3C/script%3E"
port: "{{port}}"
tls_insecure: true
timeout_secs: 15
condition: 'hit != ""'
store_as: ctrl_r
- id: control-check
action: script
condition: 'hit != ""'
code: |
let body = if type_of(ctrl_r.body) == "string" { ctrl_r.body } else { "" };
ctrl_r.status != 0 && !body.contains(sc.want)
store_as: ctrl_clean
# ── Finding ───────────────────────────────────────────────────────────────
- id: report
action: match
source: hit
pattern: "^reflected$"
condition: "ctrl_clean == true"
on_match:
finding:
title: "PhpWebGallery isadmin.inc.php lang Reflected Cross-Site Scripting (CVE-2008-4591)"
description: "An unauthenticated request to admin/include/isadmin.inc.php with lang[access_forbiden] set to a script element carrying a random marker returned that script element unescaped in the page, while an absent .php file in the same folder did not reflect it. An attacker can send a gallery administrator a link that runs any script in the gallery origin, for example to steal the session cookie."
remediation: "Upgrade PhpWebGallery to 1.6.0 or later (now Piwigo), which no longer ships this file, and turn register_globals off in PHP. As a stop-gap, deny web access to the admin/include/ folder."
confidence_delta: 0.50
qod: 75
evidence: "{{dir}}/admin/include/isadmin.inc.php?lang[access_forbiden]=<script>alert(/{{sc.marker}}/)</script> was reflected unescaped: {{sc.want}}; the same payload sent to an absent script ({{dir}}/admin/include/{{sc.marker}}.php) was not"
stop: true