Clarification on How Session Fixation Prevention Works #48458
-
This is a low-level framework question prompted by the following documentation:
https://laravel.com/docs/10.x/session#regenerating-the-session-id Looking at Fortify and Breeze source, we see This brings me to the following questions: 1. Shouldn't the session ID be regenerated before login?My limited understanding of a session fixation attack is it relies on an attacker knowing their victim's session ID. If we just logged in a user with that known session ID, isn't regeneration after the fact (and notably not destroying the old session with 2.
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
After some debugging, I've largely answered my own question:
|
Beta Was this translation helpful? Give feedback.
After some debugging, I've largely answered my own question:
\session()->regenerate()
is called doesn't matter. (You can test this by copying a Laravel session cookie into an Incognito window, writing to the session in the other window, then calling regenerate. Refreshing the Incognito window doesn't expose any newly-written session details.)\session()->regenerate()
multiple times incurs only a small performance penalty on re-randomizing a session ID. Therefore, the fact that\auth()->login() && \session()->regen…