PHPT for bug 39863
| From: | Andrew van der Stock | Date: | Wed, 12 May 2010 11:40:04 +0000 |
| Subject: | PHPT for bug 39863 | ||
| Groups: | php.qa | ||
| Request: | Send a blank email to php-qa+get-65545@lists.php.net to get a copy of this message | ||
Hi there,
I've included my first ever phpt. Can someone please look over it and check that it meets your
quality guidelines for a unit test? Once that's done, it probably should be included in the
mainline test suite once someone from your security team says yes to bug 39863.
The issue it tests is fairly serious - file_exists() amongst others can be fooled into saying a file
exists, when in fact it doesn't - with a very simple and well known null byte injection. This
test demonstrates the issue.
I've tested the underlying test on CentOS / my hand rolled PHP 5.2.11 and MacOS X /
Apple's PHP 5.3.1 and both fail this test.
This issue should also be tested on non-Unix platforms, such as Windows. But I don't know how
phpt's could test for say c:\boot.ini or another well known file.
If I was fixing the bug, I'd canonicalize the value and positively validate the filename to
only include acceptable characters for my OS's filenames. If the filename fails
canonicalization or validation, returning false is more than acceptable for file_exists(), but other
similarly afflicted file functions should be tested and their return result set according to the
function's capabilities.
thanks,
Andrew