Necuima Posted June 19, 2017 Share Posted June 19, 2017 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 More sharing options...
Necuima Posted June 19, 2017 Author Share Posted June 19, 2017 That regex should be /^[a-z\_]+$/ Oops Link to comment Share on other sites More sharing options...
Larry Posted June 21, 2017 Share Posted June 21, 2017 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 More sharing options...
Necuima Posted June 22, 2017 Author Share Posted June 22, 2017 Thanks for your thoughts, Larry. They are always appreciated. Cheers Link to comment Share on other sites More sharing options...
Recommended Posts