-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Zend Session would throw an exception "The session has already been started. The session id must be set first." upon receiving an invalid session ID #165
Comments
When trying to unit-test my fix, I realized that, as a workaround, one can simply call As a bonus, doing so prevents the creation of sessions with wrong session ID at the first place. |
Since explicitly sending an invalid For example, when using a Redis setup or any FIFO session storage. |
Fun fact, This logic doesn't do very much to help here, unfortunately, but it's nice to know. |
Another fun fact,
Long story short, if a website somehow ends up applying an empty string to |
wow you keep on finding interesting stuff! Seems like Zend_Session v1 has really serious issues 😅 |
Yes. But eh! At some point one has to consider other layers of technology to find solutions. For example, we are exploring AWS WAF with custom rules tailored towards |
In our situation the origin of the In regard to using a WAF, AWS has what they call a "Core rule set" which, among other things, targets "bad bots". Activating this set of rules would "mostly" prevent the situation described in this issue from happening. |
Another piece of wisdom I would like to share and add to this issue. There is a vulnerability called "session fixation" that is/was super easy to pull in PHP. An attacker sets the See,
There are multiple ways to mitigate this issue. To my knowledge, I'm not sure Zf1 does or can do it but nonetheless one can simply set resources.session.use_strict_mode = 1 So, long story short, the workaround that I proposed - #165 (comment) - is not a good idea since it seems to interfere with good session management. |
Long story short,
We monitored a lot of exceptions this morning on our website, all stating "The session has already been started. The session id must be set first."
There are a lot of different reasons why this message can happen.
Our logs indicated that the user ID values were in fact all attempting to break things up, with
PHPSESSID
cookie having values like:Thread.Sleep(4*1000);
C:/winnt/win.ini
${T(java.lang.System).properties}
Etc.
Upon analysis I stumbled on this old issue zendframework/zend-session#119 which helped me to reproduce the issue on my dev. env. locally with a simple
curl
command like suggested,curl -I 'http://your-local-website.com/' -H 'Cookie: PHPSESSID=_test_'
I then Xdebug-ed it to realize that Zend doesn't properly account for the situation when
session_id
is given a rejected ID. In that situation, theSID
constant is defined BUT its value is an empty string (at least, on PHP 7.0.33),The text was updated successfully, but these errors were encountered: