Repository navigation
Description
π Reproduction steps
- Create a user with
POST /v1/account(orPOST /v1/users) and look at the storedhash/hashOptionsor the PHC string:$argon2id$v=19$m=65536,t=4,p=3$β¦. - Change the password of a user with
PATCH /v1/account/password(or go through recovery):$argon2id$v=19$m=7168,t=5,p=1$β¦.
π Expected behavior
All password hashes use the parameters of the proofForPassword resource (app/init/resources/request.php L90βL101: memory 7168 KiB, time 5, threads 1).
π Actual Behavior
Some paths use the injected proofForPassword, others create a fresh new ProofsPassword() / new Argon2() and get the class defaults of Utopia\Auth\Hashes\Argon2 (memory 65536 KiB, time 4, threads 3; on main in packages/auth/src/Hashes/Argon2.php L17βL19):
| Path | Parameters |
|---|---|
POST /v1/account (account.php L376) |
64 MiB / 4 / 3 |
POST /v1/users (Users/Base.php L102) |
64 MiB / 4 / 3 |
PATCH /v1/users/{userId}/password (Users/Password/Update.php L114) |
64 MiB / 4 / 3 |
| rehash on login when the algorithm differs (account.php L1087) | 64 MiB / 4 / 3 |
PATCH /v1/account/password, recovery, users created via anonymous/magic URL/email token/OAuth/team invite |
7 MiB / 5 / 1 |
Login verifies with the parameters stored in the hash and only rehashes when the algorithm differs, so users who signed up keep the expensive hash until they change their password themselves. main has the same code.
Cost of one password_verify() inside the 2.3.0 API container (4 vCPU): 64 MiB/4/3 58 ms wall, β 150 ms CPU (three threads); 7 MiB/5/1 12 ms. The Swoole worker is blocked for the whole time.
Load test through the API (two API nodes with 4 vCPU each, Postgres on a third node, 1,500 imported users per group via POST /v1/users/argon2 with a pre-computed hash of the same password, logins round-robin, 20 s per step, two runs):
| Hash of the users | 16 connections | 64 connections | p50 (16) | CPU API nodes |
|---|---|---|---|---|
| 64 MiB / 4 / 3 (sign-up, Users API) | 49 / 51 logins/s | 51 / 51 logins/s | 314β322 ms | 100 % |
7 MiB / 5 / 1 (proofForPassword) |
200 / 220 logins/s | 266 / 212 logins/s | 68β77 ms | 82β98 % |
Sign-up itself is capped the same way: 46β49 POST /v1/account per second for both nodes together, independent of concurrency (8β64), API CPU 96β100 %.
π² Appwrite version
2.3.0 (main unchanged)
π» Operating system
Linux (Debian 12), Docker
π§± Your Environment
Self-hosted, two API nodes (4 vCPU each), Postgres and Redis on a third node, abuse limits disabled for the test.
π‘ Suggested fix
Inject proofForPassword in POST /v1/account, the Users module (Base::createUser(), password update) and the login rehash instead of constructing a default ProofsPassword/Argon2. If 64 MiB/4/3 is the intended setting, set it in proofForPassword instead, so all paths agree. Optionally rehash on login when the stored hashOptions differ from the current ones (not only when the algorithm differs), so existing users converge.
Context: #10667 reset the options once before; utopia-php/auth 86927a8 ("Fix option keys", Oct 2025) is the change that made the options actually reach password_hash().
π Have you spent some time to check if this issue has been raised before?
- I checked and didn't find a similar issue
π’ Have you read the Code of Conduct?
- I have read the Code of Conduct
Activity
[-]π Bug Report: Sign-up and the Users API hash passwords with 64 MiB / t=4 / p=3 instead of the configured Argon2 parameters (7 MiB / t=5 / p=1) β logins of these users cost ~5Γ the CPU[/-][+]π Bug Report: Sign-up ignores the configured Argon2 parameters[/+]fix(auth): use configured Argon2 params on signup and user create