Skip to content

Commit

Permalink
Make sure to compare password with unsanitized password (matomo-org#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
tsteur committed Jan 28, 2019
1 parent 60adbbc commit 0cdfff7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions plugins/Login/Controller.php
Expand Up @@ -201,6 +201,9 @@ public function confirmPassword()
if (!empty($_POST)) {
$nonce = Common::getRequestVar('nonce', null, 'string', $_POST);
$password = Common::getRequestVar('password', null, 'string', $_POST);
if ($password) {
$password = Common::unsanitizeInputValue($password);
}
if (!Nonce::verifyNonce($nonceKey, $nonce)) {
$messageNoAccess = $this->getMessageExceptionNoAccess();
} elseif ($this->passwordVerify->isPasswordCorrect(Piwik::getCurrentUserLogin(), $password)) {
Expand Down
2 changes: 2 additions & 0 deletions plugins/UsersManager/API.php
Expand Up @@ -901,6 +901,8 @@ public function updateUser($userLogin, $password = false, $email = false, $alias
throw new Exception(Piwik::translate('UsersManager_ConfirmWithPassword'));
}

$passwordConfirmation = Common::unsanitizeInputValue($passwordConfirmation);

$loginCurrentUser = Piwik::getCurrentUserLogin();
if (!$this->passwordVerifier->isPasswordCorrect($loginCurrentUser, $passwordConfirmation)) {
throw new Exception(Piwik::translate('UsersManager_CurrentPasswordNotCorrect'));
Expand Down
2 changes: 1 addition & 1 deletion plugins/UsersManager/Controller.php
Expand Up @@ -435,7 +435,7 @@ private function processPasswordChange($userLogin)
if ($newPassword !== false && !Url::isValidHost()) {
throw new Exception("Cannot change password or email with untrusted hostname!");
}

// UI disables password change on invalid host, but check here anyway
Request::processRequest('UsersManager.updateUser', [
'userLogin' => $userLogin,
Expand Down

0 comments on commit 0cdfff7

Please sign in to comment.