note 89163 deleted from function.exit by danbrown
| From: | danbrown@php.net | Date: | Tue, 24 Feb 2009 20:46:42 +0000 |
| Subject: | note 89163 deleted from function.exit by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-151082@lists.php.net to get a copy of this message | ||
Note Submitter: jbNULLezorg at NULLgmail dot com
----
To: rich dot lovely at klikzltd dot co dot uk,
You may want to look at
Filesystem Security > Null bytes related issues > Example #1 Script vulnerable to null bytes.
Null bytes related issues
As PHP uses the underlying C functions for filesystem related operations, it may handle null bytes
in a quite unexpected way. As null bytes denote the end of a string in C, strings containing them
won't be considered entirely but rather only until a null byte occurs. The following example
shows a vulnerable code that demonstrates this problem:
<?php
$file = $_GET['file']; // "../../etc/passwd\0"
if (file_exists('/home/wwwrun/'.$file.'.php')) {
// file_exists will return true as the file /home/wwwrun/../../etc/passwd exists
include '/home/wwwrun/'.$file.'.php';
// the file /etc/passwd will be included
}
?>