Skip to content

Conversation

@GitTimeraider
Copy link
Owner

Potential fix for https://github.com/GitTimeraider/Directadmin-Emailforwarder/security/code-scanning/14

To fix the open redirect vulnerability, we should validate the next_page parameter before using it in a redirect. The best way is to ensure that the redirect target is a relative path (i.e., does not contain a scheme or netloc), which prevents redirection to external sites. This can be done using Python's urllib.parse.urlparse to check that both the scheme and netloc attributes are empty. Additionally, we should remove any backslashes from the input, as browsers may treat them as path separators. If the validation fails, we should redirect to a safe default (e.g., the home page or index). The changes should be applied to both places where next_page is used: lines 35 and 57 in app/auth.py. We need to import urlparse from urllib.parse.


Suggested fixes powered by Copilot Autofix. Review carefully before merging.

…mote source

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@GitTimeraider GitTimeraider marked this pull request as ready for review August 5, 2025 09:53
@GitTimeraider GitTimeraider merged commit be589d0 into main Aug 5, 2025
4 of 5 checks passed
@GitTimeraider GitTimeraider deleted the alert-autofix-14 branch August 5, 2025 09:57
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.

2 participants