Repository navigation
fix(security): count MFA factors against the impersonator's own settings - #14017
Conversation
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().
🟢 Tier S · Ready to merge
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.
📂 Walkthrough · 2
Reviewed the commits since |
|
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
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.
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]>
While impersonating, the MFA check counted the impersonator's session factors against the target's MFA settings. As a result:
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:
testImpersonationRequiresImpersonatorFactorsandtestImpersonationIgnoresTargetFactors.