Skip to content

fix(security): harden client-side redirects against SSRF and open redirect (#241) - #270

Open
Dev1822 wants to merge 1 commit into
vallabhatech:mainfrom
Dev1822:feature/issue-241-harden-redirects
Open

fix(security): harden client-side redirects against SSRF and open redirect (#241)#270
Dev1822 wants to merge 1 commit into
vallabhatech:mainfrom
Dev1822:feature/issue-241-harden-redirects

Conversation

@Dev1822

@Dev1822 Dev1822 commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Description

This PR addresses security vulnerabilities related to client-side redirects (Open Redirect and SSRF). The previous regex-based validation for redirects in redirect.js was insufficient and susceptible to bypasses using backslashes and encoded double slashes.

This update replaces redirect.js with routeRedirects.js, implementing a strict allowlist of authorized internal application routes. It introduces a getRedirectFromParams utility to safely parse redirectUrl or next query parameters. Finally, it updates the Login.jsx success handlers to validate and safely redirect users, defaulting to the dashboard upon failure.

Fixes #241

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

  • Unit tests (routeRedirects.test.js): Verified that strict allowlisted paths are successfully validated, even when accompanied by valid query strings and hashes.
  • Security Payload Tests (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 Flow: Verified that Login.jsx correctly parses and validates query parameters before performing navigations.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works

@vercel

vercel Bot commented Jul 16, 2026

Copy link
Copy Markdown

@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.

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@Dev1822, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 16 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 07979345-1629-415d-abf1-b370cc522031

📥 Commits

Reviewing files that changed from the base of the PR and between 80dcf6a and fd6c50c.

📒 Files selected for processing (5)
  • src/pages/Login.jsx
  • src/utils/redirect.js
  • src/utils/redirect.test.js
  • src/utils/routeRedirects.js
  • src/utils/routeRedirects.test.js
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Dev1822

Dev1822 commented Jul 24, 2026

Copy link
Copy Markdown
Contributor Author

@vallabhatech , kindly suggest me any changes if needed for this pr. If not kindly merge this pr with gssoc and elusoc labels.

@github-actions github-actions Bot added bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request security ui/ux labels Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request security ui/ux

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] [ELUSoC_2026] Harden client-side query redirects against Open-Redirect and SSRF vulnerabilities

1 participant