Jump to content

What are the security vulnerabilities in the following script?


Gingechilla

Recommended Posts

I'm attempting to clean out all unwanted input from user posted data. The user can put anything in the input box but when it goes through to my php page I filter through it with the following:

 

function cleanxss($input)
{
	/// Prevents XXS Attacks www.itshacked.com
	$search = array(
					'@<script[^>]*?>.*?</script>@si',   // Strip out javascript
					'@<[\/\!]*?[^<>]*?>@si',            // Strip out HTML tags
					'@<style[^>]*?>.*?</style>@siU',    // Strip style tags properly
					'@<![\s\S]*?--[ \t\n\r]*>@'         // Strip multi-line comments
					);

	$inputx = preg_replace($search, '', $input);
	$inputx = trim($inputx);
	if(get_magic_quotes_gpc())
	{
		$inputx = stripslashes($inputx);
	}
	$input = htmlspecialchars($input);
	/// MYSQL USE ONLY: $inputx = mysql_real_escape_string($inputx);
	return $inputx;

}		


//apply the function to an array of user submitted data...
///$_POST = array_map('clean', $_POST);

//or individually like...
$message = cleanxss($_POST['data']);

 

I've pasted all the data from http://ha.ckers.org/xss.html into the form and it results in no vulnerabilities. Is this right?

 

Link to comment
Share on other sites

Oh and the data from the form will be used between other elements and saved in a file for inclusion into the main file. So for example the data from the form might be between stylesheet tags ect.

 

Only thing I can think of would be importing a CSS file like so:

@import'http://ha.ckers.org/xss.css';

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.