Bugtraq mailing list archives

Max's Guestbook (XSS) Remote Vulnerability


From: 08253 () maurickcollege nl
Date: 10 Dec 2008 20:29:05 -0000

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 
%% 
%% Discovered by: GTADarkDude
%% Disconvered on: 10 December 2008
%% Name: Max's Guestbook
%% Version: 1.0
%% URL: http://www.phpf1.com/product/php-guestbook-script.html
%% URL2: http://www.hotscripts.com/Detailed/78571.html
%% Google Search: intitle:"Max's Guestbook" powered-by-PHP-F1
%% 
%% 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


*** File ***

maxGuestbook.class


*** Vulnerable Code ***

function insertMessage(){
   $name   = isset($_POST['name']) ? $_POST['name'] : 'Anonymous';
   $email  = isset($_POST['email']) ? $_POST['email'] : '';
   $submitDate  = date($this->dateFormat);
   $content = isset($_POST['message']) ? $_POST['message'] : '';
   //(...)
   $f = fopen($this->messageDir.DIRECTORY_SEPARATOR.$filename.".txt","w+");         
   fwrite($f,$name."\n");
   fwrite($f,$email."\n");
   fwrite($f,$submitDate."\n");
   fwrite($f,$content."\n");
   fclose($f);
}

*** Exploit ***

$_POST['name'], $_POST['email'] AND $_POST['message'] are each not filtered whatsoever. 
Not when inserted [insertMessage()], nor when displayed [displayGuestbook($page)] -> XSS!

POST DATA: name=<script>while(1) alert(1337)</script>; message=qwertyuiop


*** Solution ***

Easy, simply filter all the $_POST and $_GET variables, for example by using htmlentities($var,ENT_QUOTES)


Current thread: