[ticket/17680] Add escalating cooldown for failed login attempts#6985
Open
ECYaz wants to merge 1 commit into
Open
[ticket/17680] Add escalating cooldown for failed login attempts#6985ECYaz wants to merge 1 commit into
ECYaz wants to merge 1 commit into
Conversation
Once the maximum number of login attempts for a username or IP address is exceeded, reject further attempts for a configurable cooldown period after each failed attempt, independently of the CAPTCHA. The cooldown starts at login_cooldown_min seconds, grows by the same amount for every further failed attempt and is capped at login_cooldown_max seconds. The cooldown is keyed to the source of the failed attempts: exceeding the per-IP threshold enforces it for the IP, while exceeding the per-user threshold enforces it for the username and IP combination only, so failed attempts by a third party cannot lock the account owner out. The timestamps come from the existing login attempts table, whose cleanup now also honours the maximum cooldown time. PHPBB-17680
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.
Checklist:
Once the maximum number of login attempts for a username or IP address is
exceeded, further login attempts are rejected for a cooldown period after each
failed attempt. The cooldown is enforced independently of the CAPTCHA, so it
also slows brute force attacks on boards whose CAPTCHA has been broken —
currently a broken CAPTCHA means there is effectively no mitigation at all.
How it works
login_cooldown_min(default 1 minute,0disables the cooldown) andlogin_cooldown_max(default 10 minutes). The cooldown starts at theminimum, grows by the same amount for every further failed attempt beyond
the threshold, and is capped at the maximum.
decision is made, before the current attempt is recorded — so attempts
rejected by the cooldown do not extend it.
IP; exceeding the per-user threshold enforces it for the username + IP
combination only. A third party's failed attempts therefore cannot lock the
account owner out (a cooldown keyed to the account alone would allow keeping
any account permanently locked with one failed attempt per window).
table, which already records IP, username and time for every attempt. The
session GC now retains those rows for at least
login_cooldown_max, so anactive cooldown cannot lose its reference timestamp.
LOGIN_ERROR_COOLDOWNstatus with a "You need to wait X minutes andY seconds before trying to log in again." message. All three places that
render login errors handle it (login_box, OAuth account linking, feed HTTP
auth) via a shared formatter. During the cooldown no CAPTCHA is displayed;
once it expires the CAPTCHA gate applies as before.
one for existing usernames, so the cooldown adds no new username-probing
signal.
The countdown timer with meta refresh suggested in the ticket can be a
follow-up; the server enforces the cooldown either way.
Tests
tests/auth/ticket17680_login_cooldown_test.php: threshold trip, correctpassword rejected during cooldown, rejected attempts not extending the
cooldown, username + IP keying, escalation, expiry, disabling via
0, andmessage formatting.
tests/functional/ticket17680_login_cooldown_test.php: the login formshows the cooldown message after the threshold is exceeded, for the wrong
and the correct password.
Tracker ticket:
https://tracker.phpbb.com/browse/PHPBB-17680