Repository navigation
fix: a lockout stops wrong keys, never the right one; failures expire - #67
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.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.