Doing that only removes the symptom of the problem. Your security check software has probably identified that you're letting the user pass a path to a file. This is often a good way to expose files on your site which contain non-public information (just change the URL to a different file... guessing and checking is ok). A better solution would be to secure your code so that it doesn't pass a forward slash (that's what %2F is) and the ".php" part and ensuring that the value of src is adjusted server-side after being validated as not trying to access unwanted files.
To give more assistance with doing this would require a look at the code. It may not be an quick solution if a number of files need to be modified, but it will make your site more secure.
EDIT: Code added:
PHP Code:
<?php //Strip garbage from front and end. $_GET['src'] = substr($_GET['src'],1,-4);
//Remove non-alphanumeric characters and non-dashes. $_GET['src'] = preg_replace('/[^a-z\-0-9]/i','',$_GET['src']);
//Now ensure that $_GET['src'] contains a safe file if (!file_exists('/'.$_GET['src'].'.php') || is_dir('/'.$_GET['src'].'.php')) { //File does not appear where expected, so erase variable's value. $_GET['src'] = ''; } ?>
The code above will sanitize the variable, but not get rid of your security scan error. For that, you'd start on my remove non-alpha after applying the changes to URLs throughout the system.
Last edited by JeremyMiller; 07-03-2009 at 02:20 PM..
|