Skip to content

Hardening proposals beyond the security fixes #285

Closed

Description

@codeling

This came out of a review of the plugin and component at 2501aca / cfe9835. The findings that needed a fix are in the stacked PRs:

PR Finding
#275 .htaccess section only denies (it granted access before), migration, Apache CI job, CRLF
#276 + codeling/com_bfstop#41 no request-derived URLs in mails without $live_site
#277 + codeling/com_bfstop#42 no .htaccess block of networks that overlap the allow list
#278 one block per burst of parallel failed logins
#279 login attempts refused while the block list can't be read
#280 + codeling/com_bfstop#43 unblock page: form token, no unblock without the block's address
#281 + codeling/com_bfstop#44 core.admin for .htaccess and wide blocks; safehtml blocked message
#282 + codeling/com_bfstop#45 notification addresses validated; proxy setting validated

These are the remaining proposals: defence in depth, and design gaps that are not bugs. Roughly ordered by value for the effort.

1. Make fail-open visible

#279 makes login attempts fail closed when the block list can't be read; everything else still fails open, intentionally. Nobody notices when that happens, though. The log is only visible to core.admin, and only at the default ERROR level.

  • Count DB failures per day, in a small state table (see A3 in the architecture issue), and show a warning on the component's pages ("BFStop could not read its tables N times in the last 24 h").
  • Optionally include them in the admin mail.
  • insertFailedLogin() failing means the attempt is not counted. That should be counted as a failure too.

2. Audit trail through User Actions Log

Blocks, unblocks (backend and token), allow-list changes, settings changes and clearing the log should go to Joomla's User Actions Log (ActionlogModel::addLog(), or an actionlog plugin). BFStop's own log can be cleared by the very people it should hold to account, and it is only kept for 28 days by default.

3. Login-only mode: covered endpoints (finding S7)

isLoginAttemptRequest() only recognises com_users …login and com_login …login (and API requests with credentials). A blocked client can still log in, in this mode, through:

  • com_ajax (core WebAuthn passkeys, harmless for brute force);
  • third-party social/SSO login components;
  • login modules that post to their own controllers.

Options:

  • document what is covered, and recommend full mode when third-party logins are installed;
  • deny in onUserAuthorisation (return STATUS_DENIED) for blocked addresses as a backstop. Caveat: Joomla then shows JLIB_LOGIN_DENIED only after a correct password, which is a password oracle. Only do this if the message can be made the same as for a wrong password (e.g. through onUserAuthorisationFailure and replacing the message queue).

4. Recovery endpoints while blocked (finding S8)

Keeping password reset and username reminder reachable for blocked clients is deliberate and right. Joomla limits reset.request per user (reset_count/reset_time), but remind.remind has no limit and the captcha is optional.

  • While an address is blocked, allow at most N recovery POSTs per hour from it (store them as failedlogin rows with a separate origin, or in a counter table).
  • Recommend enabling the captcha for com_users reset/remind on the settings page.

5. Proxy configuration

#282 validates the trusted-proxy list. Still open:

  • Rate-limit the warning "the request did not originate from the configured proxy" (IpHelper::getAddress()). Every direct request writes one, so an attacker can push real entries out of the rotated log. Once per address per hour is enough.
  • The settings page should say that the single-valued headers (Client-Ip, X-Cluster-Client-Ip) are only safe if the proxy overwrites them; they can't be read "from the right".
  • A self-test on the settings page: "this request came from X, via Y; the address used is Z".

6. Response headers on the blocked page and the unblock page

Add X-Content-Type-Options: nosniff and Content-Security-Policy: frame-ancestors 'none' (or X-Frame-Options: DENY). The blocked page is echoed raw, without the template; the unblock page goes through the template.

7. Web-server backend

  • Detect LiteSpeed (partial <If> support) and nginx, and refuse .htaccess mode there with a clear message instead of only the generic "htaccess not working" warning.
  • Optionally offer an nginx include file (deny <addr>;) written to a configured path, for sites behind nginx.
  • Optionally check on the settings page that the .htaccess is actually effective (e.g. request a test URL with a header the section denies). The // TODO: add check whether .htaccess actually is effective! in DisplayController::warnIfHtAccessNotWorking() is still open.

8. Request cost (DoS)

