Skip to content

Reject protocol-relative URLs in post-login redirect - #191

Open
B58TU wants to merge 1 commit into
crackmesone:mainfrom
B58TU:fix/login-open-redirect
Open

B58TU wants to merge 1 commit into
crackmesone:mainfrom
B58TU:fix/login-open-redirect

Conversation

@B58TU

@B58TU B58TU commented Sep 23, 2026

Copy link
Copy Markdown

The redirect after login only checked that the value starts with '/'. A referer like https://crackmes.one//evil.com passes the same-host check, its path '//evil.com' gets stored in the session, and after a successful login the browser receives Location: //evil.com, which resolves to https://evil.com. So someone can be shipped off to another site right after logging in on the real domain. The '\evil.com' variant works the same way in browsers since they treat backslashes as slashes.

Fix is one check at the only place the stored redirect gets used (login_post): reject values starting with '//' or containing a backslash. That covers both places that write the value (login_get and register_get).

Added a test for both cases, it fails without the fix. test_controller_edge_cases.py and test_routes.py pass, 44 total.

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