Skip to content

fix(security): count MFA factors against the impersonator's own settings - #14017

Merged
HarshMN2345 merged 4 commits into
mainfrom
fix/impersonation-operator-mfa
Sep 30, 2026
Merged

HarshMN2345 merged 4 commits into
mainfrom
fix/impersonation-operator-mfa

Conversation

@HarshMN2345

@HarshMN2345 HarshMN2345 commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

While impersonating, the MFA check counted the impersonator's session factors against the target's MFA settings. As a result:

  • an impersonator whose MFA requires a second factor could pass with a password-only session by naming a target without MFA
  • an impersonator with a complete session was refused when the target had MFA on

The session always belongs to $user, who stays the impersonator, so the requirement now comes from $user. Impersonation also needs a session to count factors on, so a JWT bound to no session is refused.

Tests: testImpersonationRequiresImpersonatorFactors and testImpersonationIgnoresTargetFactors.

While impersonating, the shared API hook counted the impersonator's session
factors against the target's MFA settings. An impersonator whose own MFA
required a second factor could pass with a password-only session by naming a
target without MFA, and an impersonator with a complete session was refused
when the target had MFA on.

The session always belongs to $user, who stays the impersonator, so the
requirement now comes from $user through User::sessionNeedsMoreFactors().
@ghost

ghost commented Sep 30, 2026 •

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

The new inline calculation preserves the intended MFA behavior, and no defects were found in the latest changes.

The MFA gate now checks session factors against the authenticated impersonator’s MFA settings rather than the target’s settings, and requires a resolved session for impersonation. E2E regressions cover incomplete impersonator MFA, target-only MFA, and JWTs with incomplete or missing session bindings.

Latest changes: The newest commit moves the MFA requirement calculation back into the API hook and counts factors directly on the resolved session instead of calling User helper methods.

Verdict New comments Fixed Still open
✅ Approved 0 0 0
📂 Walkthrough · 2
File Change
app/controllers/shared/api.php Calculate MFA requirements from the impersonator and reject incomplete or sessionless impersonation.
tests/e2e/Services/Users/UsersBase.php Add regressions for impersonator-owned MFA, target-only MFA, and JWT session bindings.

Reviewed the commits since 044ed65 · 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 S · Looks good to merge. Summary

@greptile-apps

greptile-apps Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Critical risk] Changes how MFA requirements are checked during account impersonation.

The PR appears safe to merge based on the changes reviewed.

Summary

The PR checks an impersonator’s session against the impersonator’s MFA settings rather than the target’s, and adds API tests for incomplete impersonator MFA and target MFA.

Reviews (3) · Last reviewed commit: "refactor: inline the impersonator MFA ch..."

@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → fix/impersonation-operator-mfa (after).

Metric Before After Change
🚀 Requests/sec 156.37 172.79 🟢 +10.5%
⏱️ Latency P50 110.26 ms 98.57 ms 🟢 -10.6%
⏱️ Latency P95 266.31 ms 239.48 ms 🟢 -10.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 98.57 239.48 11,001 172.79 -26.83
Account 200.33 381.43 579 9.61 -53.67
TablesDB 94.9 184.9 5,983 96.51 -19.12
Storage 90.98 198.55 2,895 48.15 -9.31
Functions 141.5 292.08 1,544 26.34 -48.91

Top API waits (after)

API request Max wait (ms)
account.name.update 563.46
functions.variables.update 520.3
functions.create 495.78
account.prefs.update 480.58
tablesdb.rows.delete 439.21

A JWT bound to no session left $session empty, which skipped the factor
check while the request acted as the target. Impersonating now needs a
session to count the impersonator's factors on.
@HarshMN2345
HarshMN2345 merged commit 3c63057 into main Sep 30, 2026
50 checks passed
abnegate added a commit that referenced this pull request Sep 30, 2026
Brings in main's OAuth2 state and nonce validation (#14012), which cloud
needs, along with the realtime origin alignment (#14020), subscriber
target ownership (#14019), GitLab primary email (#14010), impersonation
MFA (#14017), write-only webhook passwords (#14016), chunked-upload
resume ownership (#14014), preview authorize validation (#14013),
nightly forcing (#14015) and scheduled-function enqueue checks (#14011).

The merge had no textual conflicts, and main left composer.json and
composer.lock unchanged. So the lock keeps the branch's database and
async pins.

Main's assertResumeAllowed() in Storage Buckets/Files/Create checks
Input(Database::PERMISSION_UPDATE, ...). utopia-php/database 8 has no
PERMISSION_* constants, so every chunked resume would fail with an
undefined-constant error. It now passes PermissionType::Update, as the
rest of that action already does.

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.

1 participant