-
Notifications
You must be signed in to change notification settings - Fork 41
Description
Description of the bug
In an attempt to prevent HTTP Host header spoofing, trusted_host_patterns handling has been added to Backdrop in #2568
The implementation has multiple issues, though.
Steps To Reproduce
The easiest way to reproduce is to remove the actual hostname from trusted_host_patterns setting (in settings.(local.)php and call any page with it. That's the easiest way, but not the only one.
Actual behavior
Exception: The HTTP Host "example.com" is not white-listed for this site. Check the trusted_host_patterns setting in settings.php. in _backdrop_bootstrap_configuration() (line 3128 of /var/www/testing/html/core/includes/bootstrap.inc).
Issues with that:
- This throws an Exception, that will show up as
500 Internal Server Error
in webserver logs - as if it was a problem on the site, while it's a problem with the request - It uses the term "white-listed", which we removed anywhere else already
- It points to the code line in bootstrap.inc, when error display is turned on - as if this were a problem to get fixed in code
- It recommends action in settings.php, but the audience here is not primarily the site admin, it's public
Expected behavior
First of all, the error has to be 400 Bad Request
.
The wording shouldn't use deprecated terms and the hint shouldn't point to action with settings.php.
Additional information
- Backdrop CMS version: latest dev
While this may seem to hardly ever occur, this occurs regularly, if Backdrop is the default host on an IP.
And it's super easy to flood the webserver logs with 500-s from outside just by using something like:
curl -I -H 'Host:foobar.com' http://ACTUAL_HOSTNAME_OR_IP
And I don't think, the bots crawling a site (primary audience for that message) will bother to fix it in settings.php 😜 They sure would like to have access to that file, but... nope.