Repository navigation
fix(account): bind the OAuth2 state to the user who started the flow - #15029
Conversation
The OAuth2 callback accepted any nonce cookie matching the state, and a site sharing the parent domain can set that cookie for another browser. The state now carries an HMAC of the nonce and the user who started the flow, and the callback checks it against its own user, so a flow started elsewhere cannot attach its identity to the signed-in account.
|
Review complete. No issues found — approved ✅. This PR hardens the OAuth2 session and token flows against the planted-nonce-cookie attack: the flow start now computes
One minor note below threshold: the binding falls back to an empty HMAC key when Reviewed commit: aae0468 |
🟢 Tier S · Ready to mergeOAuth2 session and token flows now include an HMAC binding between the nonce and the initiating user, which the callback validates alongside the nonce cookie. Guest callbacks can also complete legacy flows whose state predates the binding. Account E2E coverage checks planted-cookie callbacks and legacy-state behavior. Latest changes: The newest commit allows guest callbacks to finish unbound legacy states and adds E2E checks that signed-in callbacks still reject those states.
📂 Walkthrough · 2
Reviewed the commits since |
Security rulesNo new WARNING or ERROR findings from security rules. 6 existing findings tracked in
|
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
The findings that requested changes are resolved. See the summary comment for what is still open.
Flows started on a pod without the state binding and finished on one with it were refused, so every console and project OAuth2 login in flight during a rollout failed for up to the nonce's hour. A guest callback gains nothing from the binding, since every guest shares the same one, so it now accepts a state without it. A callback from a signed-in browser still needs a matching binding, and any binding present is still checked.
The OAuth2 callback accepted any nonce cookie matching the state, and a site sharing the parent domain can set that cookie for another browser. The state now carries an HMAC of the nonce and the user who started the flow, and the callback checks it against its own user, so a flow started elsewhere cannot attach its identity to the signed-in account.
Rollout grace: a flow started on a pod without this change has no
bindingin its state. A guest callback accepts such a state, so console and project OAuth2 logins in flight during a deploy (the nonce lives up to an hour) still finish; the binding protects nothing for guests anyway, since every guest gets the same one. A callback from a signed-in browser (identity linking) still requires a matching binding, and any binding present is always verified.testCreateOAuth2SessionRejectsPlantedNonceCookiecovers both: a state stripped of its binding is refused for the signed-in browser and completes for a guest holding the nonce.Lint, PHPStan and the touched unit tests passed locally before rebasing on main; e2e runs in CI.
Related: appwrite-labs/cloud#6666