-
-
Notifications
You must be signed in to change notification settings - Fork 16.5k
Recommend Warning and Safer Defaults for url_for(..., _external=True) #5718
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
Comments
This is already documented in Deploying: https://flask.palletsprojects.com/en/stable/deploying/proxy_fix/ |
FWIW this is only a problem when all these criteria are met:
@davidism I'm not sure if just mentioning |
A section about |
Hi, I’m new to open source and would like to work on this issue. Can I take it? |
Thanks for the contribution and this looks great! I appreciate the clean and thoughtful write-up. Glad to see the issue addressed this thoroughly. Let me know if I can help further. |
Hi Flask team,
We recently analyzed several Flask-based applications and noticed a recurring security concern related to url_for(..., _external=True) when used in untrusted request contexts. Specifically, since it uses request.host by default to construct the external URL, applications that do not explicitly configure SERVER_NAME or sanitize headers can be vulnerable to host header injection.
To improve developer awareness and reduce misuse, we suggest: Add a warning to the url_for documentation about the risk of relying on request.host, and recommend the use of SERVER_NAME or trusted_hosts when generating external URLs.
We’d be happy to help draft the relevant documentation or contribute a pull request if this direction aligns with the maintainers' goals.
Best regards,
Rui Yang and Zhengyu Liu
Johns Hopkins University
The text was updated successfully, but these errors were encountered: