Jump to content



Photo

The Index.php Module

$_get

  • Please log in to reply
3 replies to this topic

#1 Necuima

Necuima

    Advanced Member

  • Members
  • PipPipPip
  • 255 posts
  • LocationSunshine Coast, Queensland, Australia

Posted 18 June 2017 - 7:23 PM

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
  • 0

#2 Necuima

Necuima

    Advanced Member

  • Members
  • PipPipPip
  • 255 posts
  • LocationSunshine Coast, Queensland, Australia

Posted 18 June 2017 - 7:44 PM

That regex should be /^[a-z\_]+$/

 

Oops


  • 0

#3 Larry

Larry

    Administrator/Writer

  • Administrators
  • 4796 posts
  • LocationState College, PA (USA)

Posted 21 June 2017 - 9:59 AM

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.)


  • 0

#4 Necuima

Necuima

    Advanced Member

  • Members
  • PipPipPip
  • 255 posts
  • LocationSunshine Coast, Queensland, Australia

Posted 22 June 2017 - 3:04 AM

Thanks for your thoughts, Larry.

 

They are always appreciated.

 

Cheers


  • 0





Also tagged with one or more of these keywords: $_get