Repository navigation
Remove the delayed response to failed logins - #340
Merged
Merged
Conversation
A delay was a sleep() in a PHP worker: it slowed down only clients that
wait for one answer before sending the next attempt, which blocking stops
long before a delay matters, while every delayed response held a worker
(and its database connection) that an attacker sending failed logins in
parallel, from many addresses, could use to run the server out of them.
The cap on delayed responses (delayMaxConcurrent) made the delay useless
exactly under attack.
- Removed: "Delay", "Adaptive Delay" with its maximum and thresholds,
"Responses delayed at the same time", the account throttle's delay and
"Delay Seconds Per Risk Point"; Responder::delay() and its lock slots,
BlockPolicy::delaySeconds() and FailedLoginRepository::countInLastHour()
- The account throttle's detection stays, as a signal of the risk score:
once a username has had accountBlockNumber failed logins within
accountCheckInterval minutes from any addresses, each address trying it
gets accountAttackPoints (default 3) more risk points, i.e. is blocked
after fewer attempts ("Distributed Attacks on One Account")
- The update removes the delay settings of 1.x and tells the administrator
if they delayed responses, recommending the web server's rate limiting
- Language strings of all 10 languages, README ("Rate limiting"),
CHANGELOG, tests
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AFJFMQRUHZdADDuijoYmi3
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AFJFMQRUHZdADDuijoYmi3
The check that the page was found and read asked for more than 50; the removal of the delay settings left exactly 50. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AFJFMQRUHZdADDuijoYmi3
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.
Reviews found that the response delays work against BFStop's goal, so this removes every deliberate delay from 2.0.0 (unreleased).
Why
A delay was a
sleep()in a PHP worker (Responder::delay()):blockNumberattempts (10 by default). A delay adds about 50 s at 5 s per attempt, all before the block anyway.delayMaxConcurrentallowed 5 concurrent sleeps. At 5 s per delay, about 1 request per second keeps all 5 slots busy, and from then on nobody is delayed.What changes
Responder::delay()with its lock slots,BlockPolicy::delaySeconds()andFailedLoginRepository::countInLastHour().RiskHelper::accountAttackScore()). Once a username hasaccountBlockNumberfailed logins withinaccountCheckIntervalminutes from any address, every address trying it getsaccountAttackPoints(default 3) more risk points. With the defaults, such an address is blocked after 7 attempts instead of 10. The settings group is renamed to "Distributed Attacks on One Account", andaccountThrottleEnabledbecomesaccountAttackEnabled. The real owner logging in from a known address still gets the known-IP trust bonus.postflight()shows a notice that recommends web-server rate limiting instead (nginxlimit_req,mod_evasive/mod_qos, fail2ban). The settings added during 2.0.0 development, and the lock files, never shipped, so they need no migration.Implications:
Tests
BlockPolicyTestandFailedLoginTest(cap, concurrency slots, blocked address not delayed, and so on).BlockPolicyTest/RiskHelperTest: the account-attack signal, covering the threshold, other accounts, handled and old entries, switched off, the stored (hashed) username, failing safe, and its effect oneffectiveBlockNumber().FailedLoginTest: end to end, an attacked account gets its attackers blocked sooner while another account doesn't, and a failed login is answered at once.InstallerScriptTest: the update removes the delay settings and shows the notice only when they delayed responses.UpgradeTest: the seed'sdelayDuration90 is gone after the update, and the notice is shown.SettingsDefaultsTest: its sanity floor on the number of settings drops from more than 50 to more than 40. The page has exactly 50 settings now (56 before).Results: CI is green on all 20 checks:
.htaccessjob🤖 Generated with Claude Code
https://claude.ai/code/session_01AFJFMQRUHZdADDuijoYmi3