Skip to content
This repository was archived by the owner on Nov 3, 2023. It is now read-only.

Commit 119a1b5

Browse files
committed
Invalidate the user sessions if a password changes (see CVE-2019-10641)
1 parent e4f0bad commit 119a1b5

File tree

5 files changed

+43
-0
lines changed

5 files changed

+43
-0
lines changed

system/docs/CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
Contao Open Source CMS changelog
22
================================
33

4+
Version 3.5.39 (2019-04-XX)
5+
---------------------------
6+
7+
### Fixed
8+
Invalidate the user sessions if a password changes (see CVE-2019-10641).
9+
10+
411
Version 3.5.38 (2018-12-21)
512
---------------------------
613

system/modules/core/dca/tl_member.php

+4
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,10 @@ public function setNewPassword($strPassword, $user)
608608
}
609609
}
610610

611+
// Invalidate the user sessions if the password changes
612+
$this->Database->prepare("DELETE FROM tl_session WHERE name='FE_USER_AUTH' AND pid=? AND sessionID!=?")
613+
->execute($user->id, session_id());
614+
611615
return $strPassword;
612616
}
613617

system/modules/core/dca/tl_user.php

+24
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,10 @@
242242
'exclude' => true,
243243
'inputType' => 'password',
244244
'eval' => array('mandatory'=>true, 'preserveTags'=>true, 'minlength'=>Config::get('minPasswordLength')),
245+
'save_callback' => array
246+
(
247+
array('tl_user', 'invalidateSessions')
248+
),
245249
'sql' => "varchar(128) NOT NULL default ''"
246250
),
247251
'pwChange' => array
@@ -732,6 +736,26 @@ public function checkAdminStatus($varValue, DataContainer $dc)
732736
}
733737

734738

739+
/**
740+
* Invalidate the user sessions if the password changes
741+
*
742+
* The password widget only triggers the save_callback if the password has actually
743+
* changed, therefore we do not need to check the active record here.
744+
*
745+
* @param mixed $varValue
746+
* @param DataContainer $dc
747+
*
748+
* @return mixed
749+
*/
750+
public function invalidateSessions($varValue, DataContainer $dc)
751+
{
752+
$this->Database->prepare("DELETE FROM tl_session WHERE name='BE_USER_AUTH' AND pid=? AND sessionID!=?")
753+
->execute($dc->id, session_id());
754+
755+
return $varValue;
756+
}
757+
758+
735759
/**
736760
* Prevent administrators from disabling their own account
737761
*

system/modules/core/modules/ModuleChangePassword.php

+4
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,10 @@ protected function compile()
186186
}
187187
}
188188

189+
// Invalidate the user sessions if the password changes
190+
$this->Database->prepare("DELETE FROM tl_session WHERE name='FE_USER_AUTH' AND pid=? AND sessionID!=?")
191+
->execute($objMember->id, session_id());
192+
189193
// Check whether there is a jumpTo page
190194
if (($objJumpTo = $this->objModel->getRelated('jumpTo')) !== null)
191195
{

system/modules/core/modules/ModulePassword.php

+4
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,10 @@ protected function setNewPassword()
254254
}
255255
}
256256

257+
// Invalidate the user sessions if the password changes
258+
$this->Database->prepare("DELETE FROM tl_session WHERE name='FE_USER_AUTH' AND pid=? AND sessionID!=?")
259+
->execute($objMember->id, session_id());
260+
257261
// Redirect to the jumpTo page
258262
if (($objTarget = $this->objModel->getRelated('reg_jumpTo')) !== null)
259263
{

0 commit comments

Comments
 (0)