Skip to content

Commit 8f3b537

Browse files
committed
MEDIUM: proxy: Reject some header names for 'http-send-name-header' directive
From time to time, we saw the 'http-send-name-header' directive used to overwrite the Host header to workaround limitations of a buggy application. Most of time, this led to troubles. This was never officially supported and each time we strongly discouraged anyone to do so. We already thought to deprecate this directive, but it seems to be still used by few people. So for now, we decided to strengthen the tests performed on it. The header name is now checked during the configuration parsing to forbid some risky names. 'Host', 'Content-Length', 'Transfer-Encoding' and 'Connection' header names are now rejected. But more headers could be added in future.
1 parent 2afcba1 commit 8f3b537

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

doc/configuration.txt

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8366,14 +8366,8 @@ http-send-name-header [<header>]
83668366
very late in the connection setup, it may have unexpected effects on already
83678367
modified headers. For example using it with transport-level header such as
83688368
connection, content-length, transfer-encoding and so on will likely result in
8369-
invalid requests being sent to the server. Additionally it has been reported
8370-
that this directive is currently being used as a way to overwrite the Host
8371-
header field in outgoing requests; while this trick has been known to work
8372-
as a side effect of the feature for some time, it is not officially supported
8373-
and might possibly not work anymore in a future version depending on the
8374-
technical difficulties this feature induces. A long-term solution instead
8375-
consists in fixing the application which required this trick so that it binds
8376-
to the correct host name.
8369+
invalid requests being sent to the server. This is why following header names
8370+
are forbidden: host, content-length, transfer-encoding and connection.
83778371

83788372
See also : "server"
83798373

src/cfgparse-listen.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1476,6 +1476,15 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
14761476
err_code |= ERR_ALERT | ERR_FATAL;
14771477
goto out;
14781478
}
1479+
if (strcasecmp(args[1], "host") == 0 ||
1480+
strcasecmp(args[1], "content-length") == 0 ||
1481+
strcasecmp(args[1], "transfer-encoding") == 0 ||
1482+
strcasecmp(args[1], "connection") == 0) {
1483+
ha_alert("parsing [%s:%d] : '%s' cannot be used as header name for '%s' directive.\n",
1484+
file, linenum, args[1], args[0]);
1485+
err_code |= ERR_ALERT | ERR_FATAL;
1486+
goto out;
1487+
}
14791488

14801489
/* set the desired header name, in lower case */
14811490
istfree(&curproxy->server_id_hdr_name);

0 commit comments

Comments
 (0)