Jump to content
Larry Ullman's Book Forums

Recommended Posts

Hi Larry,

 

I recently came across an attempted hack via the index.php module (pages 57...).

 

I checked the logs and they added additional stuff to the $_GET['p'] data.

 

In case it is of interest, I think the code I have added should avoid that in the future:

 

if (isset($_GET['p']))
	{
     	$p = $_GET['p'];
	// if there's any characters in there that shouldn't be, exit
	if (!preg_match("/^[a-z\_]/", $p))
	        {	
			exit ("Invalid attempt to access this module");
		}
	}
else
    $p = NULL;
Can you suggest a better way?

 

Thanks, and Cheers

Link to comment
Share on other sites

That sounds good, however, I'm not sure it's necessary. The code as written, I believe, checks against static values and serves a default value if there's no match. So it doesn't matter what a user provides that doesn't match. 

 

But if you want to use the regex, that's fine, too, just make sure you keep it up to date as you add or change modules. (Or make sure your modules always fit within that definition.)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...