-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
fix: Session management issue that causes malformed redirect URLs #3011
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Session management issue that causes malformed redirect URLs #3011
Conversation
|
🚀 Thanks for opening this pull request! We appreciate your effort in improving the project. Please let us know once your pull request is ready for review. |
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
📝 WalkthroughWalkthroughAdds redirect parsing, validation, and normalization for /login flows: parses redirect via URL, rejects absolute/protocol-relative URLs, stores a validated Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant App as app.js
participant Auth as Authentication.js
Note over App,Auth: Login request handling & redirect validation
Client->>App: GET /login?redirect=/path or body.redirect
App->>App: parse req.url via URL(...)\nextract searchParams 'redirect'\nsanitize: reject '://' or startsWith('//')\nstrip leading '/'
alt invalid redirect
App->>App: set redirect -> 'apps'\nclear originalRedirect
else valid redirect
App->>Auth: pass normalized redirect / originalRedirect
end
Auth->>Auth: validate/normalize redirect again\nset failureRedirect using originalRedirect
Auth-->>Client: redirect to computed internal path or failureRedirect
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
🔇 Additional comments (2)
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (1)
Parse-Dashboard/app.js (1)
1065-1065: Refactor for clarity and efficiency.The chained boolean expression is complex and calls
splitthree times. Additionally, if the URL contains multiple query parameters (e.g.,?redirect=/apps&other=value), the redirect value would include the extra parameters.Consider using
URLSearchParamsfor proper query string parsing:- let redirectURL = req.url.includes('?redirect=') && req.url.split('?redirect=')[1].length > 1 && req.url.split('?redirect=')[1]; + const url = new URL(req.url, `http://${req.headers.host}`); + let redirectURL = url.searchParams.get('redirect');This approach:
- Properly parses query parameters regardless of order
- Handles multiple query parameters correctly
- Improves readability
- Is more efficient
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
Parse-Dashboard/Authentication.js(1 hunks)Parse-Dashboard/app.js(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Docker linux/amd64
# [8.0.0-alpha.6](8.0.0-alpha.5...8.0.0-alpha.6) (2025-10-29) ### Bug Fixes * Session management issue that causes malformed redirect URLs ([#3011](#3011)) ([1649dd3](1649dd3))
|
🎉 This change has been released in version 8.0.0-alpha.6 |
New Pull Request Checklist
Issue Description
Invalid redirect URL in this scenario:
The problem is that the session check recognizes you're already authenticated and tries to redirect, but the redirect URL is malformed.
Approach
Fix redirect handlers to properly strip leading slashes before concatenation. This ensures that regardless of whether the user submits the login form or reloads a login page while already authenticated, the redirect URLs are always properly formatted without double slashes or malformed relative paths.
Summary by CodeRabbit
Security Improvements
Bug Fixes