]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MEDIUM: http-ana: Add a proxy option to restrict chars in request header names
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 16 May 2022 09:43:10 +0000 (11:43 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 16 May 2022 14:00:26 +0000 (16:00 +0200)
commit18c13d3bd88cbcc351a61b1e71881353ab720f67
treef822009d2aa0048ce4f460ee442ed6431697446a
parentf46393ac44002cebb89ff9510e64dc1f72cdb35f
MEDIUM: http-ana: Add a proxy option to restrict chars in request header names

The "http-restrict-req-hdr-names" option can now be set to restrict allowed
characters in the request header names to the "[a-zA-Z0-9-]" charset.

Idea of this option is to not send header names with non-alphanumeric or
hyphen character. It is especially important for FastCGI application because
all those characters are converted to underscore. For instance,
"X-Forwarded-For" and "X_Forwarded_For" are both converted to
"HTTP_X_FORWARDED_FOR". So, header names can be mixed up by FastCGI
applications. And some HAProxy rules may be bypassed by mangling header
names. In addition, some non-HTTP compliant servers may incorrectly handle
requests when header names contain characters ouside the "[a-zA-Z0-9-]"
charset.

When this option is set, the policy must be specify:

  * preserve: It disables the filtering. It is the default mode for HTTP
              proxies with no FastCGI application configured.

  * delete: It removes request headers with a name containing a character
            outside the "[a-zA-Z0-9-]" charset. It is the default mode for
            HTTP backends with a configured FastCGI application.

  * reject: It rejects the request with a 403-Forbidden response if it
            contains a header name with a character outside the
            "[a-zA-Z0-9-]" charset.

The option is evaluated per-proxy and after http-request rules evaluation.

This patch may be backported to avoid any secuirty issue with FastCGI
application (so as far as 2.2).
doc/configuration.txt
include/haproxy/proxy-t.h
reg-tests/http-rules/restrict_req_hdr_names.vtc [new file with mode: 0644]
src/cfgparse-listen.c
src/fcgi-app.c
src/http_ana.c