User tests: Successful: Unsuccessful:
Pull Request resolves # .
Totp::checkCode() matched the generated one-time passcode against the submitted value with a loose ==. getCode() returns a zero-padded numeric string, so PHP numeric juggling makes non-codes compare equal ("012345" == 12345, "123456" == "+123456", "123456" == " 123456"), and the comparison is not constant time. Switched to hash_equals() with a string cast. The TOTP setup handler read the code with getInt('code'), which drops leading zeros before it ever reaches the check; it now uses getCmd('code'), the same as the email MFA plugin and the captive login path, so the strict comparison keeps working for codes that start with 0. The fixed MFA plugin already uses hash_equals; this aligns the TOTP path with it.
+ (for example +123456).Unit test: tests/Unit/Libraries/Cms/Encrypt/TotpTest.php.
+123456 (and other numeric-juggling variants of the current code) is accepted as a valid code.
Only the exact current code is accepted; juggling variants are rejected, and codes with a leading zero still validate.
Please select:
Documentation link for guide.joomla.org:
No documentation changes for guide.joomla.org needed
Pull Request link for manual.joomla.org:
No documentation changes for manual.joomla.org needed
| Status | New | ⇒ | Pending |
| Category | ⇒ | Libraries Front End Plugins Unit Tests |
| Title |
|
||||||
Sorry about that, ticked the box. Will make sure it's checked on future PRs.
@arib06 Do we have to tell you for each of your PRs that you shall check the check box that you have read the AI policy? I did that already for your other PR and have to do the same again now.