Skip to content

Commit 7574fd8

Browse files
Maximilian WirtzLarsMichelsen
authored andcommitted
Fix type juggling vulnerability
PHP evaluates `!=` a bit loose on the type. So "0000" == "0e5678" is true in PHP. An attacker could send a zeroed cookie_hash `"0"*32` and only need an collision with a calculated hash beginning with `0e` followed by only numbers. In our tests (with auth.secret set to `stable`) a valid cookie is `cmkadmin:58191275:00000000000000000000000000000000`. For a remote attacker this would have needed 58,191,275 guesses.
1 parent 7d60f92 commit 7574fd8

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

share/server/core/classes/CoreLogonMultisite.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,10 @@ private function checkAuthCookie($cookieName) {
114114
$hash = $this->generateHash($username, $sessionId, (string) $user_secret);
115115

116116
// Validate the hash
117-
if ($cookieHash != $hash) {
117+
if ($cookieHash !== $hash) {
118118
throw new Exception();
119119
}
120120

121-
// FIXME: Maybe renew the cookie here too
122-
123121
return $username;
124122
}
125123

0 commit comments

Comments
 (0)