Repository navigation
[M2.2c2-fix] Stop unauthenticated account lockout and key IPv6 by /64 - #97
Merged
Merged
Conversation
5 of 6 tasks
samuelmbabhazi
force-pushed
the
fix/m2.2-throttle-lockout
branch
from
November 5, 2026 13:54
bed32ad to
9e3b132
Compare
samuelmbabhazi
added a commit
that referenced
this pull request
Nov 5, 2026
…#101) ## Task Review follow-up for #44 (M2.2c1). Refs #21 ## What changed **API** - `POST /auth/verify` takes `{ token, password }` (`VerifyEmailDto`). Verification checks the password against the stored hash, with Argon2id work outside any lock or transaction. Under the user lock it then rechecks that the hash did not change in the meantime, before consuming the link and activating the account. - A wrong password does not consume the verification link. - Password reset (request and confirm) accepts pending accounts as well as active ones. A reset on a pending account activates it (`identity.email_verified` then `identity.password_reset`), invalidates outstanding verification links, and advances the security version as before. - `openapi.json` and the api-client regenerated. **Web** - The verification page asks for "Password you chose when signing up" (`autocomplete=current-password`) and links to password reset for people who did not create the account or forgot the password. **Docs and tests** - SPEC 8.1 and a new THREAT_MODEL row (S4) describe the defence. - New integration test for the full attack: an attacker registers the owner's address with their own password. The owner cannot activate that password with the link, claims the account through reset, and afterwards the attacker's password and verification link are both rejected. - New integration test: a wrong password does not consume the link. - Existing unit, integration and browser flows now send the password with the code. ## Why Account pre-hijacking: 1. An attacker registers `[email protected]` with their own password. The account stays pending and the verification link goes to the victim. 2. A later signup by the victim was silently ignored, and reset refused pending accounts. 3. The victim clicked the link, which activated the attacker's password. 4. The attacker could then log in, enroll MFA and create API tokens. Enrolling MFA would lock the owner out even after a reset. ## How it was tested - `nx run-many -t lint typecheck test build -p web api` in a clean worktree: 12 tasks pass. - `pnpm gen:openapi` and `pnpm gen:api-client`: the committed output is the regenerated output. - Integration and browser tests could not run locally (no Docker in the sandbox), and GitHub Actions is blocked by the account spending limit. CI must pass before merge. ## Security considerations - Contract change on `POST /auth/verify`: the password is now required. Only the bundled web UI calls this endpoint, and it is updated in this PR. - The verify endpoint keeps its `verify` attempt limit (per network and account after #97). No new enumeration signal: every failure returns the same 401. ## Checklist - [x] Lint, typecheck, tests and build pass locally - [x] Malicious-scenario integration test added - [x] No new shell invocation and no new secret exposure path - [x] Audit events emitted for the new activation path - [x] SPEC and THREAT_MODEL updated - [ ] CI green (blocked by billing)
Closed
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.
Task
Review follow-up for #45 (M2.2c2). Refs #21
What changed
source).clientNetwork).succeeded(subject, ip)clears the account delay and that network's account quota after a successful login.Why
Anyone could lock any known account out. About 10 failed logins every 15 minutes, from any address, kept the per-account bucket exhausted, so the real owner got 429 indefinitely. A single IPv6 /64 also gave an attacker effectively unlimited per-IP quota.
How it was tested
clientNetwork(IPv4, mapped, compressed IPv6, zone ids, non-addresses).identity-throttle.integration.spec.ts):nx run-many -t lint typecheck test -p apiin a clean worktree: all pass. Integration tests could not run locally (no Docker in the sandbox), and GitHub Actions is blocked by the account spending limit. CI must pass before merge.Security considerations
Trade-off: a distributed guesser is no longer hard-capped per account. Each network gets at most 10 tries per 15 minutes per account and every attempt on the account is spaced by up to 8 s, which still bounds online guessing against Argon2id-hashed passwords. This follows OWASP guidance to avoid hard lockouts.
Checklist