Repository navigation
v3.81.2: Fix two-factor login rejecting every code; restyle challenge page - #23
Merged
Merged
Conversation
… page twofactor_setup.php stores the TOTP secret as hex, but verify2fa.php passed it to TwoFactorAuth::verify(), which base32-decodes its input. Decoding hex as base32 yields the wrong key, so enrolment succeeded and every login code was then rejected. Add TwoFactorAuth::verifyStored(), which decodes the stored hex, and use it at login. The challenge page now matches the login screen instead of rendering inside the app layout. Login styles move to assets/css/auth.css, shared by both pages. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
twofactor_setup.phpstores the TOTP secret as hex (bin2hex(random_bytes(16))) and hands the authenticator app the base32 encoding of those bytes.verify2fa.phppassed the stored hex toTwoFactorAuth::verify(), which base32-decodes its input. That gave a different key, so enrolment succeeded and every login code afterwards was rejected.Changes
TwoFactorAuth::verifyStored()hex-decodes the stored secret (anything that isn't hex is still treated as base32).verify2fa.phpnow uses it.autocomplete="one-time-code", back-to-sign-in link.assets/css/auth.css, whichlogin.phpandverify2fa.phpnow share.Testing
tests/twofactor_test.php16/16 andtests/mfa_requirement_test.php13/13, run againstopnsense_fw_test.verifyStored()accepts it, the oldverify()rejects it.auth.cssreturn 200, andverify2fa.phpredirects (302) when there's no pending session.🤖 Generated with Claude Code