Matt Wright Guestbook — 1 vulnerability check
noctis ships 1 vulnerability check for Matt Wright Guestbook, covering 1 CVE; each one has to observe the bug on the live service before it reports a finding.
← All products · Feeds on GitHub
Matt Wright Guestbook guestbook.pl SSI Injection
| CVE | CVE-1999-1053 |
|---|---|
| Severity | high · CVSS 7.5 |
| Category | rce — Remote code execution |
| Services | http, https |
| Detection | script, set_var, http_request, match · highest QoD 75 |
| Feed | tests/vulnerabilities/matt-wright-guestbook/CVE-1999-1053.yaml |
Detects guestbook.pl from Matt Wright's Guestbook 2.3.1 and earlier (CVE-1999-1053). The script removes server-side include (SSI) commands from visitor input only when they form a complete "<!-- ... -->" comment, so an unclosed directive such as <!--#exec cmd="..." is written as is into the guestbook page, where a web server that parses SSI in .html files runs the command. Under the web root, /cgi-bin, /scripts, /cgi-local, /guestbook and /cgi-bin/guestbook, the feed sends guestbook.pl (and guestbook.cgi, the name hosts requiring .cgi use) one POST that holds only a city field (no comment, so the script adds no guestbook entry, only an error line to its log, and answers with its "Your Comments appear to be blank" form) made of per-run random text, a complete comment and an unclosed, harmless <!--#echo directive. It reports the script when the returned form shows the city with the complete comment removed and the unclosed directive kept, which is the vulnerable filter at work: a page that merely echoes its input, or that HTML-escapes it, does not match. Whether the server actually runs SSI in the guestbook page is not tested.
How noctis detects it
- Parses / computes the next value with a Rhai script
- HTTP(S) request
POST {{url}}with a crafted body - Parses / computes the next value with a Rhai script
- Checks
verdictfor^POST→ finding QoD 75: Matt Wright Guestbook guestbook.pl SSI injection
References:
- https://nvd.nist.gov/vuln/detail/CVE-1999-1053
- http://www.securityfocus.com/bid/776
- http://www.securityfocus.com/archive/1/33674
- https://www.rapid7.com/db/modules/exploit/unix/webapp/guestbook_ssi_exec/
Feed source — tests/vulnerabilities/matt-wright-guestbook/CVE-1999-1053.yaml
# Matt Wright's Guestbook (Matt's Script Archive) guestbook.pl <= 2.3.1 —
# server-side include injection through guestbook entries (CVE-1999-1053,
# BID 776, Metasploit exploit/unix/webapp/guestbook_ssi_exec)
#
# Credit: target locations adapted from Greenbone's `pre2008/guestbook_pl.nasl`
# (GPL-2.0-only), which only reports that <dir>/guestbook.pl exists
# (http_is_cgi_installed_ka) under / and the CGI dirs.
#
# Source facts (guestbook.pl 2.3.1, the last release; never fixed upstream —
# Matt's Script Archive points to the NMS drop-in replacement instead):
# foreach $pair (@pairs) {
# ($name, $value) = split(/=/, $pair);
# $value =~ tr/+/ /;
# $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
# $value =~ s/<!--(.|\n)*-->//g; # the only SSI filter
# if ($allow_html != 1) { $value =~ s/<([^>]|\n)*>//g; }
# $FORM{$name} = $value; }
# &no_comments unless $FORM{'comments'}; # page below, then exit
# ... print GUEST "<b>$FORM{'comments'}</b><br>\n"; # entry -> guestbook.html
# The filter only drops a COMPLETE "<!-- … -->" comment. An unclosed directive
# such as <!--#exec cmd="…" (the Metasploit payload) survives — and so does
# it with $allow_html = 0, the tag stripper needing a ">" too. Stored in
# guestbook.html, Apache's mod_include runs it when .html files are
# SSI-parsed. no_comments() echoes the filtered fields back:
# City: <input type=text name="city" value="$FORM{'city'}" size=15>, …
#
# Better than the reference check (presence of any guestbook.pl, so the NMS
# replacement — which HTML-escapes every field — was reported too): the feed
# POSTs only city= (no comments, so no entry is ever written) carrying
# N<a><!--<b>-->K<c><!--#echo var="V<d>"
# and requires the no_comments page to echo exactly
# N<a>K<c><!--#echo var="V<d>"
# i.e. the complete comment removed and the unclosed SSI directive kept —
# guestbook.pl 2.3.1's filter in action. A raw reflector keeps the
# "<!--<b>-->" part, an escaping script turns "<" into "<": neither matches.
# Not proven: that the server SSI-parses guestbook.html (non-default config);
# exploiting it would mean writing a public entry, so the feed stops at QoD 75.
uid: 2a03e6fc-9297-46d0-93b4-573af6b0374a
name: "Matt Wright Guestbook guestbook.pl SSI Injection (CVE-1999-1053)"
description: |
Detects guestbook.pl from Matt Wright's Guestbook 2.3.1 and earlier
(CVE-1999-1053). The script removes server-side include (SSI) commands from
visitor input only when they form a complete "<!-- ... -->" comment, so an
unclosed directive such as <!--#exec cmd="..." is written as is into the
guestbook page, where a web server that parses SSI in .html files runs the
command. Under the web root, /cgi-bin, /scripts, /cgi-local, /guestbook and
/cgi-bin/guestbook, the feed sends guestbook.pl (and guestbook.cgi, the name
hosts requiring .cgi use) one POST that holds only a city field (no comment,
so the script adds no guestbook entry, only an error line to its log, and
answers with its "Your Comments appear to be blank" form) made of per-run
random text, a complete
comment and an unclosed, harmless <!--#echo directive. It reports the script
when the returned form shows the city with the complete comment removed and
the unclosed directive kept, which is the vulnerable filter at work: a page
that merely echoes its input, or that HTML-escapes it, does not match.
Whether the server actually runs SSI in the guestbook page is not tested.
cves: [CVE-1999-1053]
cvss: 7.5
severity: high
category: rce
confidence_base: 0.30
tags: [matt-wright-guestbook, guestbook, cgi, perl, ssi, ssi-injection, rce, unauthenticated, intrusive]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-1999-1053"
- "http://www.securityfocus.com/bid/776"
- "http://www.securityfocus.com/archive/1/33674"
- "https://www.rapid7.com/db/modules/exploit/unix/webapp/guestbook_ssi_exec/"
steps:
# a, c: 7 digits; b, d: 6 digits. The expected echo is built here so the
# match compares one literal string.
- id: gen-tokens
action: script
code: |
let a = rand_int(1000000, 9999999);
let b = rand_int(100000, 999999);
let c = rand_int(1000000, 9999999);
let d = rand_int(100000, 999999);
#{ a: a, b: b, c: c, d: d,
expect: "N" + a + "K" + c + "<!--#echo var=\"V" + d + "\"" }
store_as: ov
# ── Per location: this step and every following one ──
# Pre-initialised so a failed request leaves no undefined variable behind.
- id: init
action: set_var
var_name: gb
var_value: {status: 0, body: ""}
loop:
over:
- "/guestbook.pl"
- "/cgi-bin/guestbook.pl"
- "/scripts/guestbook.pl"
- "/cgi-local/guestbook.pl"
- "/guestbook/guestbook.pl"
- "/cgi-bin/guestbook/guestbook.pl"
- "/cgi-bin/guestbook.cgi"
- "/guestbook/guestbook.cgi"
var: url
# city= only: no comments field, so guestbook.pl exits in no_comments()
# before opening guestbook.html (it appends one "ERR: No Comments" line
# to its guestlog.html when logging is on, as any plain GET does).
- id: post-city
action: http_request
method: POST
path: "{{url}}"
port: "{{port}}"
headers:
Content-Type: "application/x-www-form-urlencoded"
body: "city=N{{ov.a}}%3C%21--{{ov.b}}--%3EK{{ov.c}}%3C%21--%23echo%20var%3D%22V{{ov.d}}%22"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
store_as: gb
- id: judge
action: script
store_as: verdict
code: |
let b = if type_of(gb.body) == "string" { gb.body } else { "" };
if gb.status == 200
&& b.contains("Your Comments appear to be blank")
&& b.contains("name=\"city\" value=\"" + ov.expect)
&& !b.contains("<!--" + ov.b + "-->") {
"POST " + url + " city=N" + ov.a + "<!--" + ov.b + "-->K" + ov.c
+ "<!--#echo var=\"V" + ov.d + "\": the no_comments form echoed the city as "
+ ov.expect + " (complete comment removed, unclosed SSI directive kept)"
} else {
""
}
- id: report
action: match
source: verdict
pattern: "^POST "
on_match:
finding:
title: "Matt Wright Guestbook guestbook.pl SSI injection"
description: "guestbook.pl removes only complete <!-- ... --> comments from visitor input, so an unclosed server-side include directive such as <!--#exec cmd=\"...\" is stored in the guestbook page and runs when the web server parses SSI in it."
remediation: "Remove Matt Wright's guestbook.pl (no fixed release exists) and replace it with a maintained guestbook such as the NMS guestbook, which HTML-escapes every field; disable server-side includes, or at least exec, for the guestbook page."
confidence_delta: 0.55
qod: 75
evidence: "{{verdict}}"
stop: true