fix(staff): check every moderator panel action, end panel sessions with the rest

From the 18 October security audit (S-9, S-10).

- the moderator panel only refused a role the actions in its permission
  map. hardware bans and lifting them were missing from it, and answering
  ban appeals (which lifts the ban, the address's too), name requests,
  paintings and reports were checked for player.view alone, so a Helper
  could do all of them. each now needs its own permission (address.ban,
  player.ban, player.names, items.approve, player.warn), with the rank
  check the other actions have, and an action missing from the map is
  refused. the page hides what the role cannot do.
- a new password, "Sign out everywhere", locking the account, turning 2FA
  off or deleting the account now also ends its moderator panel sessions,
  as the admin panel's reset already did, so a stolen panel session does
  not outlive them.
- test/staff.js covers both, and fails without either fix.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
SnipzilandClaude Opus 5.5 committed 2026-10-18 13:17:58 -04:00
1 parent a359371a48
commit 1e365b95c5
6 files changed
+181 -33

No files matched your search

+12
View File
@@ -111,6 +111,13 @@ const signOutOthers = (account, req) => {
}
};
// ends the account's sessions in the moderator panel (lib/modpanel.js, which
// needs this file, so it is asked for when used): with the others when the
// password changes or the owner signs out everywhere, and when the account
// locks or turns 2FA off, so that a session from before does not come back
// with it.
const endStaffSessions = account => require("./modpanel.js").forget(account);
const twoStepOf = account => ({on: totp.isOn(account), since: account.totp ? account.totp.since : null,
recoveryLeft: account.totp ? account.totp.recovery.length : 0, devices: totp.freshDevices(account).length, deviceDays: totp.DEVICE_DAYS});
@@ -292,6 +299,7 @@ const act = (account, body, req, from, res) => {
}
world.moderation.actions.kick(account);
signOutOthers(account, req);
endStaffSessions(account);
console.log(`[account] "${logText(account.username)}" changed their password from ${logText(from.address)}`);
return {ok: "Password changed."};
}
@@ -311,6 +319,7 @@ const act = (account, body, req, from, res) => {
// out of the game now, and no saved sign-in gets back in.
accounts.revokeTokens(account);
world.moderation.actions.kick(account);
endStaffSessions(account);
}
accounts.save(account);
console.log(`[account] "${logText(account.username)}" ${logText(account.locked ? "locked" : "unlocked")} from ${logText(from.address)}`);
@@ -364,6 +373,7 @@ const act = (account, body, req, from, res) => {
}
totp.turnOff(account);
accounts.save(account);
endStaffSessions(account);
res.setHeader("Set-Cookie", cookieHeader("", 0, DEVICE_COOKIE));
console.log(`[account] "${logText(account.username)}" turned two-step sign-in off from ${logText(from.address)}`);
return {ok: "2FA is off."};
@@ -467,6 +477,7 @@ const act = (account, body, req, from, res) => {
accounts.save(account);
world.moderation.actions.kick(account);
signOutOthers(account, req);
endStaffSessions(account);
return {ok: "Signed out everywhere."};
// for good: the password again, and the username typed out.
case "delete": {
@@ -479,6 +490,7 @@ const act = (account, body, req, from, res) => {
const name = account.username;
world.disconnect(account);
signOutOthers(account, null);
endStaffSessions(account);
erase(account);
console.log(`[account] "${logText(name)}" deleted their account from ${logText(from.address)}`);
return {ok: "Account deleted.", deleted: true};