note 48415 added to function.session-name
| From: | slave at codegrunt dot com | Date: | Wed, 22 Dec 2004 22:03:36 +0000 |
| Subject: | note 48415 added to function.session-name | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-82188@lists.php.net to get a copy of this message | ||
One gotcha I have noticed with session_name is that it will trigger a WARNING level error if the
cookie or GET/POST variable value has something other than alphanumeric characters in it. If your
site displays warnings and uses PHP sessions this may be a way to enumerate at least some of your
scripts:
http://example.com/foo.php?session_name_here=(bad)
Warning: session_start(): The session id contains invalid characters, valid characters are only a-z,
A-Z and 0-9 in /some/path/foo.php on line 666
I did not see anything in the docs suggesting that one had to sanitize the PHP session ID values
before opening the session but that appears to be the case.
Unfortunately session_name() always returns true so you have to actually get to the point of
assigning variables values before you know whether you have been passed bad session data (as far as
I can see). After the error has been generated in other words.
Cheers
----
Manual Page -- http://www.php.net/manual/en/function.session-name.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+48415
Delete -- http://master.php.net/manage/user-notes.php?action=delete+48415&report=yes
Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+48415&report=yes&reason=bad+code
Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+48415&report=yes&reason=spam
Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+48415&report=yes&reason=useless+example
Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+48415&report=yes&reason=contains+commercial+links
Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+48415&report=yes&reason=useless+note
Reject -- http://master.php.net/manage/user-notes.php?action=reject+48415&report=yes
Search -- http://master.php.net/manage/user-notes.php