note 48472 added to function.include

From: Date: Sat, 25 Dec 2004 11:27:54 +0000
Subject: note 48472 added to function.include
Groups: php.notes 
Request: Send a blank email to php-notes+get-82287@lists.php.net to get a copy of this message
I've found a security leak in php. Look at http://www.hardened-php.net/documentation.php paragraph 2.4.3 for more information. Here is some script code to fix this leak. <?php // $_GET["page"] is the GET query var for the requesting // file on the webserver. if (!preg_match("/[\.\\/%00:]/", $_GET["page"]) && !empty($_GET["page"])) { include("/path/" . $_GET["page"] . ".inc.php"); include_once("/path/" . $_GET["page"] . ".inc.php"); require("/path/" . $_GET["page"] . ".inc.php"); require_once("/path/" . $_GET["page"] . ".inc.php"); } else { die("Hacking attempt."); } ?> If you don't check the GET query var for this, hackers can use this var in the query to include other php script files. ---- Manual Page -- http://www.php.net/manual/en/function.include.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+48472 Delete -- http://master.php.net/manage/user-notes.php?action=delete+48472&report=yes Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+48472&report=yes&reason=bad+code Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+48472&report=yes&reason=spam Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+48472&report=yes&reason=useless+example Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+48472&report=yes&reason=contains+commercial+links Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+48472&report=yes&reason=useless+note Reject -- http://master.php.net/manage/user-notes.php?action=reject+48472&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#82287) next »