Hacker News new | ask | show | jobs
by gojomo 4985 days ago
Thanks for the invite.

However, my idea is just what's already outlined above: avoid using 'Host', except (perhaps) as a key.

Declaring one or more approved hostnames for accessing an install isn't an onerous requirement (especially if you're assuming that when they're not doing it in Django, they must do it elsewhere to be safe).

Maybe some people (such as in multi-tenancy situations or to make dev/staging/production transitions easier) will choose to use 'Host' directly anyway, or some sort of wildcard for acceptable hostnames. That's fine, but then they'll be accepting the risk by conscious action, deviating from the safer default. That seems better than facing the risk by the inaction of overlooking this more-subtle webserver-configuration issue.

1 comments

> However, my idea is just what's already outlined above: avoid using 'Host', except (perhaps) as a key.

Yes, this is a good idea in theory (it's an offshoot of the idea of avoiding using any data that's provided by the browser.) But in practice, it breaks down any time you need to generate a full URL into the site, i.e.:

* Callback URLs for schemes like OAuth, webhooks, IPN, etc. * Transaction emails with links back to the site ("this week on example.com", "joe just mentioned you..." password resets, etc.) * Links in Atom, RSS feeds, etc.

In each case, Django could require that hosts be hardcoded (perhaps in settings) instead of consulting requests, but that would make each of those things harder to use.

... I'm not really trying to have an argument here; I see your point completely and I think I probably agree, personally. But I am trying to point out that security and usability are often at odds, and that there isn't as much a "right answer" as there is a calibration between those two needs. Drawing the line in the right place is hard.