OWASP / PHP-ESAPI

Migrated from code.google.com to a more active public repository.
Other
65 stars 26 forks source link

SafeFile throws wrong Exception on nul byte injection #7

Open renaatdemuynck opened 9 years ago

renaatdemuynck commented 9 years ago

SafeFileTest::testURILocal fails because SafeFile throws EnterpriseSecurityException instead of ValidationException. This is because in more recent versions of PHP, when you inject a nul byte in the path, the class SplFileObject throws RuntimeException with message _'SplFileObject::_construct() expects parameter 1 to be a valid path, string given'. In older versions of PHP a ValidationException would have been thrown. This should be fixed by running the sanity checks before the SplFileObject::__constructor is called.

Tested on:

renaatdemuynck commented 9 years ago

UPDATE Apparently PHP fixed most of the security issues with SplFileObject. Further testing reveils the following:

Solution: Do we still really need SafeFile? Should it be marked deprecated? Anyway, if we want SafeFile to throw ValidationExceptions, the sanity checks should be performed before the SplFileObject::__constructor is called.