fix: a Kanban user's own password change signs out their other sessions and counts wrong current passwords (security area 3)
All checks were successful
Build and deploy / Validate source (push) Successful in 5s
Build and deploy / Integration suite on a real stack (push) Successful in 7m47s
Build and deploy / Secret scan and release gate (push) Successful in 5s
Build and deploy / Publish images (push) Successful in 1m2s

/api/operator/me/password left every other session of the account valid for
up to 8 h, and a wrong current password was never counted, so a session left
open could guess it. Now, as a customer's change already does: the throttle
and login_failed of the sign-in, and the other sessions of the account end.
users_test proves both; the Usuários admin edit already ended sessions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-12-01 14:20:23 -03:00
parent 52fc90cbcd
commit 0f833fa1fa
2 changed files with 30 additions and 4 deletions

View File

@@ -2,6 +2,7 @@
Run inside the API container: python -m tests.users_test
"""
import hashlib
import secrets
import time
from urllib.request import Request, urlopen
@@ -318,8 +319,24 @@ def run():
seller.call('/operator/me/password', {'current': PASSWORD, 'new': 'sete-77'}, expected=422)
seller.call('/operator/me/password', {'current': PASSWORD, 'new': 'oito-888'})
seller = signed_in(emails['vendedor'], 'oito-888')
# The new password signs out the account's other sessions, and keeps
# this one (as a customer's, security area 3, 01/12).
other_device = signed_in(emails['vendedor'], 'oito-888')
seller.call('/operator/me/password', {'current': 'oito-888', 'new': 'outra-senha-de-teste'})
seller.call('/operator/me')
other_device.call('/operator/me', expected=401)
signed_in(emails['vendedor'], 'outra-senha-de-teste').call('/operator/me')
# A session left open cannot guess the current password: wrong ones count
# against the sign-in and stop at 10, as a failed sign-in does. The count
# starts from zero here: the suites before this one share the address.
with db.connect() as c:
c.execute('DELETE FROM dtf_local.login_attempts')
for _ in range(10):
seller.call('/operator/me/password', {'current': 'errada', 'new': 'qualquer-123'}, expected=403)
seller.call('/operator/me/password', {'current': 'errada', 'new': 'qualquer-123'}, expected=429)
with db.connect() as c:
c.execute('DELETE FROM dtf_local.login_attempts WHERE key=%s', (hashlib.sha256(
('auth-account|operator:' + emails['vendedor']).encode()).hexdigest(),))
# A second Têxtil machine. Who is on each machine is who chose it after
# signing in: Usuários only shows it (item 12).