The lockout reporter recorded brute.lockout (high, blocked) with the GUESSED
account as its userId, and a high-severity blocked event with a userId
disables that account. So three wrong passwords from anyone who knew a username
disabled its owner until an admin re-enabled it - worse than the per-user lock
GHSA-rf3w-rj48-jxcc removed - and a user who mistyped their own password three
times was disabled the same way.
The reporter is now one module for startup and reload and names the account as
targetUserId; a catalog key can declare blocksAccount: false, and brute.lockout
does. An account already disabled keeps the reason it was disabled for instead
of later events overwriting it. tests/jamBleedVictimBlock.test.cjs drives the
real blocking decision with the real catalog; its negative test fails if a
lockout is recorded anywhere else or a login target is recorded as an actor.
Thanks to xet7 !
Remove the progressive HTML4/Legacy Omi middleware, cookieless sessions, page controllers, assets, parity refactors, design documents and associated tests. Restore the standard Meteor interface and operations from before the HTML4 work began.
Preserve intervening translations, backup screenshots, session upgrades, cryptographic test identifiers, local image storage, document previews and lazy browser loading. Extract the GIF utilities still required by image features into imageGif.
Validate the Node suites and add standard-interface and GIF regressions. Two existing failures remain in docsLinksResolve and ruleDetailsLocalization; browser regressions are registered but require a running server.
Thanks to xet7 !
WHAT WAS ALREADY THERE, checked before writing any of this: the DDP login has
wekan-accounts-lockout (per user, now per user+address), the REST login has
server/lib/loginAttemptThrottle.js (per address, in memory), and
server/lib/loginTimingDefense.js equalises timing so a missing user cannot be
told from a wrong password. Nothing anywhere does increasing delays, and nothing
at all blocks an address. So this extends the lockout decision rather than
adding a second mechanism beside it.
THE LOCKOUT ON ITS OWN IS A STEP FUNCTION: two failures cost nothing, the third
costs sixty seconds. A guesser spends the free attempts of every window and
waits; somebody who mistyped gets no sign they are about to be locked out. A
delay that GROWS - 1s, 2s, 4s, 8s, capped - costs a guesser far more than it
costs a person, and it degrades instead of slamming shut: the account is never
unavailable, only slower to try again.
Per (user, source address), like the counter, and for the same reason: an
attacker must not be able to slow down the account's owner. A correct password
ignores the delay entirely and clears it. An attempt refused for being too soon
is NOT counted - otherwise trying faster would reach the lockout faster, and
impatience would become a weapon against the address.
Two settings, beside the three the lockout already has: known-loginDelayBase
(1s) and known-loginDelayMax (30s). Base 0 switches delays off and leaves the
lockout behaving exactly as before, so an instance that does not want this is
not forced into it.
AND A BUG OF MINE, found by looking for existing code: knownUser.js had grown a
`require('/models/lib/accountLockout')`. A Meteor package is compiled separately
from the app and cannot import app modules - no other package here reaches
across that boundary. The check is inlined and a test fails if the import comes
back.
Thanks to xet7 !
Moving the lockout counter to one per (user, source address) broke three readers
that were still looking at the flat field it replaced: the People table's lock
icon, its unlock click handler, and the lockedUsers methods behind them. Every
account would have shown as unlocked, and no admin could have unlocked one.
That is the "and nowhere else" half of the rule I had just written into
CLAUDE.md, missed on the very next fix. The negative test now fails if anything
reads the flat field again.
models/lib/accountLockout.js is the one place that knows the shape - locked or
not, since when, how many addresses and how many failures between them - so the
client helper, the click handler and the server methods cannot drift apart
again. Admin Panel / People / People answers WHY as well as whether: how many
addresses were locked out of the account and how many failures they made.
WHICH addresses is in Admin Panel -> Problems, where it is a tally rather than a
field on every user document.
Mongo cannot ask "which accounts are locked" over dynamically-named
subdocuments without an aggregation, so a DISPLAY field - lockedUntil - is
written beside the per-address state for that query alone. It is not the
counter: the decision stays per address, and a test fails if the decision or the
scope ever reads it, because a field that says "this ACCOUNT is locked" is the
vulnerability that was just fixed. Unlocking one address clears it only when no
other address is still locked.
Thanks to daniais and xet7 !
Two rules in CLAUDE.md, both learned from fixes in this repository rather than
proposed in the abstract.
A TEST AND A NEGATIVE TEST, written so the fault cannot exist ANYWHERE in the
codebase rather than only where it was reported. A test that pins one call site
leaves the same mistake free to live in the other five, and that is how most of
these arrive: SignupBleed's guard read an option nothing sets and the same shape
sat in a second endpoint; the source-map trim was safe on the client and fatal
on the server. So the test proves the fix does what it claims - driving the
decision itself where it can, as arithmetic, reproducing the reporter's attack
exactly - and the negative test proves the fault is GONE rather than moved, by
searching the tree for the shape of it and asserting nothing matches. A test
that parses a source file is a real test here: it is what makes "and nowhere
else" checkable at all.
AND AN ATTEMPT HAS TO BE VISIBLE in Admin Panel -> Problems, wherever the fix
denies an operation and the denial can be attributed. That is the difference
between a hole that is closed and one that is closed and watched. The catalog
key, the wrapped record() call on the refusal path, and the rule that only an
ATTEMPT is logged and never ordinary use - a log that fills with normal traffic
hides the one line that mattered, which is why HashBleed deliberately has no
key.
JamBleed did not meet the second rule when it was committed: the catalog entry
was there and nothing ever wrote to it. It does now. A Meteor package cannot
import app code, so the reporter is injected - AccountsLockout takes an
onLockout callback, KnownUser calls it when a lock FIRES, and the app passes one
that writes a security-log event. On the lock only, not on every refused attempt
during it, or an attacker could fill Problems by holding down a key.
There are TWO construction sites - startup and the Admin Panel settings reload -
and a reload that dropped the reporter would stop recording attempts on a
running server while the guard kept working, which is the worst version of this:
nobody can see it working. So the negative test walks server/ and fails on any
`new AccountsLockout({...})` without onLockout, present or future.
Thanks to daniais and xet7 !
GHSA-rf3w-rj48-jxcc, reported by daniais. wekan-accounts-lockout kept ONE
counter per user - services.accounts-lockout.failedAttempts - with no notion of
where the attempts came from. Any unauthenticated attacker who knew a username
could spend three wrong passwords and lock that account out FROM EVERY ADDRESS,
repeatably, for as long as they cared to keep going. Usernames are public in
normal WeKan use, so choosing a target was trivial, and an administrator was as
easy to lock out as anyone else. Reproduced on v10.91:
attacker, address A : Incorrect / Incorrect / Too many attempts
victim, address B : (correct password) Too many attempts
Affected from v10.59, and not before, for a reason worth keeping in view: the
flat counter is much older, but until the LockoutBleed fix
(GHSA-2g94-9x3m-hv37) the hooks gated on English error strings that Meteor's
ambiguousErrorMessages had already rewritten, so the counter never moved and no
account ever locked. Making the lockout WORK is what made this reachable. A fix
that turns on a mechanism inherits whatever that mechanism gets wrong.
TWO FAULTS, and the second is the one that hurts:
1. the counter was global, so an attacker's failures were charged to the
victim's account rather than to the attacker's address;
2. a CORRECT password was refused while the lock held, and counted as a
further failure on the way. The old code allowed an attempt only when
there was no error AND no lock, so the owner typing the right password
fell through to the same throw as the attacker.
Both are fixed in the decision itself, which is now a pure module:
* the counter is per (user, source address). The address comes from
X-Forwarded-For under HTTP_FORWARDED_COUNT - the same rule
server/lib/loginAttemptThrottle.js uses, so a lockout and a throttle cannot
disagree about who somebody is - and only the position `hops` from the right
is read, so a forged header cannot pick its own bucket. The key is a SHA-256
prefix: an IPv4 address is all dots and cannot be a Mongo field name, and a
locked account should not carry a list of the addresses that attacked it.
* a correct password is allowed FIRST, before anything reads the lock, and
clears the state behind it. The lock exists to stop guessing; somebody who
did not have to guess has proved they are not who it is for. It also clears
the pre-fix flat fields, so an account left locked by the old counter is
freed by its owner's next correct login rather than by a wait with no
visible end.
Hammering during a lock no longer extends it either - otherwise the denial of
service returns inside the mechanism meant to stop it.
The three methods that wrote the flat counter are removed rather than left
unreachable, and a test fails if a flat write appears in the hook again.
tests/lockoutPerSourceAddress.test.cjs is 15 tests, driving the decision as
arithmetic rather than through a server: the reported attack, the correct
password during a lock, that the lock still fires and still expires, the
forwarded-header rules, and that malformed state reads as "nothing yet" rather
than throwing - a lockout that threw on an unexpected document would lock
everybody out of a database that had one.
Thanks to daniais and xet7 !