Skip to content

[M2.2c1-fix] Stop account pre-hijacking through pending registrations - #101

Merged
samuelmbabhazi merged 3 commits into
mainfrom
fix/m2.2-account-pre-hijacking
Nov 5, 2026
Merged

samuelmbabhazi merged 3 commits into
mainfrom
fix/m2.2-account-pre-hijacking

Conversation

@samuelmbabhazi

Copy link
Copy Markdown
Collaborator

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

Checklist

  • Lint, typecheck, tests and build pass locally
  • Malicious-scenario integration test added
  • No new shell invocation and no new secret exposure path
  • Audit events emitted for the new activation path
  • SPEC and THREAT_MODEL updated
  • CI green (blocked by billing)

@samuelmbabhazi
samuelmbabhazi force-pushed the fix/m2.2-account-pre-hijacking branch from 0b9f92d to ae781ec Compare November 5, 2026 13:58
@samuelmbabhazi
samuelmbabhazi merged commit 77ffc6c into main Nov 5, 2026
2 of 11 checks passed
@samuelmbabhazi
samuelmbabhazi deleted the fix/m2.2-account-pre-hijacking branch November 5, 2026 13:58
@samuelmbabhazi samuelmbabhazi mentioned this pull request Nov 5, 2026
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