Repository navigation
MFA challenge: configurable attempt limits and an event on a failed code #21021
michielwittkampf
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Summary
Make the attempt limits of the multi-factor challenge on the login page configurable, and dispatch an event when a challenge fails. Today an app that wants a stricter limit, or wants to log failed codes, has to override protected internals of
Filament\Auth\Pages\Login.Current behaviour (5.11.3)
MultiFactorChallengeallows 5 submissions per user per 60 seconds ($maxRateLimiterAttemptsis protected with no setter, andhitRateLimiter()uses the default decay).codeExpiryMinutes().AppAuthenticationdefaults tocodeWindow = 8: 17 valid codes at any moment. Thank you for lowering this to 1 on 6.x (fix(panels): reduce default TOTP code window to ±30 secs #20317).Someone who knows a user's password can keep submitting codes for days. At 5 per minute that is about 7,200 guesses a day: roughly a 0.7% daily chance for a 6-digit email code, and about 11% for an app code with the 5.x window. These are back-of-the-envelope figures, not measurements.
Ideas
->multiFactorAuthentication([...], challengeRateLimit: ...), or public setters onMultiFactorChallenge.MultiFactorChallengeFailed($user, $providerId), similar to Fortify'sTwoFactorAuthenticationFailed. Apps could then log it, notify the user, or lock the account without overridingLogin.codeWindowdefault of 1, or mention the trade-off in the 5.x docs.Current workaround
We override
Login::isMultiFactorChallengeRateLimited()to reject a locked-out user before the code is validated, so a correct code is neither consumed nor revealed. We also catch theValidationExceptioninauthenticate()to count wrong codes by their keys (data.multiFactor.<provider>.code/.recoveryCode). It works, but it depends on protected methods and on the order of calls insideauthenticate(), which may change between releases.For reference, NIST SP 800-63B requires limiting consecutive failed attempts per authenticator (at most 100). The current 5-per-minute limit has no ceiling over time.
All reactions