Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Security Vulnerability Report: Open Redirect in "next" parameter #1833

Open
Cainor opened this issue Nov 18, 2023 · 0 comments
Open

Security Vulnerability Report: Open Redirect in "next" parameter #1833

Cainor opened this issue Nov 18, 2023 · 0 comments

Comments

@Cainor
Copy link

Cainor commented Nov 18, 2023

Dear Team,

Thank you for your contribution to the open source community

Summary:
I was able to find an Open Redirect vulnerability providing different domain in the "next" parameter that is used in the login process.

Open Redirect Description and Impact:
An Open Redirect issue occurs when a web application redirects users to external URLs without proper validation. This can lead to phishing attacks, where users are tricked into visiting malicious sites, potentially leading to information theft and reputational damage to the website used for redirection.

Vulnerable Code:

next_url = request.POST.get('next', '')
if next_url:
return HttpResponseRedirect(next_url)

Here if the "next" parameter was any of the following:

  • ?next=https://www.google.com
  • ?next=//google.com

Recommended Solution:
To remediate this use: url_has_allowed_host_and_scheme method provided by django.utils.http
The code should look like this:

from django.utils.http import url_has_allowed_host_and_scheme
...
 next_url = request.POST.get('next', '') 
 if next_url and url_has_allowed_host_and_scheme(next_url, settings.ALLOWED_HOSTS): 
     return HttpResponseRedirect(next_url) 

Thank you for your attention to this matter. I look forward to your response and am ready to assist in any way necessary to resolve this issue.

Regards,
Cainor

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

No branches or pull requests

1 participant