note 85036 added to language.oop5.patterns

From: Date: Tue, 12 Aug 2008 12:41:01 +0000
Subject: note 85036 added to language.oop5.patterns
Groups: php.notes 
Request: Send a blank email to php-notes+get-143391@lists.php.net to get a copy of this message
Tedmasterweb's point is a good one, though sanitizing inputs is often even more subtle than you would expect. For instance, his sanitizing solution would fail if the supplied driver name were "../../../../../../../../etc/passwd\0" (which, as you'll note, is null-byte-terminated). The underlying C-functions that run most modern POSIX-compliant and POSIX-based operating system filesystem operations will treat the ASCII null byte as a string termination character, and so will ignore the ".php" he appended to the path. Thus, this attack would still succeed. This attack is described in further detail here (the link is too long for the word wrapping, but it will still work): http://us3.php.net/manual/en/security.filesystem.php #security.filesystem.nullbytes In my own __autoload functions, I tend to provide a validating regex for class or interface names to only allow characters I know are safe (though this code might have to be adjusted once namespace support is fully functional in PHP). For anyone who prefers to attempt to remove unsafe characters instead, I suggest the following list at a minimum: period (for the ".." pseudo-directory), slash and backslash (for directory separators; both work on Windows systems), the explicit DIRECTORY_SEPARATOR constant, and the ASCII null byte (which can be typed in code as "\0"). Usage of the PHP functions escshellcmd or escshellarg might also be advisable, depending on how your code is written (particularly depending on whether it is executing a shell command or including a file). ---- Server IP: 64.71.164.2 Probable Submitter: 65.220.74.200 ---- Manual Page -- http://www.php.net/manual/en/language.oop5.patterns.php Edit -- https://master.php.net/note/edit/85036 Del: integrated -- https://master.php.net/note/delete/85036/integrated Del: useless -- https://master.php.net/note/delete/85036/useless Del: bad code -- https://master.php.net/note/delete/85036/bad+code Del: spam -- https://master.php.net/note/delete/85036/spam Del: non-english -- https://master.php.net/note/delete/85036/non-english Del: in docs -- https://master.php.net/note/delete/85036/in+docs Del: other reasons-- https://master.php.net/note/delete/85036 Reject -- https://master.php.net/note/reject/85036 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#143391) next »