Skip to content

fix(auth): use configured Argon2 params on signup and user create - #14101

Merged
ArnabChatterjee20k merged 8 commits into
mainfrom
fix/14099-proof-for-password-params
Oct 5, 2026
Merged

ArnabChatterjee20k merged 8 commits into
mainfrom
fix/14099-proof-for-password-params

Conversation

@cursor

@cursor cursor Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Account signup, Users API create/update password, and login algo-rehash were constructing a fresh ProofsPassword() / Argon2 with library defaults (64 MiB / time 4 / threads 3) instead of using the injected proofForPassword resource (7 MiB / time 5 / threads 1 from app/init/resources/request.php).

This wires those paths through the shared resource so newly created and rehashed passwords use the configured Argon2 parameters consistently with recovery / password-update flows that already did.

Login now also rehashes Argon2 passwords whose costs differ from the configured ones (password_needs_rehash() on the stored hash, not hashOptions), so users already hashed at 64 MiB / 4 / 3 converge on their next login instead of keeping the expensive hash until they change their password.

Test Plan

  • Create a user via POST /v1/account and confirm stored hashOptions match memoryCost=7168, timeCost=5, threads=1 (or the PHC string m=7168,t=5,p=1).
  • Create a user via POST /v1/users with a plaintext password and confirm the same options.
  • Update a user password via PATCH /v1/users/{id}/password and confirm the same options.
  • Log in with a user whose stored hash algo differs so rehash runs, and confirm the rewritten hash uses the configured options.
  • Log in with an imported Argon2 user whose costs differ ($argon2i$v=19$m=20,t=3,p=2$…) and confirm the hash is rewritten to m=7168,t=5,p=1.

Related PRs and Issues

Checklist

  • Have you read the Contributing Guidelines on issues?
  • If the PR includes a change to an API's metadata (desc, label, params, etc.), does it also include updated API specs and example docs?
Open in Web View Automation 

Sign-up, Users API create/update password, and login rehash were instantiating
a fresh ProofsPassword()/Argon2 with library defaults (64 MiB/4/3) instead of
the injected proofForPassword (7 MiB/5/1). Wire those paths through the shared
resource so all hashes match the configured parameters.

Fixes #14099

Co-authored-by: chiragaggarwal5k <[email protected]>
@cursor
cursor Bot requested a review from ChiragAgg5k October 5, 2026 03:33
@cursor
cursor Bot marked this pull request as ready for review October 5, 2026 03:33
@ghost

ghost commented Oct 5, 2026 •

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

The new fixture covers the previously missing cost-only rehash case, with no additional defects found in the incremental changes.

Uses the configured password-proof resource for account signup, Users API creation and password updates, and login rehashing. Login also refreshes Argon2 hashes with outdated variants or costs. E2E coverage checks persisted settings and successful login after rehashing, now including an Argon2id fixture with the previous signup costs.

Latest changes: Adds an old-cost Argon2id fixture to the login rehash regression test and updates the expected user count.

Verdict New comments Fixed Still open
💬 Commented 0 1 0

Note

@cursor[bot] does not have write access to this repository, so Hansi does not approve automatically. A maintainer can review and approve.

📂 Walkthrough · 6
File Change
app/controllers/api/account.php Uses configured hashing for signup and login upgrades for differing algorithms, variants, or costs.
src/Appwrite/Platform/Modules/Users/Base.php Accepts the configured password proof for shared user creation.
src/Appwrite/Platform/Modules/Users/Http/Users/Create.php Injects and passes the configured proof for plaintext passwords.
src/Appwrite/Platform/Modules/Users/Http/Users/{Argon2,Bcrypt,MD5,PHPass,SHA,Scrypt,Scrypt/Modified}/Create.php Passes the shared creation dependency while preserving imported hashes.
src/Appwrite/Platform/Modules/Users/Http/Users/Password/Update.php Uses configured hashing for replacement passwords.
tests/e2e/Services/Users/UsersBase.php Checks configured hashing across creation, updates, and login upgrades, including old-cost Argon2id hashes.
✅ Fixed since the last review · 1
  • Cover cost-only upgrades of existing Argon2id hashes · tests/e2e/Services/Users/UsersBase.php:622

Reviewed the commits since b3e7782 · Details · Comment @hansi-codes review to re-run, or mention @hansi-codes with a question.

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Tier A · See the inline comments. Summary

cursoragent and others added 2 commits October 5, 2026 03:37
…hash

