Skip to content

Fix Login Only bypass at the backend login; prune lifted .htaccess blocks on unblock; bound DNS cache - #263

Merged
codeling merged 4 commits into
mainfrom
ccr-f557f83f-uk6a4f
Nov 7, 2026
Merged

codeling merged 4 commits into
mainfrom
ccr-f557f83f-uk6a4f

Conversation

@codeling

@codeling codeling commented Nov 7, 2026

Copy link
Copy Markdown
Owner

Plugin half of a bug/security review of plugin and component. The component changes are in codeling/com_bfstop#31 (same branch name), which CI picks up automatically.

Changes

Security: "Login Only" block mode could be bypassed at the backend login (9965e72)

Joomla's backend runs com_login for every request from a guest, or from a user without core.login.admin, whatever component the request names (com_login and com_ajax are the only exceptions). This happens in AdministratorApplication::findOption(), which runs at dispatch, after onAfterRoute. isLoginAttemptRequest() only checked the option parameter. So in Login Only mode, a blocked address could keep trying passwords with POST /administrator/index.php and task=login, either leaving option out or naming any other component (option=com_cpanel&task=login, …).

  • The new requestedOption() returns the component Joomla will actually run, and the login check uses it.
  • The password-recovery exemption uses it too, and the unblock-token pass is limited to the site, so neither lets a blocked address through to the backend login form.
  • tests/Integration/fixtures/request.php can now simulate backend requests (--admin, as a guest or as a named user). The new tests in BlockedRequestTest fail on main (request 'task=login' should be blocked) and pass here.

Lifted blocks are taken out of .htaccess right away (e770bbb)

Unblocking in the component, from the block list or with an unblock link, only recorded the unblock in the database. The web server kept rejecting the address until the next block or the daily maintenance. The removal logic moves from Bfstop::removeLiftedHtaccessBlocks() into HtaccessHelper::removeLiftedBlocks() so the component can call it. This commit also adds the ComponentTest tests for all the component fixes in com_bfstop#31.

The reverse-DNS cache is pruned daily, whatever the purge age (6feadd4)

#__bfstop_dnscache was only cleaned up in purgeOldEntries(), which never runs with a purge age of 0, and it had no row limit. With the reverse-DNS risk signal on, every failed login from a new address adds a row, and an IPv6 client can use a new address for every attempt. The new pruneDnsCache() runs in the daily maintenance: it deletes expired rows and keeps at most 10000, oldest first.

CHANGELOG (21d05fd)

None of these affect the released 1.5.x. Login Only mode, removing lifted .htaccess blocks and the reverse-DNS signal are all new in 2.0.0.

Checked and not changed

  • Saving the plugin in Plugin Manager doesn't wipe the settings. Its form only has a note field, which posts nothing, and Form::filter() only outputs posted fields, so params stays as stored.
  • Not fixed in this PR, worth a decision:
    • The unblock link is built from Uri::base(), so it follows the request's Host header unless live_site is set. This is the same as Joomla's own reset mails. In "any address" mode, a forged Host can put a foreign domain into the unblock mail.
    • The API application (client id 3) is never covered by enabledForOrigin, so failed logins through API basic auth aren't counted.
    • #__bfstop_failedlogin has no index on ipaddress, so the per-IP counts scan the table (it is capped at 200000 rows).

Testing

Run locally against Joomla 5.4.10 on PostgreSQL 16, with the package built from both branches and installed by tests/ci/install-joomla.sh:

  • phpunit --testsuite unit,integration: 388 tests OK (381 on main plus 7 new), 3 skipped for environment reasons (running as root; MySQL-only checks). UnblockPageHttpTest was also run after deploying the changed code into the site.
  • check-versions, check-language, check-workflows, check-joomla-checksums, check-zip, composer validate --strict, php -l and xmllint all pass.
  • Not run locally: MySQL/MariaDB and Joomla 6. CI covers those.

Generated by Claude Code

Joomla's backend runs com_login for every request of a guest (or of a
user without core.login.admin), whatever component the request names,
except com_login and com_ajax: AdministratorApplication::findOption(),
which is called when the request is dispatched, after onAfterRoute.
isLoginAttemptRequest() only went by the "option" parameter, so in
"Login Only" block mode a blocked address could keep trying passwords
at the backend login by leaving out option=com_login, or naming any
other component (e.g. POST /administrator/index.php with task=login).

The checks now go by the component Joomla actually runs
(requestedOption()). The exemptions for password recovery and for the
unblock page use it too (the unblock pass is limited to the site), so
neither lets a blocked address through to the backend's login form.

The request fixture can now simulate backend requests (--admin, as a
guest or as a given user) for the tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AFJFMPv7CSqgJJ93QJvYfL
…fixes

With blocking through .htaccess, unblocking an address in the
component's block list or with an emailed unblock link only recorded
the unblock in the database. The line in .htaccess stayed until the
plugin blocked the next address or ran its daily maintenance, so the
web server kept rejecting the address for up to a day.

The removal of lifted blocks moves from the plugin class into
HtaccessHelper::removeLiftedBlocks(), so com_bfstop can call it right
after it unblocked something (see the com_bfstop branch of the same
name).

ComponentTest gets tests for that and for the other com_bfstop fixes:
unblocking several blocks at once no longer stops at one which was
lifted already, every sortable column header is one the list model
accepts, and block durations (a week, 30 days, progressive ones) are
shown as text instead of language keys.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AFJFMPv7CSqgJJ93QJvYfL
#__bfstop_dnscache was only cleaned up by purgeOldEntries(), which
doesn't run with a purge age of 0, and had no row limit. With the
reverse-DNS risk signal on, every failed login from a new address adds
a row, and an IPv6 client can use a new address for every attempt.

The daily maintenance now deletes expired entries (nothing reads them
any more) and keeps the table to 10000 rows, oldest first.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AFJFMPv7CSqgJJ93QJvYfL
…omponent fixes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AFJFMPv7CSqgJJ93QJvYfL
@codeling
codeling merged commit de1d5b9 into main Nov 7, 2026
18 checks passed
@codeling
codeling deleted the ccr-f557f83f-uk6a4f branch November 7, 2026 21:49
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