Host Header Attack: url_for()
should not trust unvalidated Host header
#1854
Unanswered
lieryan
asked this question in
Potential Issue
Replies: 1 comment
-
I think the solution to this should be that accessing anything that uses the Host header from And if the user don't care about the host header (i.e. they are in an environment where they don't have to worry about this issue), they can just use something like |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This is somewhat related to ticket #843.
Currently,
url_for()
can be used to generate an absolute URL for a route and it uses Host header to do so. There is currently no validation in the value of the host header, which can be abused for some quite funky stuffs.This behavior is a security issue because it opens up the application to Host Header Attack.
You can fix this issue in your application by adding a TrustedHostMiddleware and setting
allowed_hosts=["yourdomain.com"]
, but I think most people aren't going to know that they must use TrustedHostMiddleware if they want to useurl_for()
securely.To reproduce:
And on the shell do (note the funky looking Host header):
Beta Was this translation helpful? Give feedback.
All reactions