Skip to content

fix: a lockout stops wrong keys, never the right one; failures expire - #67

Merged
alexeybe1kin merged 6 commits into
mainfrom
fix/lockout-after-key
Nov 13, 2026
Merged

alexeybe1kin merged 6 commits into
mainfrom
fix/lockout-after-key

Conversation

@alexeybe1kin

Copy link
Copy Markdown
Collaborator

Hunt findings memorygate-1 F10 and memorygate-2 F12 (auth; Claude-written).

Every key check refused before verifying the key: five wrong keys from one address locked out every caller at that address for 300 s, the right key included. Anyone behind a proxy, on the host network or in the same container network could lock the others out. The failure count also never expired (four bad keys now and one next month made a lock).

Now auth_settings_service.attempt(scope, valid) runs after the key check, at all six call sites: admin key, read keys, listener keys, change-key, rotate-key and the current-key confirmations.

  • A right key always passes and clears the count.
  • A wrong one is counted, and refused (429) while the scope is locked.
  • Failures older than 15 minutes no longer count.

Why this is safe: admin keys are at least 16 characters and stored keys at least 14, and read keys are PBKDF2-hashed, so online guessing was never what the lockout stood between. A lockout that also blocks the right key mostly lets a bad caller deny the good ones.

Tests: tests/test_lockout_after_key.py, 3 tests (2 fail on main). test_memory_reset_service's lock test now asserts the new rule (wrong keys locked, the right key still resets). Locally: every auth/lockout-touching test file, 229 passed; ruff and types ok.

@alexeybe1kin
alexeybe1kin merged commit bcf24bb into main Nov 13, 2026
3 checks passed
@alexeybe1kin
alexeybe1kin deleted the fix/lockout-after-key branch November 13, 2026 11:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant