-
-
Notifications
You must be signed in to change notification settings - Fork 366
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
Security Fix for Session Fixation - huntr.dev #1112
Changes from all commits
57cd2b7
2b93f30
8508a8c
5c379e5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1182,13 +1182,19 @@ public function setPassword(Request $request, Response $response, $args) | |
/** @var \UserFrosting\Sprinkle\Account\Authenticate\Authenticator $authenticator */ | ||
$authenticator = $this->ci->authenticator; | ||
|
||
// Log out any existing user, and create a new session | ||
if ($authenticator->check()) { | ||
$authenticator->logout(); | ||
// Remove persistent sessions across all browsers/devices, and create a new session | ||
$user = $passwordReset->user; | ||
|
||
// Make sure logout will have a valid user | ||
if (!$authenticator->check()) { | ||
$authenticator->login($user); | ||
} | ||
|
||
// Remove persistent sessions | ||
$authenticator->logout(true); | ||
|
||
// Auto-login the user (without "remember me") | ||
$user = $passwordReset->user; | ||
// Create a new session | ||
$authenticator->login($user); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This code is not optimized : Login-in the user to log him out again, to log him in again is not an optimized process. Note with UF5, the behavior of this page has changed. First, the page is guarded by the |
||
|
||
$ms->addMessageTranslated('success', 'WELCOME', $user->export()); | ||
|
@@ -1301,6 +1307,20 @@ public function settings(Request $request, Response $response, $args) | |
|
||
$currentUser->save(); | ||
|
||
// If user changed his password, remove persistent sessions across all browsers/devices, and create a new session | ||
if (isset($data['password'])) { | ||
|
||
/** @var \UserFrosting\Sprinkle\Account\Authenticate\Authenticator $authenticator */ | ||
$authenticator = $this->ci->authenticator; | ||
|
||
// Keep user to re-login after persistent session cleanup | ||
$user = $currentUser; | ||
$authenticator->logout(true); | ||
|
||
// Auto-login the user (without "remember me") | ||
$authenticator->login($user); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. Login-in the user to log him out again, to log him in again is not an optimized process. |
||
} | ||
|
||
// Create activity record | ||
$this->ci->userActivityLogger->info("User {$currentUser->user_name} updated their account settings.", [ | ||
'type' => 'update_account_settings', | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
N.B.: The sign_in_attempt is null on purpose, as it's enabled only on production environment.