Skip to content

fix(auth): stop PersonalData from mutating its own state while validating - #13532

Merged
HarshMN2345 merged 6 commits into
mainfrom
fix/personal-data-validator-state
Sep 8, 2026
Merged

HarshMN2345 merged 6 commits into
mainfrom
fix/personal-data-validator-state

Conversation

@HarshMN2345

@HarshMN2345 HarshMN2345 commented Sep 8, 2026 •

Copy link
Copy Markdown
Member

Closes #11895

What does this PR do?

Lowercases local copies of personal data during non-strict password validation instead of modifying the validator's stored fields. Password acceptance behavior stays the same.

Test Plan

The existing strict and non-strict validator tests pass: 2 tests, 47 assertions. The test-only subclass that exposed protected fields was removed; the suite retains its public validation assertions. Pint and PHP syntax checks passed.

…ting

isValid() lowercased the userId, email, name and phone properties in place
whenever strict mode was off, so the validator carried state from one call
into the next. Lowercase the values into locals instead, leaving the
instance reusable and side-effect free.
@greptile-apps

greptile-apps Bot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR prevents non-strict personal-data password validation from mutating the validator’s stored fields.

  • Copies user ID, email, name, and phone into local variables before normalization.
  • Preserves the existing strict and non-strict password acceptance behavior.

Confidence Score: 5/5

The PR appears safe to merge, with no outstanding correctness or security findings.

The validation logic preserves the prior comparisons while eliminating mutation of stored validator state. The previous test-related finding was manually resolved without explanation and does not remain outstanding.

Important Files Changed

Filename Overview
src/Appwrite/Auth/Validator/PersonalData.php Validation now normalizes local copies of personal data rather than mutating object state, while retaining the existing comparisons.

Reviews (6): Last reviewed commit: "Merge branch 'main' into fix/personal-da..." | Re-trigger Greptile

@github-actions

github-actions Bot commented Sep 8, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → fix/personal-data-validator-state (after).

Metric Before After Change
🚀 Requests/sec 185.38 171.46 🔴 -7.5%
⏱️ Latency P50 93.56 ms 98.88 ms 🔴 +5.7%
⏱️ Latency P95 220.82 ms 243.51 ms 🔴 +10.3%
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 98.88 243.51 10,773 171.46 +22.69
Account 213.16 387.88 567 9.38 +45.43
TablesDB 93.81 176.82 5,859 95.46 +12.68
Storage 95.04 200.18 2,835 47.92 +12.78
Functions 154.55 296.48 1,512 26.22 +19.86

Top API waits (after)

API request Max wait (ms)
account.name.update 554.4
functions.create 512.41
account.prefs.update 440.22
functions.variables.create 439.3
storage.files.create 423.91

Asserting only isValid() results could not catch the regression: lowercasing in
place is idempotent, so the mutating version returned the same answers. Read the
fields back through a named subclass instead, and use a password long enough to
clear the password rules so validation reaches the block that mutated them.
The mutation is invisible through isValid(): lowercasing in place is
idempotent, so the mutating version answers every public call identically.
Behaviour-only assertions pass against the code this PR removes, which leaves
the fix unguarded.

Read the fields back through a named subclass, the same way ActivateRulesTest
reaches a protected member. AGENTS.md rules out reflection, not subclasses.
@HarshMN2345
HarshMN2345 merged commit 9908be9 into main Sep 8, 2026
6 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.

Validator mutates internal state in PersonalData::isValid causing side effects

2 participants