fix(security): harden client-side redirects against SSRF and open redirect (#241) - #270
fix(security): harden client-side redirects against SSRF and open redirect (#241)#270Dev1822 wants to merge 1 commit into
Conversation
|
@Dev1822 is attempting to deploy a commit to the vallabhatech's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
Warning Review limit reached
Next review available in: 16 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
✨ Finishing Touches🧪 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 |
|
@vallabhatech , kindly suggest me any changes if needed for this pr. If not kindly merge this pr with gssoc and elusoc labels. |
Description
This PR addresses security vulnerabilities related to client-side redirects (Open Redirect and SSRF). The previous regex-based validation for redirects in
redirect.jswas insufficient and susceptible to bypasses using backslashes and encoded double slashes.This update replaces
redirect.jswithrouteRedirects.js, implementing a strict allowlist of authorized internal application routes. It introduces agetRedirectFromParamsutility to safely parseredirectUrlornextquery parameters. Finally, it updates theLogin.jsxsuccess handlers to validate and safely redirect users, defaulting to the dashboard upon failure.Fixes #241
Type of change
How Has This Been Tested?
Please describe the tests that you ran to verify your changes.
routeRedirects.test.js): Verified that strict allowlisted paths are successfully validated, even when accompanied by valid query strings and hashes.routeRedirects.test.js): Verified that malicious payloads (e.g.,https://evil.com,//malicious.com,/\evil.com,javascript:alert(1)) are correctly blocked and gracefully default to/dashboard.Login.jsxcorrectly parses and validates query parameters before performing navigations.Checklist: