mailing list archives
AlienForm2 CGI script: arbitrary file read/write
From: Nick Cleaton <nick () cleaton net>
Date: Mon, 10 Jun 2002 22:18:53 +0100
Vulnerable: AlienForm2 revision 1.5
Category: Perl/CGI coding errors
Impact: Subject to file permissions, an attacker can read any
file on the server, append arbitrary data to any
existing file or write arbitrary data to new files.
Date: 10th June 2002
Vendor: Jon Hedley
Vendor Status: Notified 24th April 2002
Vendor Fix: None available
AlienForm2 by Jon Hedley is a template driven form processing Perl
CGI script. It is normally installed as af.cgi or alienform.cgi.
Template files on the server are used to configure the format of the
output document, the name of a log file and the format of the data to
append to the log file.
AlienForm2 is published under a licence that does not allow me to
reproduce parts of it here without permission, which I have been
unable to obtain. This advisory is best read in conjunction with a
copy of af.cgi.
The paths to the template files come from CGI inputs, and a flaw in
the code that cleans up those inputs allows any file on the server to
be used as a template file. The cleanup code replaces bad characters
and constructs with the empty string, and the input string ".|./" is
transformed by the cleanup code to "../".
The path cleanup code can be found on lines 185, 186, 197 and 198 of
The name of a CGI input in square brackets in a template is replaced
with the value of that input. The regular expression which performs
the replacement is not resilient to regular expression metacharacters
in the name of a CGI input, allowing an attacker to take full control
of the contents of a template after CGI input substitution.
The CGI input substitution code can be found on line 246 of af.cgi.
On lines 185 and 197, change  to [_]
On lines 186 and 198, change // to /_/
On lines 246 and 248, change $key to \Q$key\E
Arbitrary file disclosure:
This proof of concept exploit appends the text "hello there" to the
file /tmp/foo on the web server. It requires the existence of the
file /tmp/passwd, consisting of just the three lines:
This exploit can be readily adapted to use any other file of two or
more lines in place of /tmp/passwd, and the file disclosure
vulnerability could be used to find a suitable file. That process
could be automated.
nick () cleaton net
- AlienForm2 CGI script: arbitrary file read/write Nick Cleaton (Jun 10)