Skip to content

fix(users): reject invalid scrypt modified options with 400 - #13553

Merged
HarshMN2345 merged 3 commits into
mainfrom
codex/validate-scrypt-salt
Sep 9, 2026
Merged

HarshMN2345 merged 3 commits into
mainfrom
codex/validate-scrypt-salt

Conversation

@HarshMN2345

@HarshMN2345 HarshMN2345 commented Sep 9, 2026 •

Copy link
Copy Markdown
Member

What does this PR do?

A malformed passwordSalt, passwordSaltSeparator, or passwordSignerKey in POST /v1/users/scrypt-modified passes the route's text validation and causes the hash library to throw an uncaught InvalidArgumentException, returning HTTP 500. Translate invalid hash options into HTTP 400 general_argument_invalid with the library's validation message before creating the user.

The HTTP regression covers a valid import and persisted hash options, malformed Base64 in each option, and the salt/signer key zero-value checks. It also verifies rejected requests do not create users.

Test Plan

Validated against an isolated API container using this branch and the local backing services:

  • docker exec appwrite-scrypt-salt-test /usr/local/bin/test tests/e2e/Services/Users/UsersCustomServerTest.php --filter='testCreateScryptModified|testCreateUserSessionHashed' — 2 tests, 106 assertions passed, including login with imported hashes.
  • The new regression fails against origin/main with HTTP 500 instead of 400.
  • Targeted Pint and PHPStan checks for both changed files passed; git diff --check passed.

Related PRs and Issues

Checklist

@greptile-apps

greptile-apps Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge; no outstanding correctness, security, or repository-rule violations were identified.

Summary

  • Catches hash-library validation failures and translates them to general_argument_invalid.
  • Adds end-to-end coverage for valid imports, persisted hash options, malformed Base64, zero-value inputs, and absence of users after rejected requests.
  • The previously implementation-coupled message assertions have been removed.

Comment thread tests/e2e/Services/Users/UsersBase.php Resolved
@github-actions

github-actions Bot commented Sep 9, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → codex/validate-scrypt-salt (after).

Metric Before After Change
🚀 Requests/sec 259.74 250.58 ⚪ -3.5%
⏱️ Latency P50 68.31 ms 69.82 ms ⚪ +2.2%
⏱️ Latency P95 155.16 ms 159.92 ms ⚪ +3.1%
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 69.82 159.92 15,789 250.58 +4.76
Account 134.1 242.47 831 13.78 -2.21
TablesDB 67.58 123.73 8,587 138.75 +8.95
Storage 63.9 142.72 4,155 68.92 +7.22
Functions 102.54 191.07 2,216 37.33 +5.43

Top API waits (after)

API request Max wait (ms)
functions.variables.create 461.14
account.name.update 399.78
account.prefs.update 342.77
functions.variables.update 335.98
functions.variables.delete 334.72

@HarshMN2345
HarshMN2345 merged commit 0979ee9 into main Sep 9, 2026
46 checks passed
@ChiragAgg5k ChiragAgg5k mentioned this pull request Sep 10, 2026
2 of 4 tasks
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.

2 participants