fix: renew session on user login to prevent session fixation#300
Open
allamiro wants to merge 1 commit into
Open
fix: renew session on user login to prevent session fixation#300allamiro wants to merge 1 commit into
allamiro wants to merge 1 commit into
Conversation
actix-session recommends rotating the session on privilege changes. set_user_session now calls session.renew() before storing the user and csrf token.
36a056d to
faf401b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #277.
Problem
set_user_sessionstored the authenticated user in the pre-login session without rotating it — standard session-fixation hygiene (actix-session providesSession::renew()exactly for privilege changes).Change
session.renew()is called at the start ofset_user_session, so both the mask login path (/user_login) and the OIDC callback path get a fresh session key on successful authentication.Testing
cargo test: 9/9 pass in a rust:1.83 container.Summary by cubic
Rotate the session on authentication to prevent session fixation.
set_user_sessionnow callsSession::renew()(fromactix-session) before storing the user, so both/user_loginand the OIDC callback issue a fresh session ID.Written for commit 36a056d. Summary will update on new commits.