From:             pornel at despammed dot com
Operating system: All? Win32 tested
PHP version:      5CVS-2005-07-20 (dev)
PHP Bug Type:     *Directory/Filesystem functions
Bug description:  NUL allowed in file paths

Description:
------------
NUL character (C string terminator) is allowed in file paths passed to OS
functions, which causes unexpected truncation of string.

This is a security risk for popular, sloppy code like:
 include($_GET['page'].'.i-feel-safe.php');
because ?page=/etc/passwd%00 circumvents such "protection".

IMHO PHP should throw an error if PHP string can't be safely converted to
C string.


Reproduce code:
---------------
<?php
fopen(urldecode("test%00.html"),"r");

Expected result:
----------------
Error: illegal path

Actual result:
--------------
Warning: fopen(test) [function.fopen]: failed to open stream: No such file
or directory in c:\www\test.php5 on line 2

-- 
Edit bug report at http://bugs.php.net/?id=33784&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=33784&r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=33784&r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=33784&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=33784&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=33784&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=33784&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=33784&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=33784&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=33784&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=33784&r=notwrong
Not enough info:             
http://bugs.php.net/fix.php?id=33784&r=notenoughinfo
Submitted twice:             
http://bugs.php.net/fix.php?id=33784&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=33784&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=33784&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=33784&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=33784&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=33784&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=33784&r=float
No Zend Extensions:          http://bugs.php.net/fix.php?id=33784&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=33784&r=mysqlcfg

Reply via email to