]> git.kaiwu.me - haproxy.git/commit
MINOR: http: add one control per existing HTTP violation
authorWilly Tarreau <w@1wt.eu>
Tue, 20 Oct 2026 13:21:51 +0000 (15:21 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 21 Oct 2026 15:41:14 +0000 (17:41 +0200)
commit5364eccc58486afaf11c596ae68c256e8959258a
treeda46a750cc304550f626e4f9fb5764490e3158f2
parent3bca22650dddfe3992e10410f889e8b1ad537dee
MINOR: http: add one control per existing HTTP violation

Following the previous patch, this one extends every place where a
check for relaxing protocol violations was permitted with a specific
tunable that can individually be enabled or disabled, so that it is
now possible to selectively enable a single (or a few) exceptions
without granting other ones.

The following ones are covered here, per direction:

 "fragment-in-url",                HTTP_VIO_URL_FRAG,         HTTP_DIR_REQ
 "non-ascii-in-url",               HTTP_VIO_URL_NON_ASCII,    HTTP_DIR_REQ
 "long-status-code",               HTTP_VIO_STATUS_LONG,      HTTP_DIR_RES
 "non-token-in-header-name",       HTTP_VIO_HDR_NAME_NON_TOK, HTTP_DIR_BOTH
 "nul-in-header-value",            HTTP_VIO_HDR_VALUE_NUL,    HTTP_DIR_BOTH
 "inconsistent-transfer-encoding", HTTP_VIO_TE_BAD,           HTTP_DIR_RES
 "unparsable-authority",           HTTP_VIO_AUTH_UNPARSABLE,  HTTP_DIR_REQ
 "invalid-connect-authority",      HTTP_VIO_AUTH_CONNECT_INV, HTTP_DIR_REQ
 "empty-authority-host",           HTTP_VIO_AUTH_EMPTY_HOST,  HTTP_DIR_REQ
 "mismatch-authority-host",        HTTP_VIO_AUTH_HOST_DIFF,   HTTP_DIR_REQ
 "invalid-version-string",         HTTP_VIO_VERSION_STRING,   HTTP_DIR_BOTH
 "invalid-websocket-key",          HTTP_VIO_WEBSOCKET_KEY,    HTTP_DIR_BOTH

Most of the time the check consisted in appending this after err_pos < -1:

     || !(global.acc_hreq_vio & (1U << HTTP_VIO_...))

For the long status code, the code was slightly reordered because the
check for the lenient case was performed first and now we must do the
strict check first (but the logic is unchanged, both were exclusive
already). The logic remains: if strict mode (default) or relaxed without
acceptance for long headers, we reject beyond 3 digits. And in any case
we continue to reject values that don't fit in 16 bits.

The doc was updated with descriptions of what each keyword corresponds
to, associated risks, and examples.

This is not much intrusive and might possibly be backported to latest
LTS if users want it.
doc/configuration.txt
include/haproxy/http-t.h
src/h1.c
src/h1_htx.c
src/h2.c
src/h3.c
src/http.c
src/mux_h1.c