Validated successUrl / cancelUrl / returnUrl origin in Stripe checkout#27845
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
WalkthroughThis pull request adds URL sanitization to three Stripe checkout and billing endpoints to prevent open redirects. A new 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ast-grep (0.42.2)ghost/core/test/unit/server/services/members/members-api/controllers/router-controller.test.jsWarning Review ran into problems🔥 ProblemsStopped waiting for pipeline failures after 30000ms. One of your pipelines takes longer than our 30000ms fetch window to run, so review may not consider pipeline-failure results for inline comments if any failures occurred after the fetch window. Increase the timeout if you want to wait longer or run a Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Comment |
sagzy
left a comment
There was a problem hiding this comment.
Nice one, thorough and readable tests 👍
…heckout ref https://linear.app/ghost/issue/BER-3647 - the public `create-stripe-checkout-session` endpoint forwarded caller-supplied `successUrl` / `cancelUrl` verbatim to Stripe, which would redirect users to any external URL after checkout - turning the Ghost site into an open-redirect launch pad - the same applied to `create-stripe-checkout-setup-session` and `create-stripe-billing-portal-session` (both behind an identity token, but still worth tightening) - now reject any return URL whose origin or subpath doesn't match `urlUtils.getSiteUrl()`, letting the downstream stripe-api fall back to its existing same-origin defaults; the gift flow keeps its site-root cancelUrl fallback since Stripe gift checkout has no config-level default for `cancel_url` - subpath comparison normalizes both sides to trailing-slash form, so `/blog` and `/blog/` are treated equivalently while `/blogger` is rejected
4370fc1 to
043ca7d
Compare
ref https://linear.app/ghost/issue/BER-3647
create-stripe-checkout-sessionendpoint forwarded caller-suppliedsuccessUrl/cancelUrlverbatim to Stripe, which would redirect users to any external URL after checkout - turning the Ghost site into an open-redirect launch padcreate-stripe-checkout-setup-sessionandcreate-stripe-billing-portal-session(both behind an identity token, but still worth tightening)urlUtils.getSiteUrl(), letting the downstream stripe-api fall back to its existing same-origin defaults; the gift flow keeps its site-root cancelUrl fallback since Stripe gift checkout has no config-level default forcancel_url/blogand/blog/are treated equivalently while/bloggeris rejected