Repository navigation
Description
Findings from a review of the plugin and component that are not fixed yet and not tracked in another issue. File and line references are to main at 643df3b and codeling/com_bfstop@cd9da63.
Status
Every item is fixed or moved to another issue. Items 3, 6, 7, 8 and 10 are fixed in #334 (commit d30ab1f), merged.
| # | Item | Status |
|---|---|---|
| 1 | Row limits only once a day, no cap on blocks | ➡️ moved to #335 (the once-a-day cap isn't a real bug; the remaining parts and alternative storage designs are discussed there) |
| 2 | eventsInInterval() calls log() with one argument |
✅ fixed in bedfac1 |
| 3 | Admin's "blocked" mail lists failed logins of the block duration | ✅ fixed in d30ab1f (#334) |
| 4 | Unblock mail with an empty token | ✅ fixed in 7451fbc |
| 5 | Group notifications go to blocked users | ✅ fixed in 7451fbc |
| 6 | IPv4-mapped IPv6 doesn't match IPv4 entries | ✅ fixed in d30ab1f (#334) |
| 7 | riskMinBlockNumber above blockNumber |
✅ fixed in d30ab1f (#334) |
| 8 | IP information page empty for IPv6 networks | ✅ fixed in d30ab1f (#334) |
| 9 | VersionHelper::getVersion() throws on an invalid manifest cache |
✅ fixed in 7451fbc |
| 10 | .htaccess entries added by hand |
✅ canonicalised in 7451fbc; removing now needs core.admin too, in d30ab1f (#334) |
The four findings of the same review which mattered most are fixed and merged:
| Fix | Plugin | Component |
|---|---|---|
| Editing a block no longer makes a duration the list doesn't offer permanent | #289 | codeling/com_bfstop#50 |
| Blocks added in the backend start when added, not at midnight | #290 | codeling/com_bfstop#51 |
.htaccess entries are removed after a mode or path change, and on uninstall |
#291 | codeling/com_bfstop#52 |
.htaccess mode: the unblock link gets through; Blocklist blocks go into the file |
#292 | codeling/com_bfstop#53 |
Already tracked elsewhere, so not repeated here:
- the database queries
init()/NotifierHelpermakes on every request: Architecture problems in plugin and component #284 A4; - the daily maintenance without a lock, and the read-modify-write race of
savePluginSetting(): Architecture problems in plugin and component #284 A3; - the dead fallback in
TokenHelper,LogHelperignoringlogMaxSize, the message type oftestNotify(),LogModelhard-coding the file name: Code smells in plugin and component #283 C1, C4, C5, C6.
Robustness
1. The row limits only hold once a day, and blocks have none
Status: ➡️ moved to #335. The cap only holding once a day isn't a real bug: blocking already bounds the rows per address, and #335 lists what can still happen. The block table without a cap and the
.htaccesscleanup query over the whole block table are still open and tracked there, together with alternative ways to store failed logins.
- Where:
src/Helper/DatabaseHelper.php:35($FAILED_LOGIN_MAX_ROWS = 200000), thetrim*()calls inBfstop::onAfterInitialise(), andgetAddressesWithoutActiveBlock()atDatabaseHelper.php:352. - Problem: the failed-login cap is only enforced by the daily maintenance, so between two runs a client with many addresses can add rows without limit; the trim then deletes at most 1,000 × 5,000 rows per run.
- Problem:
#__bfstop_bannediphas no cap at all. WithdeleteOld= 0, or with permanent blocks, it grows with every block, and an IPv6 client can cause one block per /56. - Problem: in
.htaccessmode,getAddressesWithoutActiveBlock()(aNOT EXISTSover the whole table) runs on every new block, under the block lock. - Proposal: check the failed-login count cheaply on insert (e.g. every N inserts), cap or archive old block rows, and restrict the
.htaccesscleanup query to the addresses present in the file.
2. eventsInInterval() calls log() with one argument
Status: ✅ fixed in bedfac1. The log call moved to
Repository::windowQuery()withLog::WARNING, so it no longer throws. It doesn't return 0 early, but with a negative interval theBETWEENrange is empty anyway.
- Where:
src/Helper/DatabaseHelper.php:111:$this->logger->log("Invalid interval $interval"). - Problem:
LoggerHelper::log()takes two arguments. With an interval ≤ 0 this throws anArgumentCountError, whichcatch (\Exception)doesn't catch, so the failed login ends in an error page. - Reachable: not through the settings form (
validate="options"keepsaccountCheckInterval≥ 5), but through a stored setting or a future caller. - Fix: pass
Log::WARNING, and return 0 for an interval ≤ 0.
Mails
3. The admin's "blocked" mail lists the failed logins of the block duration, not of the check interval
Status: ✅ fixed in d30ab1f (#334). Leaving out
handled = 1rows wouldn't have worked, because the block marks the attempts handled before the mail is built. Instead, the attempts the block decision counted (the unhandled ones of the check interval) are read under the block lock, before the block marks them, and only when a mail can go out. The mail lists those. Its text no longer says it may list more, in all 10 languages.
- Where:
Bfstop::notifyOfBlock()(src/Extension/Bfstop.php:338) passes the block duration toblockedNotifyAdmin(), andNotifierHelper::getBlockedBody()(NotifierHelper.php:124) uses it as the window ofgetFormattedFailedList(). - Problem: for a permanent block that is 10 years: the mail lists every failed login of the address still stored, including those handled by earlier blocks.
- Fix: pass
checkInterval, and leave outhandled = 1rows.
4. An unblock mail goes out with an empty token if the token can't be stored
Status: ✅ fixed in 7451fbc.
notifyOfBlock()logs an error and sends no mail when the token can't be made or stored.
- Where:
Bfstop::getUnblockLink()(Bfstop.php:144).getNewUnblockToken()returnsnullon failure, andunblockLink(null)builds…&token=; the mail is sent with a link that can't work. - Fix: don't send the mail (and log it) when no token was stored.
5. Group notifications also go to blocked (disabled) users
Status: ✅ fixed in 7451fbc.
UserRepository::emailsOfGroup()uses anINNER JOINandu.block = 0.
- Where:
DatabaseHelper::getUserGroupEmail()(DatabaseHelper.php:676) selects every member of the group, including accounts withblock = 1. - Fix: add
u.block = 0to the query. TheLEFT JOINis effectively an inner join because of theWHEREong.group_id; make it anINNER JOIN.
Address matching
6. Clients whose IPv4 address arrives as IPv4-mapped IPv6 don't match IPv4 entries
Status: ✅ fixed in d30ab1f (#334). The new
IpHelper::unmapped()is applied ingetAddress()(toREMOTE_ADDRand the forwarding header),canonicalEntry(),lookupCandidates(),isInSubnet()andisTrustedProxy(). Mapped networks within::ffff:0:0/96become IPv4 networks. The update script converts existing list entries the same way, and old.htaccessentries in mapped form are removed with their IPv4 block.
- Where:
IpHelper::lookupCandidates()(src/Helper/IpHelper.php:142) andtrackedAddress()(:170). - Problem: behind dual-stack sockets (a server listening on
[::]),REMOTE_ADDRcan be::ffff:203.0.113.5. Its candidates are all 16-byte forms, so allow-list and block entries203.0.113.5or203.0.113.0/24never match it. In.htaccessmode the written entry is::ffff:203.0.113.5. - Fix: normalise IPv4-mapped addresses to IPv4 in
getAddress()(or incanonicalEntry()/lookupCandidates()).
7. riskMinBlockNumber above blockNumber silently raises the threshold for everybody
Status: ✅ fixed in d30ab1f (#334).
SettingsModel::validate()refuses the combination, andBlockPolicy::effectiveBlockNumber()caps the floor atblockNumber.
- Where:
Bfstop::determineEffectiveBlockNumber()(Bfstop.php:489):max($minBlockNumber, $effective). - Problem: with
blockNumber5 andriskMinBlockNumber10, every client gets 10 attempts, and the settings page accepts the combination. - Fix: validate
riskMinBlockNumber <= blockNumberinSettingsModel::validate(), or cap the floor atblockNumber.
Component
8. The IP information page shows nothing for blocked IPv6 networks
Status: ✅ fixed in d30ab1f (#334).
GeoHelperlooks up a network by its network address.
- Where: com_bfstop
admin/src/View/Ipinfo/HtmlView.php:33. - Problem: the block list links IPv6 clients by their network (
2001:db8:1:200::/56), andGeoHelper::getCityDetails()is given the CIDR string, which the reader refuses, so the page always says "no information". - Fix: look up the network address (the part before
/).
9. VersionHelper::getVersion() throws on an invalid manifest cache
Status: ✅ fixed in 7451fbc. It checks
is_object($json) && isset($json->version)and returns''otherwise.
- Where: com_bfstop
admin/src/Helper/VersionHelper.php:21. - Problem:
json_decode()givesnullfor an empty or invalidmanifest_cache, andproperty_exists(null, …)is aTypeErroron PHP 8: every backend page of the component fails. - Fix:
is_object($json) && property_exists(...).
10. .htaccess entries added by hand: not canonical, and removing needs less than adding
Status: ✅ fixed.
HtblockController::save()stores the address in canonical form (7451fbc). Decision on the permission: removing entries needscore.adminas well ascore.delete, the same as adding one, throughHtblocklistController::mayRemove(), which the toolbar also uses (d30ab1f, #334).
- Where: com_bfstop
HtblockController::save()(admin/src/Controller/HtblockController.php:101) writes the address as typed, e.g.203.0.113.5/24or2001:DB8::/32, not inIpHelper::canonicalEntry()form, so the dedupe and the comparisons with the block list miss other spellings. - Where:
HtblocklistController::unblock()(:32) needs onlycore.delete, while adding an entry needscore.create+core.admin. - Fix: canonicalise before
denyIP(), and decide whether removing hand-made entries should needcore.adminas well. It's probably fine as it is, but it's worth an explicit decision.
Activity
Merge pull request #334 (fixes)