Skip to content

fix(users): reject imported Argon2 hashes that can never verify - #14924

Merged
ChiragAgg5k merged 1 commit into
mainfrom
fix/argon2-salt-tag-length
Oct 24, 2026
Merged

ChiragAgg5k merged 1 commit into
mainfrom
fix/argon2-salt-tag-length

Conversation

@ChiragAgg5k

@ChiragAgg5k ChiragAgg5k commented Oct 24, 2026 •

Copy link
Copy Markdown
Member

POST /v1/users/argon2 accepted Argon2 hashes that can never be verified, so the import succeeded and every sign-in for that user then failed.

$argon2id$v=19$m=8,t=1,p=1$YQ$YQ        # 1-byte salt and tag
$argon2id$v=19$m=64,t=1,p=16$…          # 4 KiB per lane

Hash\Argon2 now also requires:

Minimum
salt 8 bytes
tag 4 bytes
memory 8 KiB × parallelism

Found while backporting #14825 to 1.9.x (#14910, which ships the same check).

Test

UsersBase::testCreateUserHashLimits gets four new refused hashes. Against the current validator all four are accepted, so the test fails without this fix.

Argon2 needs a salt of at least 8 bytes, a tag of at least 4 bytes and at least 8 KiB of memory per lane. Imports below those bounds were stored, then failed every sign-in.
@luxor-code-review

luxor-code-review Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Review complete. No issues found — approved ✅.


This PR hardens Argon2 hash validation by enforcing the Argon2 reference minimums: an 8-byte salt, a 4-byte hash tag, and a memory cost of at least 8 KiB per lane (m >= 8*p), on top of the existing maxima. The validation math was verified correct against RFC 9106 and the Argon2 reference implementation.

Files Change
src/Appwrite/Auth/Validator/Hash/Argon2.php Adds SALT_MIN, TAG_MIN, and m >= 8*p checks to isValid() alongside existing maximum limits
tests/e2e/Services/Users/UsersBase.php Adds e2e coverage for import of below-minimum Argon2 hashes being rejected

Reviewed commit: 973f2d0

@ghost

ghost commented Oct 24, 2026 •

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

The new validation checks match Argon2's minimum verification requirements, and the E2E test covers each newly rejected case.

The Argon2 hash validator now rejects imported hashes whose decoded salt or tag is below Argon2's minimum lengths, as well as hashes whose memory cost is too small for their parallelism. The Users E2E hash-limit test adds examples for these rejected inputs.

Verdict New comments Fixed Still open
✅ Approved 0 0 0
📂 Walkthrough · 2
File Change
src/Appwrite/Auth/Validator/Hash/Argon2.php Enforces minimum decoded salt and tag lengths and memory per lane.
tests/e2e/Services/Users/UsersBase.php Adds invalid Argon2 hashes covering short salt/tag values and insufficient memory per lane.

Reviewed 973f2d0 · Details · Comment @hansi-codes review to re-run, or mention @hansi-codes with a question.

@ChiragAgg5k ChiragAgg5k self-assigned this Oct 24, 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 S · Looks good to merge. Summary

@github-actions

Copy link
Copy Markdown

Security rules

No new WARNING or ERROR findings from security rules.

6 existing findings tracked in .semgrep/baseline.json
  • php.appwrite.guest-write-without-abuse-limit (3)
  • php.appwrite.secret-compare-timing (1)
  • php.appwrite.weak-secret-env-default (2)

Posted by Checks / Rules. Re-runs update this comment in place. Rule details and baseline: .semgrep/README.md.

@github-actions

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → fix/argon2-salt-tag-length (after).

Metric Before After Change
🚀 Requests/sec 217.75 226.11 ⚪ +3.8%
⏱️ Latency P50 76.69 ms 77.57 ms ⚪ +1.2%
⏱️ Latency P95 188.54 ms 174.19 ms 🟢 -7.6%
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 77.57 174.19 14,079 226.11 -14.35
Account 142 259.26 741 12.26 -23.93
TablesDB 76.81 139.41 7,657 125.15 +8.84
Storage 67.98 164.19 3,705 62.35 -14.2
Functions 104.53 197.01 1,976 33.89 -76.56

Top API waits (after)

API request Max wait (ms)
functions.create 336.48
account.name.update 331.04
functions.variables.update 327.17
functions.variables.create 324.16
account.prefs.update 311.27

@ChiragAgg5k
ChiragAgg5k merged commit ce55e4a into main Oct 24, 2026
69 checks passed
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