Repository navigation
Hardening proposals of issue #285 (items 2–9) - #336
Merged
Merged
Conversation
- 6: the page of a blocked address sends frame-ancestors 'none' and X-Frame-Options: DENY (it is echoed without the template); the unblock page sends X-Frame-Options: DENY and nosniff (no CSP there: it would replace a policy the site sends already). - 5: a request which bypassed the configured proxy is logged once an hour per address (LockHelper::due(), 64 stamp files keyed like the lock slots), not on every request; the settings show a check with the administrator's own request (REMOTE_ADDR, forwarding headers, the address BFStop uses); the header setting says Client-Ip and X-Cluster-Client-Ip are only safe if the proxy overwrites them. - 3: the blocking-mode description says which logins "Login Only" covers and recommends "Full Site" for sites with third-party logins. - 7: HtaccessHelper::webServer() tells Apache, LiteSpeed and nginx apart; .htaccess mode is refused on nginx, LiteSpeed gets a specific warning, and the .htaccess warnings only show where the file is used. - 9: the release zips and sums get a build provenance attestation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AFJFMRAm2uvNjFHsxUU4VL
…tem 8) In "Full Site" mode (with or without .htaccess), nothing routing tells can change the answer for the backend and the API: the unblock page and the password recovery are pages of the site. onAfterInitialise refuses those requests already; what it found (allow list, active blocks) is reused after routing instead of being asked again. The site and "Login Only" still wait for the router. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AFJFMRAm2uvNjFHsxUU4VL
, item 4) A blocked client is let through to the password recovery, and its forms send mails (the username reminder has no limit in Joomla). Their submissions are counted against the newest active block (new columns recovery_requests/recovery_since of #__bfstop_bannedip, install SQL and the 2.0.0 update): at most BlockPolicy::RecoverySubmissionsPerHour (10) an hour, then the blocked page; the views stay reachable. Fails open. The reminder setting's description recommends a captcha for these forms. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AFJFMRAm2uvNjFHsxUU4VL
…, item 2) ActionLogHelper writes to com_actionlogs (ActionlogModel::addLog(), as Joomla's own action log plugins do) when com_bfstop is among its "Events To Log": blocks added/changed (postSaveHook) and lifted, allow-list entries added/changed/removed, .htaccess entries added/removed, settings saved (names of the changed settings only), purges of failed logins and user name statistics, pruning and clearing BFStop's log, and blocks lifted with an unblock link. Not the plugin's automatic blocks. The component's installer registers com_bfstop in #__action_logs_extensions and, when it is new there, ticks it in loggable_extensions; uninstalling takes it out again. Messages in all 10 languages. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AFJFMRAm2uvNjFHsxUU4VL
…s (issue #285, item 7) A toolbar button (settings.checkHtaccess, core.admin) runs HtaccessCheckHelper: a probe directory next to the .htaccess file, whose own .htaccess has an <If> of the block section's form with "Require all denied" for an address no client has or the query deny=<token> (HtaccessHelper::writeProbe()). Its file is requested over HTTP from the site's own address with ?allow= (must be served) and ?deny= (must be refused); the directory is removed again. Results: effective, ignored, broken (500) or unknown with the reason. The probe is also checked against a real Apache in tests/ci/apache-htaccess.sh. Resolves the TODO in DisplayController. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AFJFMRAm2uvNjFHsxUU4VL
New setting nginxDenyFile (with "Full Site"): NginxDenyFile keeps the active blocks (BlockRepository::activeAddresses(), newest first, at most MaxBlockLines) as "deny" lines in a *.conf file for nginx to include. It is rewritten as a whole, atomically, after a block (BlockService), an unblock (backend and token, through UnblockHelper), a block saved by hand, a change of the settings (the former file is emptied) and by the daily maintenance. Entries overlapping the allow list or a trusted proxy are left out. Only a file which starts with BFStop's header is overwritten, and only *.conf (NginxdenyfileRule refuses the others). nginx has to be reloaded to read it; the setting's description says how. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AFJFMRAm2uvNjFHsxUU4VL
ActionLogHelper checked for Joomla\CMS\Extension\MVCFactoryServiceInterface, which doesn't exist, so nothing reached the User Actions Log (CI: testWhatAdministratorsDoGoesToTheUserActionsLog, and phpstan's class.notFound). It is Joomla\CMS\MVC\Factory\MVCFactoryServiceInterface. The unblock page sets its headers in one loop, so the baseline entry of setHeader() shrinks to 2 instead of growing to 5. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AFJFMRAm2uvNjFHsxUU4VL
…reads The "broken" message (status 500) says the directives need Apache 2.4 or later, not exactly 2.4. The "ignored" message no longer says that other web servers don't read .htaccess files: nginx doesn't, OpenLiteSpeed reads only their rewrite rules, and LiteSpeed Enterprise may not support every directive of the block section. All 10 languages. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AFJFMRAm2uvNjFHsxUU4VL
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.
This implements the open items of #285 that were chosen. One commit per item. The items not done here have their own issues: #337 (making database failures visible, item 1), #338 (the Login Only backstop, item 3) and #339 (the mailpit mail test, item 10).
Closes #285.
Changes
6. Response headers
Content-Security-Policy: frame-ancestors 'none'andX-Frame-Options: DENY.X-Frame-Options: DENYandnosniff. It gets no CSP header, because one would replace a policy the site may already send.5. Proxy configuration
LockHelper::due(), 64 stamp files), not on every request.REMOTE_ADDR, forwarding headers) and the address BFStop takes from it.Client-IpandX-Cluster-Client-Ipare only safe if the proxy overwrites them.3. Login Only mode
7. Web server
HtaccessHelper::webServer()tells Apache, LiteSpeed and nginx apart..htaccessmode is refused on nginx, and LiteSpeed gets its own warning. The.htaccesswarnings only show where the file is used.HtaccessCheckHelper):.htaccessfile. The probe's own.htaccessuses the block section's form (<If>+Require all denied) and refuses one query.tests/ci/apache-htaccess.shalso checks the probe against a real Apache. This resolves the TODO inDisplayController.nginxDenyFile, used with "Full Site" (NginxDenyFile):denylines in a*.conffile for nginx to include.8. Request cost
onAfterInitialise, before routing. None of the pages a blocked address may reach is there. The site and "Login Only" still wait for the router, and the early check's queries aren't repeated after routing.4. Password recovery while blocked
BlockPolicy::RecoverySubmissionsPerHour). They're counted against the newest active block, in the new columnsrecovery_requests/recovery_sinceof#__bfstop_bannedip(install SQL and the 2.0.0 update). The views stay reachable.2. User Actions Log
ActionLogHelperrecords in Joomla's User Actions Log:.htaccessentries added and removed;com_bfstopin#__action_logs_extensionsand ticks it under "Events To Log" when it's new there. Uninstalling removes it again.9. Supply chain
release.ymlattests the build provenance of the zips andSHA256SUMSwithactions/attest-build-provenancev4.2.2, pinned by SHA. The package README and the release notes explaingh attestation verify.New strings are in all 10 languages.
Tests
LockHelper::due().webServer(), the probe files, and the nginx refusal;.htaccesscheck (with a fake server);NginxDenyFile(content, which files it may overwrite, following the block list).php -lpass locally.🤖 Generated with Claude Code
https://claude.ai/code/session_01AFJFMRAm2uvNjFHsxUU4VL