Advisory: Professional PHP Tools Guestbook Multiple Vulnerabilities
Release Date: 2006/06/17
Last Modified: 2006/07/17
Author: Tamriel [tamriel at gmx dot net]
Application: Professional PHP Tools Guestbook
Risk: Medium
Vendor Status: contacted | no patch available
Vendor Site: www.php-tools.eu
Overview:
Quote from wwww.php-tools.eu
"Dieses einfache Gaestebuch kann auf jedem Webspace
mit PHP 5 und MySQL Unterstuetzung installiert
werden. Es sind Smilies ein BBCode integriert.
HTML ist aus Sicherheitsgruenden deaktiviert. Dem
Webmaster steht eine einfache Webadministration
zur Verfgung, mit der er alle Eintraege bequem
verwalten kann. Er ist auch in der Lage eine oder
mehrere IP Adressen fr das Gaestebuch zu sperren."
Details:
1) SQL Injection Vulnerability in class.php
(arround line 75-115)
...
$hidemail = $_POST['hidemail'];
...
mysql_query("INSERT INTO gbook ( name, mail, hidemail, datum, ip,
text ) VALUES ( '$name', '$mail', '$hidemail', '$date', '$ip', '$text' ) ");
...
Here the programer forgot something to validate.
In the complete script you can found this vulnerabilities so i
mention only one example here.
2) SQL Injection Vulnerabilities in class.php
(arround line 250 and arround line 260)
...
$name = $_POST['name'];
$mail = $_POST['mail'];
$ip = $_POST['ip'];;
$text = $_POST['text'];
mysql_query("UPDATE gbook SET name='$name', mail='$mail', ip='$ip', text='$text' WHERE id='$entry'");
...
mysql_query("DELETE FROM gbook WHERE id='$entry'");
include(config('tpl_dir').'/del.tpl');
...
As an admin you can insert enough SQL Code. Its not celver to
trust every person who has admin access.
Version note:
I havent found some information about the actual version of this script, so take a look on the
md5 hashes of my proofed files:
9f3f1e28f6a449b51bda7f57d7cfbb48 class.php
c27de7365648eb554c3a4cab83895015 delcookie.php
faca302875997b345ab4912465df06e4 setcookie.php
Note:
1) You can found some other insecure handlings, like the administration login in setcookie.php
...
include('config.php');
if ( md5(config('admin_pass')) == $_GET['pass'] )
{
setcookie('gbook', $_GET['pass'], time()+2419200);
}
...
Attackers can here easy brute the password.
2) delcookie.php
...
setcookie('gbook', $_COOKIE['gbook'], time()-2419200);
...
The logout handler does not overwrites the existence cookie, so attackers can
read out (for example on shared computer systems) the admin's password hash after logout.
Solution:
Use the php's mysql_real_escape_string, to call MySQL's library function mysql_real_escape_string,
which prepends backslashes to the following characters: x00, n, r, , ', " and x1a.
In the delcoookie.php replace "setcookie('gbook', $_COOKIE['gbook'], time()-2419200);" with
"setcookie('gbook', '', time()-2419200);".