[UNIX] PHP 4.x Session Spoofing
From: support@securiteam.comDate: 01/15/02
- Previous message: support@securiteam.com: "[NT] Internet Explorer SuperCookies P3P Bypass and Cookie Controls"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
From: support@securiteam.com To: list@securiteam.com Date: Tue, 15 Jan 2002 23:21:11 +0100 (CET)
The following security advisory is sent to the securiteam mailing list, and can be found at the SecuriTeam web site: http://www.securiteam.com
- - promotion
When was the last time you checked your server's security?
How about a monthly report?
http://www.AutomatedScanning.com - Know that you're safe.
- - - - - - - - -
PHP 4.x Session Spoofing
------------------------------------------------------------------------
SUMMARY
The default configuration of PHP 4.x does not store its SessionID in a
secure environment but rather in the /tmp directory. This would allow an
attacker with access to the /tmp directory to spoof existing SessionIDs,
thus gaining privileged access to other people's accounts.
DETAILS
Background:
What are sessions:
A session ID is required to identify people. It is passed over to the
browser and then is either part of the url or is stored as a cookie. With
every request, the browser also sends this ID over to the server that
makes is possible to see which requests came from which user. Using the IP
is not reliable for identification, because many people can come over a
proxy and have the same IP.
Sessions are now also used for authentication purposes. Because there is
no reliable way of keeping a permanent connection to the user, a login
procedure is simulated using sessions. As long as the user is "logged in",
the session-ID replaces any user/password combination. Because session-IDs
are difficult to predict (that is why they are so terribly long), they are
considered secure.
Session support in PHP:
Since PHP4, there is a native support for sessions, which was derived from
the PHPLib. Instead of using a SQL backend to store these IDs, they chose
to store them as files in /tmp.
Every session is stored in a file like
sess_g35g5g54gg45wg85
Where "g35g5g54gg45wg85" is the actual SessionID. Someone could now easily
spoof these sessions, because he now knows the IDs. He would even be able
to read the contents of these files, because PHP very often runs as module
(i.e. every executed PHP script inherits the user permissions of apache),
thus you only have to write a PHP script which reads out these files.
Workaround:
It is suggested that you create a directory called
mkdir /tmp/php_sessions/
You have to adjust the path in php.ini for this. Then chown it to apache
chown www-data: php_sessions
And make sure to take away "r". r means "listing a directory". Apache only
has to be able to "go into it" = x = 1, and "write" = w = 2. 1 + 2 = 3, so
chmod 300 php_sessions
Now, although apache is able to create and read sessions, it is not
anymore possible to list the directory.
The PHP-developers are informed about this issue, and there is a
discussion about various security issues in PHP-Dev.
ADDITIONAL INFORMATION
The information has been provided by Michel Lang and
<mailto:daniel@lorch.cc> Daniel Lorch.
========================================
This bulletin is sent to members of the SecuriTeam mailing list.
To unsubscribe from the list, send mail with an empty subject line and body to: list-unsubscribe@securiteam.com
In order to subscribe to the mailing list, simply forward this email to: list-subscribe@securiteam.com
====================
====================
DISCLAIMER:
The information in this bulletin is provided "AS IS" without warranty of any kind.
In no event shall we be liable for any damages whatsoever including direct, indirect, incidental, consequential, loss of business profits or special damages.
- Previous message: support@securiteam.com: "[NT] Internet Explorer SuperCookies P3P Bypass and Cookie Controls"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
- Re: register_globals - turning on
... >>an Apache module. ... >So basically using the .htaccess is a safe
way of enabling sessions to ... >>Stick this file on the beginning of every PHP
page processed. ... >>In the case of session data, the web server needs to be able
... (comp.lang.php) - deadline for Usenix Security extended to Friday, Feb. 1st
... Technical Sessions: August 7-9, 2002 ... interested in the latest advances in
security of computer systems. ... This symposium will last for four and a half days.
... sessions including refereed papers, invited talks, works-in-progress, ... (comp.security.misc) - deadline for Usenix Security extended to Friday, Feb. 1st
... Technical Sessions: August 7-9, 2002 ... interested in the latest advances in
security of computer systems. ... This symposium will last for four and a half days.
... sessions including refereed papers, invited talks, works-in-progress, ... (comp.security.unix) - Re: Weirdness
... >> as I am getting parse errors. ... Well, oddly enough, I just started
getting issues with sessions ... Apache owns and has rwe on it. ... PHP
is running as an Apache module, ... (php.general) - Re: [PHP] Keeping sessions
... I know this is a PHP and not an Apache list but maybe someone is doing this
with web hosting... ... That doesn't change the fact that Apache does not get involved in sessions.
... Users's session must be persistent in all cases: web server down, user jumpig between backend
web servers, etc ... (php.general)