Skip to content

get_host will use X-Forwarded-Host by default #609

@danielrichman

Description

@danielrichman

Here: https://github.com/mitsuhiko/werkzeug/blob/cbd049d88727936173386d2e80bb5ffa51fedd6e/werkzeug/wsgi.py#L141

I don't think that this is a safe default.
When using flask it gives any client the ability to set an arbitrary hostname in request.url.

This surprised me, since http://werkzeug.pocoo.org/docs/0.9/contrib/fixers/#werkzeug.contrib.fixers.ProxyFix exists to explicitly enable support for these headers (X-Forwarded-For, X-Forwarded-Host, ...).

And I think that this is misleading: http://werkzeug.pocoo.org/docs/0.9/wrappers/#werkzeug.wrappers.BaseRequest.trusted_hosts since a web server must not only “not route invalid hosts to the application”, but it must also delete any foreign X-Forwarded-Host headers.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions