Conversation
normalize the login "next" parameter in admin and contest login handlers.
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Improves safety and correctness of handling the next redirection parameter in admin and contest POST handlers to avoid unsafe redirects and better preserve allowed URLs. Fixes #1684.
Changes:
- Parse
nextusingurllib.parse.urlsplitin both admin and contest handlers. - Reject
nextvalues that include a scheme/host or don’t start with/, falling back to a safe URL. - Preserve query strings for accepted internal paths.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| cms/server/contest/handlers/main.py | Uses urlsplit to validate/sanitize next and preserve query parameters for contest redirects. |
| cms/server/admin/handlers/main.py | Uses urlsplit to validate/sanitize next and preserve query parameters for admin redirects. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1685 +/- ##
==========================================
- Coverage 54.68% 54.64% -0.05%
==========================================
Files 336 336
Lines 27501 27525 +24
==========================================
+ Hits 15039 15041 +2
- Misses 12462 12484 +22
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Normalize and validate the parsed next-page path in admin and contest login handlers. Handle empty paths by treating them as "/", reject URLs with a scheme or netloc, and refuse path segments that are empty or contain "." or ".." to avoid unsafe redirects or path traversal. Also ensure the query string is preserved when constructing fallback URLs. These changes harden next-parameter handling and fix edge cases when urlsplit.path is empty.
Improves the handling of the
nextpage redirection parameter in both the admin and contest handlers.Fix #1684