[TikiWiki-commits] [Git][tikiwiki/tiki][29.x] [FIX] Email 2FA: decrypt stored token before comparing OTP

"Alfred Syatsukwa \(@alfredsyatsukwa\) via TikiWiki-cvs" <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <6a8429394f9a2_3827bebc8347f8@gitlab-sidekiq-low-urgency-cpu-bound-v2-b96b6f55-ntvhj.mail>

Alfred Syatsukwa pushed to branch 29.x at Tiki Wiki CMS Groupware / Tiki


Commits:
265b4723 by Alfred Syatsukwa at 2026-08-18T09:35:41+00:00
[FIX] Email 2FA: decrypt stored token before comparing OTP
---
* [FIX] Email 2FA: decrypt stored token before comparing OTP
---
See merge request tikiwiki/tiki!10937

(cherry picked from commit 170620a78d74ff74d8a8f9f83bc06752d1ef4b9c)

See merge request tikiwiki/tiki!10942

- - - - -


1 changed file:

- lib/core/TwoFactorAuth/Email2FA.php


Changes:

=====================================
lib/core/TwoFactorAuth/Email2FA.php
=====================================
@@ -112,8 +112,7 @@ class Email2FA implements TwoFactorAuthInterface
             throw new TwoFactorAuthException($errMsg);
         }
 
-        $hashedTokenFromDb = $tokenInfo['token'];
-        $hashedTokenFromClient = $this->crypt->encryptData($code);
+        $storedToken = $tokenInfo['token'];
         $attempts = $tokenInfo['attempts'];
         $created = intval($tokenInfo['created']);
         $tokenTTL = intval($prefs['twoFactorAuthEmailTokenTTL'] ?? 30) * 60;
@@ -123,7 +122,9 @@ class Email2FA implements TwoFactorAuthInterface
             throw new TwoFactorAuthException($errMsg);
         }
 
-        if ($hashedTokenFromDb !== $hashedTokenFromClient) {
+        $decryptedToken = $this->crypt->decryptData($storedToken);
+
+        if ($decryptedToken === false || ! hash_equals($decryptedToken, $code)) {
             $attempts = $tokenInfo['attempts'] + 1;
             $this->twoFATable->update(['attempts' => $attempts], ['userId' => $userInfo['userId']]);
             return false;



View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/265b4723912232a6812b12c4729fa527feb5577f

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/265b4723912232a6812b12c4729fa527feb5577f
You're receiving this email because of your account on gitlab.com. Manage all notifications: https://gitlab.com/-/profile/notifications | Help: https://gitlab.com/help

_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.