sec: narrow CSRF exemption for approve/cancel to token-only requests - #531
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughMiddleware ChangesToken-aware CSRF exemption for purchase endpoints
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
|
@coderabbitai full review |
Rate Limit Exceeded
|
a76882c to
e1bee49
Compare
|
Rebased on feat/multicloud-web-frontend. Resolved conflicts in:
All tests pass (1444 passed). @coderabbitai review |
|
🧠 Learnings used✅ Action performedReview finished.
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
Fixes #404: the approve/cancel/reject paths were unconditionally exempt from CSRF validation, meaning a session-authenticated user could be CSRF-attacked into approving a purchase from a malicious page. requiresCSRFValidation now accepts the request and checks for a bearer token: if the request carries a session, CSRF is required (session flow); if there is no session, CSRF is skipped (pure email-link/token flow where the approval token in the URL serves as the authenticator). Unconditionally-exempt paths (login, setup-admin, forgot/reset-password, register) are unchanged. Updated the call site in validateSecurity and fixed existing tests in coverage_gaps_test.go to pass the request argument. Regression tests added covering both the token-only and session cases.
e1bee49 to
d8eabd6
Compare
Fixes #404
Summary by CodeRabbit
Bug Fixes
Tests