See A4 in the architecture issue: create the notifier lazily, cache the address for the request, make username lookups index-friendly, and set a query budget per failed login enforced by a test. Blocked clients currently cost a full Joomla boot plus 2–3 queries per request; for full mode, consider answering them already in onAfterInitialise when no exemption can apply (non-site clients, no com_users/com_bfstop request).

9. Updates and supply chain

CI is already in good shape: actions pinned to SHAs, SHA-256 checks of Joomla and the previous release, least-privilege permissions:, draft releases. Still open:

  • The update details file at detailsurl (update-pkg.xml) is hosted outside the repositories (and planned for GitHub Pages in Release plan for 2.0.0 #250). Make sure the generator writes a <sha512> (or <sha384>) for each package, which Joomla checks before installing.
  • Consider GitHub artifact attestations (actions/attest-build-provenance) for the release zips.

10. Tests

Activity

  1. codeling commented on Nov 21, 2026

    @codeling
    OwnerAuthor

    Status of each item:

    # Item Status
    1 Make fail-open visible 🟡 Partly. Every database failure now goes through FailurePolicy, is logged at error level and counted per request (64389c6, #284 A6). A failed insertFailedLogin() is included. Open: a daily count kept beyond the request, the warning on the component's pages, and the admin mail.
    2 Audit trail through User Actions Log ⬜ Open
    3 Login Only mode: endpoints it covers ✅ Documented in the blocking-mode description, with "Full Site" recommended for third-party logins (#336). Not done: the onUserAuthorisation backstop, because of the password-oracle caveat.
    4 Recovery endpoints while blocked ⬜ Open (rate limit for blocked addresses, captcha recommendation)
    5 Proxy configuration ✅ The client address is worked out (and warned about) once per request (0ad2dd1, #315). The warning is logged once an hour per address, the settings note on Client-Ip/X-Cluster-Client-Ip is added, and there's a self-test on the settings page (#336).
    6 Response headers ✅ nosniff on the blocked page (16ce370). frame-ancestors 'none' and X-Frame-Options: DENY on the blocked page; X-Frame-Options: DENY and nosniff on the unblock page (#336).
    7 Web-server backend 🟡 Detecting nginx and LiteSpeed is done: .htaccess mode is refused on nginx, and LiteSpeed gets its own warning (#336). Open: the nginx include file, and the check that the .htaccess file actually works (the TODO in DisplayController).
    8 Request cost 🟡 Mostly done in #284 A4: lazy notifier and proxy settings parsed once (314340d), indexed username lookups (6d7ec1a), query-count limits (a352f78), address worked out once per request (#315). Open: answering blocked clients already in onAfterInitialise in full mode.
    9 Updates and supply chain ✅ update-pkg.xml gets a <sha256> per package (ee04429). Build provenance attestations for the release zips (#336).
    10 Tests 🟡 Query-count test (6d7ec1a, a352f78) and phpstan in CI (a535d3c, #319) are done. Open: an end-to-end mail test against an SMTP sink (mailpit).

    Generated by Claude Code

  2. codeling commented on Nov 21, 2026

    @codeling
    OwnerAuthor

    Update: every item is now done in #336 (one commit per item) or moved to an issue of its own.

    # Item Status
    1 Make fail-open visible ➡️ moved to #337 (the per-request counting is done in 64389c6)
    2 User Actions Log ✅ #336 (a1e70a8)
    3 Login Only mode: endpoints it covers ✅ documented in #336 (52a0480). The onUserAuthorisation backstop is moved to #338
    4 Recovery endpoints while blocked ✅ #336 (b575ef7): at most 10 form submissions an hour, plus the captcha recommendation
    5 Proxy configuration ✅ #315 (0ad2dd1) and #336 (52a0480)
    6 Response headers ✅ 16ce370 and #336 (52a0480)
    7 Web-server backend ✅ #336: nginx/LiteSpeed detection (52a0480), the .htaccess self-check (752167f), the nginx deny file (59daccb)
    8 Request cost ✅ #284 A4 (314340d, 6d7ec1a, a352f78, #315). Blocked backend/API requests are refused before routing in #336 (de5567a)
    9 Updates and supply chain ✅ ee04429 and #336 (52a0480): attestations
    10 Tests ✅ query-count test and phpstan (6d7ec1a, a352f78, a535d3c). The mailpit E2E test is moved to #339

    #336 says "Closes #285", so this issue closes when it's merged.


    Generated by Claude Code

  3. added a commit that references this issue on Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions