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

Fix code scanning alert no. 20: URL redirection from remote source #519

Merged
merged 1 commit into from
Oct 19, 2024

Conversation

TreyWW
Copy link
Owner

@TreyWW TreyWW commented Oct 19, 2024

Fixes https://github.com/TreyWW/MyFinances/security/code-scanning/20

To fix the problem, we need to validate the redirect_url to ensure it is safe to use. We can use Django's url_has_allowed_host_and_scheme function to check that the URL is safe to redirect to. This function ensures that the URL does not contain an explicit host name unless it is in the list of allowed hosts.

  1. Import the url_has_allowed_host_and_scheme function from django.utils.http.
  2. Use this function to validate the redirect_url before performing the redirect.
  3. If the redirect_url is not valid, redirect to a default safe page, such as the dashboard.

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

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Copy link
Contributor

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails

Scanned Manifest Files

@TreyWW TreyWW marked this pull request as ready for review October 19, 2024 20:08
@TreyWW TreyWW merged commit 2c8808c into main Oct 19, 2024
9 checks passed
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