Files
romm/backend/handler/auth/middleware
Sam Dornan 242af819ad fix(security): revoke the target account's sessions on a credential change
`update_user` cleared only the caller's session, so an admin resetting a
compromised account left every attacker session on it live. It now revokes the
sessions of the account the change was applied to, keyed on the username the
account held before the update, and still clears the caller's own session when
they are that account. `set_user_new_password` already did this; the update
endpoint was the gap.

A revocation could also be undone by any request already in flight: the session
middleware rewrote its copy unconditionally on the way out. An existing session
now refreshes with `SET ... XX`, so a record deleted mid-request is not
recreated, and the response clears the cookie instead.

`clear_user_sessions` also builds its delete keys from decoded members. The
configured clients pass `decode_responses=True`, so this changes nothing in
production, but the key is now right for any client, and the whole set goes in
one `delete` rather than a call per session.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NouZquWDxNBqxYyu2E2GF8
2026-09-20 15:15:39 +00:00
..