Skip to content

docs: add warning and best practices for url_for(..., _external=True)… #5722

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ranveer9
Copy link

Description of the Change

This pull request adds a warning and best practices to the Web Security documentation regarding the use of url_for(..., _external=True) without setting SERVER_NAME or trusted_hosts. The new section explains the risk of host header injection and provides recommendations for safer configuration. This aims to improve developer awareness and help prevent potential security vulnerabilities, as discussed in #5718.

How it Addresses the Issue

  • Documents the risk of host header injection when generating external URLs.
  • Recommends setting SERVER_NAME and using trusted_hosts.
  • References the ProxyFix documentation for further guidance.

Relevant Issue
fixes #5718

@BrookeYangRui
Copy link

Thanks for working on this! I really appreciate how clearly the risks and recommendations were described.

This patch aligns well with the concerns I originally raised in issue #5718, glad to see it resolved!

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.

Recommend Warning and Safer Defaults for url_for(..., _external=True)
2 participants