Adds E2E coverage so plaintext user create, password update, and login
algo-rehash persist memory 7168 / time 5 / threads 1 from proofForPassword
instead of the Argon2 library defaults.

Co-authored-by: chiragaggarwal5k <[email protected]>
ghost
ghost previously requested changes Oct 5, 2026

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Tier B · 2 blocking findings to address. Summary

Comment thread tests/e2e/Services/Users/UsersBase.php Resolved
Comment thread tests/e2e/Services/Users/UsersBase.php Resolved
Login only rehashes when the stored algorithm name differs from argon2, so
the imported argon2i fixture keeps m=20,t=3,p=2. Assert preservation there
and configured costs only for algorithms that were actually upgraded.

Co-authored-by: chiragaggarwal5k <[email protected]>
@github-actions

github-actions Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → fix/14099-proof-for-password-params (after).

Metric Before After Change
🚀 Requests/sec 198.58 206.23 ⚪ +3.9%
⏱️ Latency P50 85.26 ms 84.25 ms ⚪ -1.2%
⏱️ Latency P95 206.77 ms 192.4 ms 🟢 -7%
Per-scenario breakdown & investigation details

Metrics below reflect the current branch (after). Δ P95 compares against the base.

Scenario P50 (ms) P95 (ms) Requests RPS Δ P95 (ms)
API total 84.25 192.4 12,882 206.23 -14.37
Account 156.68 293.27 678 11.25 -24.5
TablesDB 82.56 154.18 7,006 113.89 -18.45
Storage 76.69 167.26 3,390 57.19 -15.23
Functions 116.12 223.42 1,808 31.14 -3.36

Top API waits (after)

API request Max wait (ms)
account.prefs.update 493.48
functions.variables.update 405.58
account.get 365.79
account.name.update 364.63
storage.buckets.create 340.41

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Tier S · Looks good to merge. Summary

Login only rehashed when the algorithm differed, so users hashed with
the library default (64 MiB, 4 passes, 3 threads) kept that cost until
they changed their password. Compare the stored hash against the
configured costs with password_needs_rehash(), which reads them from
the hash itself rather than from hashOptions.

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Tier A · See the inline comments. Summary

Comment thread tests/e2e/Services/Users/UsersBase.php Resolved

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Tier S · Looks good to merge. Summary

@HarshMN2345

Copy link
Copy Markdown
Member

@hansi-codes re-review and give tick if all good

@ghost

ghost commented Oct 5, 2026

Copy link
Copy Markdown

✅ Re-reviewed; no new blocking issues found.

  • Login checks the stored hash for outdated Argon2 costs and rehashes using the configured resource (app/controllers/api/account.php:1112–1125).
  • E2E coverage includes the old-cost Argon2id user, verifies persisted costs, and checks login again after rehashing (tests/e2e/Services/Users/UsersBase.php:612–658).

This is a code-review tick, not confirmation of passing checks: I haven’t run the tests, and the benchmark report is inconclusive.

@HarshMN2345

Copy link
Copy Markdown
Member

✅ Re-reviewed; no new blocking issues found.

  • Login checks the stored hash for outdated Argon2 costs and rehashes using the configured resource (app/controllers/api/account.php:1112–1125).
  • E2E coverage includes the old-cost Argon2id user, verifies persisted costs, and checks login again after rehashing (tests/e2e/Services/Users/UsersBase.php:612–658).

This is a code-review tick, not confirmation of passing checks: I haven’t run the tests, and the benchmark report is inconclusive.

@hansi-codes give a tick

@ghost

ghost commented Oct 5, 2026

Copy link
Copy Markdown

✅ No blocking issues found in the code review. Tests remain unverified.

@ArnabChatterjee20k
ArnabChatterjee20k merged commit b707cb0 into main Oct 5, 2026
51 checks passed
abnegate added a commit that referenced this pull request Oct 5, 2026
Merges main a2cca78 (#14009, #14106, #14117, #14115, #14119, #14114,
#14101, #14125, #14129, #14127) so cloud#5410 can require a train head
that contains main at or after 0ed7232.

Conflicts: none.

Database 8.0 port: none needed. Main's new code only uses Document
getAttribute/setAttribute and Query::equal/lessThan/orderAsc/limit
(Tasks/Interval.php), all unchanged in database 8.0; no removed
Database::* constants, config collections, or model magic reads.
composer.json and composer.lock are untouched by main, so the train's
database and migration pins stay as they are.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.

🐛 Bug Report: Sign-up ignores the configured Argon2 parameters

4 participants