I noticed today that in my session files for a site, there are a few files with file names that are significantly smaller than the rest, example:
Standard Session File:
sess_0020cc255681808f78c08b67cd88cbcea13f45ee7629754ed82ccb8b010cf83d2b353b7136847f2876d99f3297a5def5bcc62b433d6d56d7f1b301f82c833aad
(5 + 128 character file length)
Exceptional Session File:
sess_629aca24e094f17d02b3d105ebe9e5d4
(5 + 32 character file length)
This site is very busy and has a Lot of traffic (~22k visitors pcm), viewing the session folder there are ~1% (actually 0.92%) of these very short named session files.
I have in the past read up a lot on sessions before implementing this site redesign last year (2015) and from that, currently have in my php.ini
:
session.cookie_httponly=1
session.use_only_cookies=1
session.cookie_secure=1
session.entropy_file=/dev/urandom
session.hash_function=whirlpool
session.session.use_trans_sid=0
session.entropy_length=32
EDIT (additionals):
session.hash_bits_per_character = 4
session.sid_length
is undefined (undefinable) as this build is using PHP 5.6.2
Which, as far as I know, should be generally fine. I have read very few other topics about how to ensure minimum file length, although I have read various thing about using session.entropy_length
but this doesn't seem to obviously apply to this issue.
The entropy_length value is the only one I'm not certain of its use and need.
My Questions
- What causes 1% of sessions to be only 5 + 32 characters long?
- How do I set it so that all sessions are the same length (5 + 128 chrs)
I realise the below question I can try it and see as it causes no harm, but if the above solution is the intended use for session.entropy_length
, that would be useful to know. There seems little literature around about what entropy_length is actually -practically- for.
Will increasing the session entropy length value improve this?[NO]
I think there can currently be a small potential issue with session name collision, and it looks frankly wrong how so many session files are so wonderfully long but a notable minority are relatively tiny.
Updates
From comments there are some details that it may be worth me summarising here:
- The issue is not with my browser(!!)
- This is using PHP Version 5.6.2
- LAMP stack on a [single] WHM server.
- If PHP-cli is run it could/would only be run by the server hosts, although I really doubt they're running it. I know them well and am a decent client so....
- I have checked and confirmed that the website
htaccess
files are not making any changes to any aspect of PHP - The server runs with very few error logs (I have 14 errors from the last week, from 9k visits, errors all 404s from robot scrapers trying to hack into Wordpress [the site is not wordpress].)
- PHP is run through suPHP (version unknown at present), I'm also looking at updating suphp but I doubt this would directly relate to this issue.
- From Ryan Vincents suggestion I will setup a notification when a shorter than 128chr session is made (and hopefully from which address)
- The session file storage folder is defined in PHP.ini and so if an outside PHP.ini is used then I'd expect sessions to appear in other folders such as
/temp
.