Files
wekan/server/methods/lockoutSettings.js
T
Lauri Ojansivu c49d9d8d3e Fix the JamBleed regression: a login lockout never disables the account being guessed.
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 !
2026-10-02 10:31:23 +03:00

53 lines
2.0 KiB
JavaScript

import { Meteor } from 'meteor/meteor';
import { AccountsLockout } from 'meteor/wekan-accounts-lockout';
import { ReactiveCache } from '/imports/reactiveCache';
import LockoutSettings from '/models/lockoutSettings';
// The lockout reporter (and why it names the TARGET): server/lib/lockoutReporter.js.
import { reportLockout } from '/server/lib/lockoutReporter';
Meteor.methods({
async reloadAccountsLockout() {
// Check if user has admin rights
const userId = this.userId;
if (!userId) {
throw new Meteor.Error('error-invalid-user', 'Invalid user');
}
const user = await ReactiveCache.getUser(userId);
if (!user || !user.isAdmin) {
throw new Meteor.Error('error-not-allowed', 'Not allowed');
}
try {
// Get configurations from database
const knownUsersConfig = {
failuresBeforeLockout: (await LockoutSettings.findOneAsync('known-failuresBeforeLockout'))?.value || 3,
lockoutPeriod: (await LockoutSettings.findOneAsync('known-lockoutPeriod'))?.value || 60,
failureWindow: (await LockoutSettings.findOneAsync('known-failureWindow'))?.value || 15
};
const unknownUsersConfig = {
failuresBeforeLockout: (await LockoutSettings.findOneAsync('unknown-failuresBeforeLockout'))?.value || 3,
lockoutPeriod: (await LockoutSettings.findOneAsync('unknown-lockoutPeriod'))?.value || 60,
failureWindow: (await LockoutSettings.findOneAsync('unknown-failureWindow'))?.value || 15
};
// Initialize the AccountsLockout with configuration
const accountsLockout = new AccountsLockout({
knownUsers: knownUsersConfig,
unknownUsers: unknownUsersConfig,
onLockout: reportLockout,
});
// Start the accounts lockout mechanism
accountsLockout.startup();
return true;
} catch (error) {
console.error('Failed to reload accounts lockout:', error);
throw new Meteor.Error('error-reloading-settings', 'Error reloading settings');
}
}
});