security - Where can Null Byte Injection affect my PHP web app in a realistic setting? -
i've read php section on http://projects.webappsec.org/null-byte-injection.
the example provides pretty dumb - mean, why ever want include file based on outside param without checking first (for directory traversal attacks, one)?
so, if following standard php security practices, such as
- encoding user entered data on display
- validating user entered stuff works files
- preventing crsf
- not running uploads via executes php
- etc
can provide real life example or common mistake of php developers problem can occur?
thanks
upate
i'm trying make break, , have tried.
// $filename public $filename = "some_file\0_that_is_bad.jpg"; $ext = pathinfo($filename, pathinfo_extension); var_dump($filename, $ext);
which outputs
string(26) "some_file�_that_is_bad.jpg" string(3) "jpg"
i believe part of fun null byte injection simple validation may not enough catch them
e.g. string "password.txt\0blah.jpg" ends ".jpg" far scripting language concerned .. when passed c based function ( such many system functions) gets truncated "password.txt"
this means simple check may not safe. (this pseudocode, not php)
if ( filename.endswith(".jpg") ) { some_c_function(filename); }
instead may have do
filename = break_at_null(filename); if ( filename.endswith(".jpg") ) { some_c_function(filename); }
now doesn't matter c function .. examples in cited article may have need file reading functions, database accesses, system calls, etc.
Comments
Post a Comment