Repository navigation
fix(account): answer an unknown user like a wrong secret on token confirmation - #15990
Conversation
…firmation Co-Authored-By: Claude Opus 5.5 <[email protected]>
Code review
This updates account recovery and verification confirmation handlers to return Latest changes: The latest commit updates the phone-verification E2E case to expect status 401 and the Walkthrough (6)
Reviewed the commits since Tip Comment |
… phone verification Co-Authored-By: Claude Opus 5.5 <[email protected]>
Security rulesWARNING (1 new) — review signal only; does not fail the job.
|
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|

What does this PR do?
The public token-confirmation routes answered differently for an unknown user and for a wrong secret:
404 user_not_foundagainst401 user_invalid_token. A caller holding no secret could use that difference to learn which user IDs exist, and so which addresses have accounts, given the ID a token-creation call returns.An unknown user now gets
401 user_invalid_token, the same answer as a wrong secret, on:PUT /v1/account/recoveryPUT /v1/account/recovery/otpPUT /v1/account/verifications/emailPUT /v1/account/verifications/email/otpPUT /v1/account/verifications/phoneThe session-confirmation routes already answered this way. A valid secret still works exactly as before.
This closes the confirmation half of https://github.com/appwrite/appwrite/security/code-scanning/4958. The other half isn't covered here: magic-URL and email/phone OTP token creation return the real user ID when the address already has an account, and clients need that ID to create the session. That change to the login API is tracked separately.
Test Plan
The four e2e cases that used an unknown user ID on these routes (verification, recovery, email OTP verification, recovery OTP in
AccountCustomClientTest) now expect401with typeuser_invalid_token.Pint, Rector and PHPStan pass on the changed files.
Verification
AccountCustomClientTest(verification, recovery, email OTP verification, recovery OTP) passed in CI run 45356568256, in Tests / E2E / PostgreSQL (dedicated) / Account.accountcommands did not reach the temporary project's users: a user I had just created there was reported as not found.🤖 Generated with Claude Code
Related: appwrite-labs/cloud#6666