Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.