Skip to content

Remaining review findings in plugin and component: row limits, mails, address matching, smaller bugs #294

Closed

Description

@codeling

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:

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 .htaccess cleanup 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), the trim*() calls in Bfstop::onAfterInitialise(), and getAddressesWithoutActiveBlock() at DatabaseHelper.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_bannedip has no cap at all. With deleteOld = 0, or with permanent blocks, it grows with every block, and an IPv6 client can cause one block per /56.
  • Problem: in .htaccess mode, getAddressesWithoutActiveBlock() (a NOT EXISTS over 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 .htaccess cleanup 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() with Log::WARNING, so it no longer throws. It doesn't return 0 early, but with a negative interval the BETWEEN range 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 an ArgumentCountError, which catch (\Exception) doesn't catch, so the failed login ends in an error page.
  • Reachable: not through the settings form (validate="options" keeps accountCheckInterval ≥ 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 = 1 rows 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 to blockedNotifyAdmin(), and NotifierHelper::getBlockedBody() (NotifierHelper.php:124) uses it as the window of getFormattedFailedList().
  • 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 out handled = 1 rows.

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() returns null on failure, and unblockLink(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 an INNER JOIN and u.block = 0.

  • Where: DatabaseHelper::getUserGroupEmail() (DatabaseHelper.php:676) selects every member of the group, including accounts with block = 1.
  • Fix: add u.block = 0 to the query. The LEFT JOIN is effectively an inner join because of the WHERE on g.group_id; make it an INNER 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 in getAddress() (to REMOTE_ADDR and the forwarding header), canonicalEntry(), lookupCandidates(), isInSubnet() and isTrustedProxy(). Mapped networks within ::ffff:0:0/96 become IPv4 networks. The update script converts existing list entries the same way, and old .htaccess entries in mapped form are removed with their IPv4 block.

  • Where: IpHelper::lookupCandidates() (src/Helper/IpHelper.php:142) and trackedAddress() (:170).
  • Problem: behind dual-stack sockets (a server listening on [::]), REMOTE_ADDR can be ::ffff:203.0.113.5. Its candidates are all 16-byte forms, so allow-list and block entries 203.0.113.5 or 203.0.113.0/24 never match it. In .htaccess mode the written entry is ::ffff:203.0.113.5.
  • Fix: normalise IPv4-mapped addresses to IPv4 in getAddress() (or in canonicalEntry()/lookupCandidates()).

7. riskMinBlockNumber above blockNumber silently raises the threshold for everybody

Status: ✅ fixed in d30ab1f (#334). SettingsModel::validate() refuses the combination, and BlockPolicy::effectiveBlockNumber() caps the floor at blockNumber.

  • Where: Bfstop::determineEffectiveBlockNumber() (Bfstop.php:489): max($minBlockNumber, $effective).
  • Problem: with blockNumber 5 and riskMinBlockNumber 10, every client gets 10 attempts, and the settings page accepts the combination.
  • Fix: validate riskMinBlockNumber <= blockNumber in SettingsModel::validate(), or cap the floor at blockNumber.

Component

8. The IP information page shows nothing for blocked IPv6 networks

Status: ✅ fixed in d30ab1f (#334). GeoHelper looks 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), and GeoHelper::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() gives null for an empty or invalid manifest_cache, and property_exists(null, …) is a TypeError on 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 needs core.admin as well as core.delete, the same as adding one, through HtblocklistController::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/24 or 2001:DB8::/32, not in IpHelper::canonicalEntry() form, so the dedupe and the comparisons with the block list miss other spellings.
  • Where: HtblocklistController::unblock() (:32) needs only core.delete, while adding an entry needs core.create + core.admin.
  • Fix: canonicalise before denyIP(), and decide whether removing hand-made entries should need core.admin as well. It's probably fine as it is, but it's worth an explicit decision.

Activity

  1. 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

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions