Skip to content

Remove the delayed response to failed logins - #340

Merged
codeling merged 3 commits into
mainfrom
ccr-a0c069d4-wo0w14
Nov 22, 2026
Merged

codeling merged 3 commits into
mainfrom
ccr-a0c069d4-wo0w14

Conversation

@codeling

@codeling codeling commented Nov 22, 2026 •

Copy link
Copy Markdown
Owner

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()):

  • It only slows clients that wait for one answer before sending the next attempt. Blocking already stops such a client after blockNumber attempts (10 by default). A delay adds about 50 s at 5 s per attempt, all before the block anyway.
  • Parallel or distributed attackers don't wait for answers, so the delay never slows them. Every delayed response holds a worker and its database connection, which such an attacker can use to run the server out of workers.
  • The cap meant to prevent that made the delay useless under attack. delayMaxConcurrent allowed 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.
  • The standards don't ask for a delay. OWASP A07 says "limit or increasingly delay failed login attempts, but be careful not to create a denial of service scenario". NIST SP 800-63B-4 requires limiting failed attempts, which the block already does.

What changes

  • Removed settings: "Delay", "Adaptive Delay" with its maximum and two thresholds, "Responses delayed at the same time", the account throttle's "Additional Delay" and "Delay Seconds Per Risk Point".
  • Removed code: Responder::delay() with its lock slots, BlockPolicy::delaySeconds() and FailedLoginRepository::countInLastHour().
  • The account throttle's detection becomes a risk-score signal (RiskHelper::accountAttackScore()). Once a username has accountBlockNumber failed logins within accountCheckInterval minutes from any address, every address trying it gets accountAttackPoints (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", and accountThrottleEnabled becomes accountAttackEnabled. The real owner logging in from a known address still gets the known-IP trust bonus.
  • Update from 1.x: the update removes the five delay settings of 1.5.2. If they actually delayed responses, postflight() shows a notice that recommends web-server rate limiting instead (nginx limit_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.
  • Strings and docs: language strings in all 10 languages, including the plugin description that still mentioned "a variable delay". The README section "What the delays can and can't do" becomes "Rate limiting". The CHANGELOG gets a "Removed" entry, and its other 2.0.0 bullets that described delay behaviour are rewritten or dropped. The wiki pages "Design Decision No Response Delays" and "Why No Delay Options in 2.0" are drafted but not published yet.

Implications:

  • Failed logins are now answered at once.
  • With blocking mode "Reporting Only", BFStop now only records and notifies.
  • Integrations that wrote the removed setting keys break. They are unlikely to exist.

Tests

  • Removed: the delay tests in BlockPolicyTest and FailedLoginTest (cap, concurrency slots, blocked address not delayed, and so on).
  • Added to 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 on effectiveBlockNumber().
  • Added to 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.
  • Added to InstallerScriptTest: the update removes the delay settings and shows the notice only when they delayed responses.
  • Updated UpgradeTest: the seed's delayDuration 90 is gone after the update, and the notice is shown.
  • Updated 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:

  • the unit tests on PHP 8.2, 8.4 and 8.5
  • the integration suites on Joomla 5.4, 6.1 and 6.2 with MySQL, MariaDB and PostgreSQL
  • both update-from-the-previous-release jobs
  • phpstan, the language and package checks, and the Apache .htaccess job

🤖 Generated with Claude Code

https://claude.ai/code/session_01AFJFMQRUHZdADDuijoYmi3

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
@codeling codeling added this to the BFStop 2.0 milestone Nov 22, 2026
@codeling codeling self-assigned this Nov 22, 2026
@codeling
codeling merged commit 7cb9f90 into main Nov 22, 2026
20 checks passed
@codeling
codeling deleted the ccr-a0c069d4-wo0w14 branch November 22, 2026 18:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants