Security Issue in PHP – include_once

There is an interesting hack in an account of our client on our webhosting service. It is an online library system of our client which is written in PHP. One day, the system admin reported that the postfix died becaue of a lot of spam mails sending from the online library system. When I checked the log and saw the log like the following:

1171167204.920 534343 TCP_MISS/200 63463 POST

When I go the the php file and know how the cracker crack the system. The problem is about php.

$pagename =$_GET['Name'];
<?php include_once("{$pagename}");?>

The problem is that the $pagename does not have any gruad to check the value that got by $_Get[‘name’].

The function of include_once is allow to include the source from outside,

So, when cracker use a ‘’ as name, and use the url, ,

The $pagename will become and the indule_once function will execute as:

<?php include_once("");?>

That will executes the php script in and will be an ARGV for that php script. This will be a security hole of the system.

So that for security, if it is necessary to use include_once, include function in dynamic,
it has to have a check to see it is from the place you want before.

Leave a Reply