fix: generate and store nonce in magic-link transaction for ID token …#2753
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughThe magic-link passwordless flow now generates a nonce, sends it in authorization parameters, and stores it in transaction state. Tests verify cookie persistence and reject callbacks with mismatched ID-token nonces. ChangesMagic-link nonce flow
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2753 +/- ##
=======================================
Coverage 88.11% 88.11%
=======================================
Files 79 79
Lines 11105 11108 +3
Branches 2296 2296
=======================================
+ Hits 9785 9788 +3
Misses 1276 1276
Partials 44 44 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Looks good, but can we add a test to check callback with mismatched ID-token nonce since we are now checking the nonce? |
2735b19 to
1a9dcd5
Compare
📋 Changes
Magic-link passwordless flows (
send: 'link') now generate a nonce alongsidestatewhen building the authorization request. The nonce is:authParamsforwarded to Auth0 in the/passwordless/startrequest body, so Auth0 embeds it in the magic link's authorization URLstateWhen the magic link is followed and the callback completes the authorization code exchange,
processAuthorizationCodeResponsereceives the stored nonce asexpectedNonceand verifies it matches thenonceclaim in the returned ID token. Without this fix,expectedNoncewasundefinedand the check was silently skipped, an attacker who extracted an ID token from a completed magic-link flow could replay it in a different session.OTP flows (
send: 'code') are not affected — they do not use an authorization code callback and are not impacted by this change.📎 References
🎯 Testing
New unit test in
passwordless-server.flow.test.ts:nonceis present inauthParamssent to Auth0noncematches the value forwarded to Auth0Summary by CodeRabbit
/passwordless/startpayload, stored in transaction state, and correctly enforced during callback nonce mismatch scenarios.