Skip to content

fix(BUG-147): sanitize the login next redirect target - #98

Merged
ojas50 merged 1 commit into
mainfrom
ojas
Oct 27, 2026
Merged

ojas50 merged 1 commit into
mainfrom
ojas

Conversation

@ojas50

@ojas50 ojas50 commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

Login "next was used as the redirect target as is, so a crafted link could send users to an outside site. It now accepts only internal paths

The login form's next field was returned verbatim by _post_login_destination, so POST /login {next: https://evil.example/steal} answered 302 Location: https://evil.example/steal (CWE-601). The value now goes through the existing _safe_redirect_url allowlist sanitiser before the role-landing checks: only ALLOWED_REDIRECT_PATHS survive (query strings preserved) and anything else collapses to / and falls through to the normal landing.

New tests/test_auth.py::TestPostLoginRedirect (9 tests) pins https://, http://, //, /\\, \\\\ and javascript: nexts to /, keeps /students?roster=abc&q=alice intact, and checks the live form POST. Suite: 743 passed / 10 skipped (was 734/10).
@vercel

vercel Bot commented Oct 27, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
student-analytics Ready Ready Preview Oct 27, 2026 2:54pm UTC

@ojas50
ojas50 merged commit 5deba87 into main Oct 27, 2026
4 checks passed

This branch was successfully deployed

1 active deployment
Preview — 1c8951b4 Deployed Oct 27, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant