Olivier Houchard [Tue, 17 Nov 2026 16:20:57 +0000 (17:20 +0100)]
BUG/MEDIUM: dns: release the session slot of expired TCP queries
A DNS-over-TCP session counts its pipelined queries in ds->nb_queries, up
to DNS_STREAM_MAX_PIPELINED_REQ (4), and only dns_recv_nameserver()
releases a slot, when a response is delivered. But when a query expires
without response, dns_process_query_exp() only decrements onfly_queries.
After 4 unanswered queries, the session is thus neither in the free nor in
the idle list anymore: it is never reused nor released and its connection
remains open forever, while new queries open new connections. With a TCP
nameserver not answering some names, one connection is leaked every 4
such queries, without limit.
Let's release the slot when a query expires, and move the session to the
free or idle list, under the stream server's lock, exactly as done when a
response is received.
This was introduced in 2.4 with commit fd647d5f5 ("MEDIUM: dns: adds code
to support pipelined DNS requests over TCP."), so this must be backported
to all stable branches.
Olivier Houchard [Tue, 17 Nov 2026 16:37:14 +0000 (17:37 +0100)]
REGTESTS: decompression: don't use yes(1) in http_large_cl
The body of http_large_cl.vtc was produced using "yes | head -c". But
vtest ignores SIGPIPE, which is inherited by the shell commands, and
BusyBox's yes never stops when its output is closed in this case. The test
then hangs until it is killed by vtest, as seen on the Alpine CI. GNU yes
is not affected because it exits on the write error.
Let's use awk instead to produce the same 24000 bytes. This test was added
by commit 68a8abcbe ("REGTESTS: decompression: test a large decompressed
Content-Length response"), no backport is needed.
Olivier Houchard [Tue, 17 Nov 2026 15:37:38 +0000 (16:37 +0100)]
REGTESTS: http-messaging: check that 1xx don't abort H2 backend tunnels
This test sends a CONNECT request, then an Extended CONNECT request (via
an H1 upgrade), through H2 backends whose servers answer with an interim
response then with a 200 response, and checks that data may then be
exchanged in the tunnel. It validates the previous fix.
Olivier Houchard [Tue, 17 Nov 2026 15:37:38 +0000 (16:37 +0100)]
BUG/MEDIUM: mux-h2: don't abort a tunnel attempt on interim responses
On the backend side, when a CONNECT or an Extended CONNECT request was
sent, h2c_dec_hdrs() aborts the tunnel attempt as soon as a response
without H2_MSGF_BODY_TUNNEL is received. But h2_make_htx_response() clears
this flag for any status other than 2xx and 101, including interim
responses (1xx) such as 100 Continue or 103 Early Hints. H2_SF_BODY_TUNNEL
is then removed and H2_SF_TUNNEL_ABRT set, so that the final 200 response
is processed as a regular response with a body. The client receives the
interim and the final responses, but the connection is closed as soon as
data are exchanged. This breaks CONNECT and WebSocket (Extended CONNECT)
through H2 servers emitting interim responses.
Let's only abort the tunnel attempt on final responses.
This has been there since 2.4 with commit d0db42326 ("MINOR: mux-h2: Add 2
flags to help to properly handle tunnel mode") and must be backported to
all stable versions.
Olivier Houchard [Tue, 17 Nov 2026 14:38:01 +0000 (15:38 +0100)]
REGTESTS: decompression: test a large decompressed Content-Length response
This test sends a small gzip-compressed body with a Content-Length header,
decompressing into more than a buffer, and checks that the whole
decompressed body is received. It is used to validate the previous fix.
Olivier Houchard [Tue, 17 Nov 2026 14:38:01 +0000 (15:38 +0100)]
BUG/MEDIUM: flt-decomp: don't expose EOM before the end of decompression
When the last DATA block carries the EOM flag, which is the case for
Content-Length messages, the decompression filter replaces its compressed
data with the decompressed ones, but the block keeps the EOM flag. If all
the input data were consumed but the decompressed output could not be fully
drained into the buffer, the message is already seen as ended. The filter
is then no longer called and the pending output is lost, silently
truncating the message. Chunked messages are not affected because the EOM
flag is carried by the EOT block, which is held while data are pending.
Let's remove the EOM flag from any DATA block processed by the filter, and
save it in the filter context, so that it is restored once the
decompression is finished, as it is already done when a block is removed.
This was introduced by commit 40e5dff61 ("MAJOR: tree-wide: No longer use
HTX_FL_HAS_EOM to detect end of message"): before it, the end of message was
hidden during the decompression, but since it is carried by the tail block,
it is only saved when the block is removed. No backport is needed.
Olivier Houchard [Tue, 17 Nov 2026 14:06:51 +0000 (15:06 +0100)]
BUG/MEDIUM: htx: never merge the next DATA block into the referenced one on defrag
When htx_defrag() is called with a referenced DATA block, this block is
copied as a new block to preserve it. But the DATA block following it, if
any, is then copied using __htx_add_data_type_atonce(), which appends it to
the tail block, i.e. to the referenced block itself. The returned block is
thus larger than requested by <blkinfo> and contains the next block's data.
The compression filter, which continues with the block following the one
it replaced with htx_replace_blk_value(), then skips these data and
forwards them uncompressed in the middle of the compressed stream.
This can be triggered with a Lua filter appending data at the end of a
response (HTTPMessage:append()) before the compression filter: the appended
data are added in a new DATA block, and when the compressed output of the
previous block is larger than the input and requires a defragmentation, the
appended data are emitted as-is and the response is corrupted.
Let's never merge a DATA block into the referenced block.
This was introduced by commit 0c6f2207f ("MEDIUM: htx: Refactor htx
defragmentation to merge data blocks"). It should be backported to 3.4.
Olivier Houchard [Tue, 17 Nov 2026 13:12:49 +0000 (14:12 +0100)]
BUG/MEDIUM: peers: make the soft-stop "dont_stop" state per peers section
Commit 608e23c49 ("MINOR: peers: Use a static variable to wait a resync on
reload") replaced the PEERS_F_DONOTSTOP flag with a static variable in
__process_stopping_peer_sync(), considering that it was only used in this
function. But this function is called by the sync task of each peers
section, so the variable is shared between all sections. With more than one
peers section, upon soft-stop, only the first section to process the signal
arms its resync timeout, requests the local reconnect and kills its
sessions; the other ones see dont_stop already set and skip this, so they
never push their tables to the new process. Then the first section which
completes (or times out) decrements jobs and resets the variable, letting
the old process leave without releasing the table refcounts of the other
sections. As a result, on each reload, the stick-tables of all sections but
one are lost.
Let's store this state in the peers section itself.
This fixes GitHub issue #3517. This must be backported to 3.0.
Olivier Houchard [Tue, 17 Nov 2026 12:48:25 +0000 (13:48 +0100)]
BUG/MEDIUM: stick-tables/cli: "set table" without key must not clear the table
cli_parse_table_req() accepts "set table <table>" without any "key" nor
"ptr" argument and returns 0, so that the table I/O handler runs with the
"set" action, which, like "clear", kills all unreferenced entries of the
table. So an operator mistyping "set table t" silently wipes the whole
table instead of getting an error (the doc's synopsis lists key/ptr as
required):
> set table t key 10.0.0.1 data.gpc0 1 (x4)
> show table t => used:4
> set table t => (no output)
> show table t => used:0
Let's return the usage message when "set" is used without key nor ptr.
This was introduced in 1.7 by commit f13ebdf28 ("REORG: cli: move table
dump/clear/set to stick_table.c") which made "set" use the table I/O
handler. Before that, it was a no-op. This should be backported to all
stable versions.
Olivier Houchard [Tue, 17 Nov 2026 10:14:57 +0000 (11:14 +0100)]
BUG/MINOR: http/hardening: free the new profile on strdup() failure
In cfg_parse_http_hardening(), when strdup() of the file name fails after
a new profile was allocated by http_hardening_new(), the profile is not
yet indexed and its only reference is lost on "goto out", leaking it and
its name. Let's release it with http_hardening_free(), which is safe for
the static profiles.
This was reported by Coverity (CID 1690184) in GitHub issue #3560, with
the analysis and fix provided by Alexandre Laroche. It was introduced by
commit fa70a47cb ("MINOR: cfgparse/http: add a simple parser for new
section "http-fingerprint"") in 3.5-dev11, so no backport is needed.
Willy Tarreau [Wed, 21 Oct 2026 20:43:44 +0000 (22:43 +0200)]
MINOR: sample: add a "tr" converter
This converter works like the unix "tr" utility: it translates or deletes
characters from the input sample. As on the command line, it takes 2 or 3
arguments:
- optional flags, which must start with '-': 'd' to delete characters
instead of translating them, 'c' to use the complement of the first
set ;
- the set of characters to match ;
- the replacement set, mandatory without 'd' and forbidden with it.
For example, tr('a-z','A-Z') upper-cases the input, and tr(-dc,'[:digit:]')
only keeps the digits. A set starting with '-' as the first argument must
be written with a backslash ('\-'), except for "-" alone, again as with the
unix utility.
Sets support ranges ("a-z"), the POSIX character classes ("[:alpha:]"
etc, ASCII only), and the usual escapes (\NNN octal, \n, \t, \\ etc).
When the replacement set is shorter than the first one, its last char is
repeated. When complemented, the chars are enumerated in ascending order.
The sets are resolved at config parsing time into a 256-byte table stored
in the second argument, and the flags are stored as an integer in the
first one, so that the runtime processing only consists in one table
lookup per byte. The deletion loop is branchless so that it remains fast
on large contents such as a request body. It relies on smp_prepare_out()
so that read-only inputs, which are the most common ones, are not
duplicated first but directly transformed into a trash chunk. The
converter works on binary contents and preserves the input sample's type.
The set parsing functions tr_set_init(), tr_read_char() and tr_set_next()
are exported, with struct tr_set_ctx in sample-t.h, so that other
converters may use the same set syntax.
Willy Tarreau [Wed, 21 Oct 2026 21:05:05 +0000 (23:05 +0200)]
OPTIM: sample: use smp_prepare_out() in the lower and upper converters
These converters used to call smp_make_rw() then convert the string in
place. Most of the time their input is read-only (e.g. a header), in
which case smp_dup() first copied it into a trash chunk before the
conversion performed a second pass over it. By relying on
smp_prepare_out() instead, the converted string is directly written into
the trash chunk while reading the input, saving one pass. Writable inputs
are still converted in place.
Willy Tarreau [Wed, 21 Oct 2026 21:01:06 +0000 (23:01 +0200)]
MINOR: sample: add smp_prepare_out() to prepare an output buffer
Converters that transform their input without making it grow (case
conversion, character deletion etc) usually call smp_make_rw() then work
in place. When the input is read-only, which is the most common case,
smp_dup() first copies the whole input into a trash chunk, and the
converter then performs a second pass over it.
smp_prepare_out() avoids this copy: for a R/W sample of type STR or BIN,
it leaves the sample as-is, otherwise it replaces the sample's buffer with
a new trash chunk at least as large as the input (with the same truncation
rules as smp_dup()) and clears the "const" flag. The caller saves the
input's area pointer before the call, then reads from it and writes into
the sample's area. Since both may alias when the sample was R/W, the
caller must never write ahead of where it reads.
Willy Tarreau [Tue, 17 Nov 2026 08:21:17 +0000 (09:21 +0100)]
IMPORT: slz-prv: work around lobotomized compilers' fallthrough diagnostics
When preprocessing and compilation run as separate phases (cpp then
cc, as often happens in distributed builds for example), comments are
stripped before compilation begins. Lobotomized compilers that decide
to emit warnings when they don't see "/* fall through */" comment
annotations that were dropped on the previous phase were just
misdesigned in a hurry and are causing harm.
We already had to do this in tables.h in the past but it's just lost at
the wrong place now. Let's just move that __fallthrough definition into
slz-prv.h where it's easier to locate, and use it in slz_rfc1951_flush()
to silence a compiler warning instead of modifying the code to work around
this absurdity.
Willy Tarreau [Mon, 12 Oct 2026 19:20:36 +0000 (19:20 +0000)]
REGTEST: ssl: test tune.h2.fe.enabled and h2_enabled on two instances
This test compares two haproxy instances, "hon" with the default setting
and "hoff" with "tune.h2.fe.enabled off", and sends them the same
requests. It verifies that on "hoff":
- "h2" is never negotiated via ALPN, whether it comes from the default
bind ALPN, an explicit "alpn" setting (even "h2" alone, which becomes
equivalent to "no-alpn") or a crt-list entry, while it is on "hon";
- an HTTP/1 frontend receiving the H2 preface responds a 405 instead of
being upgraded as it is on "hon";
- a "bind" line forcing "proto h2" closes its connections upon accept,
while it serves H2 on "hon";
- the h2_enabled sample fetch returns false, while it is true on "hon".
The upgrade is tested with haproxy itself as the H2 client because vtest
emits the preface again on the first "stream" block, and its "txpri" may
split it after the first empty line, which the H1 mux then parses as an
HTTP/1 request and rejects with a 400.
It should be backported with the "tune.h2.fe.enabled" setting and the
"h2_enabled" sample fetch.
Willy Tarreau [Mon, 12 Oct 2026 18:52:49 +0000 (18:52 +0000)]
MINOR: sample: add h2_enabled to report whether H2 may be used on frontends
With "tune.h2.fe.enabled" now able to disable HTTP/2 on frontends, users
may need to adapt some of their rules depending on whether or not HTTP/2
may be served to clients (filtering, headers, thresholds, redirects etc),
without having to keep them in sync by hand with the global setting.
This adds the "h2_enabled" sample fetch, which works like "quic_enabled":
it returns true only when HTTP/2 support was built in (USE_H2) and was not
disabled on frontends by "tune.h2.fe.enabled off".
This should be backported along with the "tune.h2.fe.enabled" setting.
Willy Tarreau [Mon, 12 Oct 2026 18:33:35 +0000 (18:33 +0000)]
MINOR: global: add tune.h2.fe.enabled to disable HTTP/2 on frontends
In case of trouble in the HTTP/2 stack, users currently have no simple way
to stop serving HTTP/2 to clients: the default ALPN of SSL "bind" lines
silently advertises "h2", explicit "alpn" settings have to be edited on
every "bind" line and crt-list entry, HTTP/1 connections starting with the
H2 preface are upgraded unless "option disable-h2-upgrade" is set
everywhere, and "proto h2" binds have to be found and changed.
This patch adds a new global setting, "tune.h2.fe.enabled", which defaults
to "on" and is stored as GTUNE2_DISABLE_H2_FE in tune.options2. When set
to "off", three layers are touched:
- h2 is prevented from being configured: "h2" is removed from explicit
alpn via alpn_remove_token() when proxies are finalized, as well as
from crt-list entries. The default ALPN (or the one derived from
"proto") is processed the same way in proxy_finalize(). If "h2" is
the only protocol, the string ends up empty, which is equivalent to
"no-alpn". Nothing changes on the data path: the SSL contexts are
created afterwards from the final strings.
- h1 is prevented from upgrading to h2 in proxy_finalize(), which sets
PR_O2_NO_H2_UPGRADE on HTTP frontends, so that the H1 mux responds
a 405 to the H2 preface as with "option disable-h2-upgrade",
indicating that method "PRI" is rejected;
- finally, h2_init() refuses frontend new connections, so anything that
cannot be fixed above (e.g. "proto h2" or NPN) is immediately closed.
The keyword is parsed in cfgparse-global.c so that it remains accepted
when building without USE_H2. Backend connections are not affected since
the main purpose it to provide an emergency switch to protect against an
exploitable flaw for example with limited impact. This may change later
with a new option if deemed useful.
One limitation is that the keyword must be seen before parsing "alpn"
keyword on "bind" lines, which is normally granted since "global" section
isn't supposed to appear after proxies. In any case, any residual case
would still be blocked by h2_init(), by closing the connection.
The goal is to offer an emergency kill-switch, so this is meant to be
backported to stable versions, along with the two preceding commits:
MINOR: ssl: add alpn_remove_token() to drop a protocol from an ALPN string
MINOR: global: add tune.options2 to host new GTUNE2_* flags
Willy Tarreau [Mon, 12 Oct 2026 18:31:38 +0000 (18:31 +0000)]
MINOR: global: add tune.options2 to host new GTUNE2_* flags
All 32 bits of global.tune.options are now in use, so new global tuning
flags cannot be added there anymore. Rather than widening this field,
which would require turning every GTUNE_* value into a 64-bit constant
(e.g. ~GTUNE_NO_TG_FD_SHARING would otherwise clear the upper bits),
let's add a second flags word, tune.options2, whose flags will be named
GTUNE2_*.
This is a preliminary step for the "tune.h2.fe.enabled" setting and may
have to be backported along with it.
Willy Tarreau [Mon, 12 Oct 2026 18:31:19 +0000 (18:31 +0000)]
MINOR: ssl: add alpn_remove_token() to drop a protocol from an ALPN string
This function removes all occurrences of a given protocol name from an
ALPN string in the binary form produced by ssl_sock_parse_alpn(), in
place, and updates its length. The string remains zero-terminated so that
the existing strstr() checks on it keep working, and it may end up empty,
which is then equivalent to "no-alpn". It returns the number of entries
removed.
It will be used by future patches to globally disable some protocols from
frontend ALPN strings at boot.
Willy Tarreau [Mon, 16 Nov 2026 14:56:55 +0000 (14:56 +0000)]
DEV: h2: mkhdr: support "--" as a delimiter between frame descriptions
Producing a sequence of different frames required one call per frame.
Now "--" may be used to delimit multiple frame descriptions on the same
command line. Each description is processed independently (options are
reset between them), and the resulting frames are emitted in the same
order. All descriptions are checked before anything is emitted, so that
an error in one of them doesn't produce a partial output. Empty
descriptions are rejected. Example:
$ dev/h2/mkhdr -t p -- -t s -- -t h -i 1-3 -f es,eh -e :method GET \
-- -t ping -R 0000000000000001 -n 2
Willy Tarreau [Mon, 16 Nov 2026 14:54:41 +0000 (14:54 +0000)]
DEV: h2: mkhdr: support stream ID ranges with -i
Opening many streams at once (e.g. to test the concurrent streams
limits) required one call per stream. Now "-i <first>-<last>" emits
the same frame(s) for each stream ID from <first> to <last> included,
in ascending order, only the stream ID differing between them. When
combined with -n, each stream's frame(s) are repeated <count> times
before switching to the next stream. All stream IDs of the range are
used, regardless of their parity.
Willy Tarreau [Mon, 16 Nov 2026 15:04:09 +0000 (15:04 +0000)]
DEV: h2: mkhdr: add -n to repeat the emitted frames
It's often needed to send the same frame many times (e.g. PING or
WINDOW_UPDATE floods, or many CONTINUATION frames), which used to
require calling the tool in a loop. The new "-n <count>" option emits
the resulting frame(s) <count> times in a row. The frame is built
only once and its output repeated. When used with -d, the whole
sequence of frames carrying the file is repeated. A count of zero
emits nothing. It's also accepted with the preface.
Willy Tarreau [Mon, 16 Nov 2026 14:53:44 +0000 (14:53 +0000)]
DEV: h2: add mkhdr.c, a C port of mkhdr.sh
mkhdr.sh forks several processes per frame, which makes it slow when
producing many frames (around 4ms per invocation here, vs 0.2ms for
the C version). This is a port of the script to C, accepting the same
options and producing byte-identical output for valid inputs, with a
few differences:
- the data file passed with -d is read in binary mode, so NUL bytes
are preserved (bash's "read" silently drops them);
- header names and values passed with -e may be longer than 127
bytes, as their lengths are now properly encoded as HPACK integers,
and backslash escapes are interpreted there as with -r, the length
being computed after unescaping;
- -r, -R and -e may be repeated and combined, their contents being
concatenated in their order of appearance to form the payload
(e.g. "-R 4 -r abcd" gives 04 61 62 63 64). An odd number of hex
digits in -R implies a leading zero;
- -e no longer forces the frame type to HEADERS, it only changes the
default type, so that -t always wins regardless of the option order
(the script would turn "-t c -e foo bar" into a HEADERS frame);
- -l always sets the frame's length field, which only defaults to the
payload's length (the script ignored -l when a payload was given).
This permits to emit a frame header alone and append its payload
separately, or to advertise a wrong length;
- options that would otherwise be silently ignored are rejected: any
option other than -e, -r or -R repeated, -t p with other options,
-d with -r/-R/-e;
- the "ACK" flag (0x01) is supported for SETTINGS and PING;
- unknown flags or invalid hex digits are reported as errors instead
of being silently ignored;
- the usage message describes each option on its own line, and is
sent to stderr on errors.
The output is emitted through a 64kB buffer so that frames are sent in
large blocks (stdio defaults to 4kB on pipes).
Willy Tarreau [Mon, 16 Nov 2026 14:53:27 +0000 (14:53 +0000)]
DEV: h2: add h2dec, a raw HTTP/2 frame decoder
mkhdr.sh produces raw HTTP/2 frames but nothing permits to decode them
back, nor to inspect a captured stream. h2dec reads a raw HTTP/2 byte
stream on stdin and prints one line per frame with the 9 header bytes
in hex followed by the decoded type, stream ID, length, flags and pad
length when present. An optional connection preface is detected.
For HEADERS, PUSH_PROMISE and CONTINUATION frames, the header block is
reassembled (padding, priority and promised stream ID are stripped),
and once END_HEADERS is seen, it is decoded with haproxy's own HPACK
decoder (as dev/hpack/decode does) and each field is printed indented
below the frame, in HTTP/1 form ("name: value"), pseudo-headers
appearing as ":name: value". Non-printable characters are escaped. A
single dynamic table is maintained for the whole input, whose size may
be changed with "-s".
Olivier Houchard [Tue, 17 Nov 2026 09:56:32 +0000 (10:56 +0100)]
BUG/MINOR: debug: Do not allocate context when we don't need one
In debug_parse_cli_sched(), when debug dev sched has been used with a
count of 0, do not bother allocating a context, as it will never be
used, and the memory will be leaked.
This is a minor problem that only affects a debug command used
incorrectly, and do not need any backport.
This was submitted by Alexandre Laroche, and should fix github issue
BUG/MINOR: quic: initialize the members read by quic_conn_release() first
qc_new_conn() allocates the CID tree before initializing ->flags, ->state
and ->prx_counters, while quic_conn_release(), called from its error path,
reads all three of them. On allocation failure, the release thus reads
uninitialized memory, and quic_conn_prx_cntrs_update() dereferences an
invalid ->prx_counters instead of returning early. This affects both
frontend and backend connections.
The backend ->prx_counters assignment has the same problem, as it is placed
after the RAND_bytes() call, which is another failure point.
This was introduced by commit b8cb8e1a6 ("BUG/MINOR: quic: fix counters
used on BE side"), which moved the assignment into the per-side branches,
after the first failure point. Move the CID tree allocation after these
initializations, and move the backend ->prx_counters assignment before
RAND_bytes().
BUG/MINOR: quic-be: do not register the connection before the quic_conn is initialized
qc_new_conn() stores the connection passed as argument in qc->conn before the
first failure points, while quic_conn_release(), called from its own error
path, BUG_ONs on a non-null ->conn. As the upper connection is still
allocated while qc_new_conn() runs, any failure after this point aborts the
whole process instead of returning an error. Only backend connections are
affected, as the frontend caller passes a NULL connection.
qc->conn cannot simply be removed from qc_new_conn(): it is dereferenced by
ssl_sock_srv_try_reuse_sess(), called from qc_alloc_ssl_sock_ctx() on the
backend side, to look up a reusable TLS session. The latter leaves
ctx->conn to NULL, unlike its non-QUIC counterpart ssl_sock_init(), which
forces ssl_sock_srv_try_reuse_sess() to fall back to qc->conn.
Pass the connection to qc_alloc_ssl_sock_ctx() so that ctx->conn is always
valid, and use it unconditionally in ssl_sock_srv_try_reuse_sess(). Then let
the caller register the connection, next to conn->handle.qc, once
qc_new_conn() has succeeded.
Commit ca5511f02 fixed this by setting ->conn only once the quic_conn was
fully initialized. Commit a83ed86b7, which reinstated the conn argument,
moved the assignment back into the initialization block and reintroduced
the bug.
BUG/MEDIUM: quic-be: keep the source port range of a closing backend connection
When a backend QUIC connection enters the closing state, qc_new_cc_conn()
moves its socket to a new quic_conn_closed instance. Since commit 02b768501
("MEDIUM: fd: Remove fdinfo"), the source port range used to bind that
socket is stored in qc->sport_range, but this member was not copied to the
closing connection, and the quic_conn_closed pool is not zeroed.
qc_release_fd() later installs qc->sport_range as the fd owner with
FD_OWNER_PR, so that fd_delete() gives the port back to its range. With an
uninitialized pointer, port_range_release_port() dereferences a wild address
and the process dies on a general protection fault; when the field happens
to be zero, the port is never released, so the range is exhausted after as
many connections and every new backend connection fails with
CO_ER_PORT_RANGE.
Copy the source port range to the closing connection, as is already done for
the other members it needs. It is always NULL on the frontend side.
This bug was introduced by commit 02b768501, so it only affects 3.5-dev4 and
later. No backport is needed.
BUG/MEDIUM: quic: do not keep 0-RTT packets which cannot be decrypted
On a listener with "allow-0rtt", a 0-RTT packet whose header protection
cannot be removed is queued in the 0-RTT encryption level pqpkts list and
its content is copied into the connection Rx buffer. That buffer is
reclaimed in order by quic_rx_pkts_del(), which stops at the first
referenced packet, so a queued 0-RTT packet pins all the data behind it.
Commit bba6baff3 ("BUG/MEDIUM: quic: prevent conn freeze on 0RTT
undeciphered content") addressed this by releasing these packets at
handshake completion, unconditionally. Commit b1af5dabf ("BUG/MEDIUM:
quic: avoid freezing 0RTT connections") then restricted that release to
the case where an address validation token was received: without a token,
the peer address is only validated by the handshake completion itself, so
the 0-RTT data are to be processed once the handshake is done.
That reasoning holds only if 0-RTT keys exist. When none were installed,
because the early data were rejected by the TLS stack or because the TLS
library does not support 0-RTT, the packets can never be decrypted, so
nothing releases them before the connection is freed. A 0-RTT packet
received after handshake completion is queued the same way, with even
less chance of ever being decrypted.
The Rx buffer then fills up and every packet of the connection is dropped
until the idle timeout, accounted as dropped_pkt_bufoverrun and shown as
dropbuff= in "show quic full". Since the buffer is reclaimed in order,
the whole connection stalls, not only the 0-RTT traffic.
Release the pending 0-RTT packets at handshake completion when there is
no 0-RTT RX secret, and drop 0-RTT packets received after handshake
completion without 0-RTT keys instead of queueing them.
This is a regression from b1af5dabf, so it must be backported to 2.9 and
above only.
REGTESTS: http-messaging: Properly handle WINDOW_UPDATEs with connect_tunnels
The last fix was incomplete. Depending on the timeout, with the third test,
two WINDOW_UPDATE frames can be receveid from the server instead of one
before receiving the response. Instead, explicitly wait for these two
WINDOW_UPDATE frames, the first one before sending tunneled data, and the
other one just after.
REGTESTS: http-messaging: Fix abortonclose issue with connect_tunnels
connect_tunnels.vtc script was fixed. The third test could be aborted before
the response was received if the connection to the server was not
synchronous. It appeared to be an issue, at least, on macOS. This happened
because C3 client was sending its tunneled data in a DATA frame carrying
END_STREAM, right after the CONNECT request. Depending on the timing, the
request could be aborted because "abortonclose" is now enabled by default.
To fix the issue, the END_STREAM flag is no longer set on the client DATA
frame. It is not mandatory for the test.
In addition, Barriers are now used instead of delay to make the frame
ordering deterministic.
Amaury Denoyelle [Mon, 16 Nov 2026 15:56:53 +0000 (16:56 +0100)]
BUG/MINOR: hq-interop: drop data after request
Strengthen hq-interop by silently draining any data following the
request. This ensures that a QCS instance won't be used to convey
multiple requests as this is undefined behavior.
This new check has been merged with the handling of a delayed standalone
FIN. This ensures that FIN is never forgotten, whether it is received
with or without extra data after the request.
This may be backported to stable releases if needed.
Amaury Denoyelle [Mon, 16 Nov 2026 14:15:29 +0000 (15:15 +0100)]
BUG/MINOR: hq-interop: skip zero-copy with large buffers
Large buffers were introduced in 3.4. They may be used in channels while
muxes continue to rely on normal-sized objects. In this case, zero-copy
must be disabled when sending data.
Most muxes were adapted but the hq-interop layer was forgotten. This
patch fixes this by adding a similar check to the one already present in
HTTP/3.
Olivier Houchard [Mon, 16 Nov 2026 16:27:00 +0000 (17:27 +0100)]
BUG/MEDIUM: stick-tables: compute the shard of string keys on the stored key
stksess_setkey_shard() hashes string keys on the raw sample length, while
the stored key is truncated to the table's "len" and stops at the first
NUL. Peers send and hash the stored key, so for longer keys the creating
node and its peers disagree on the shard, and entries are pushed to the
wrong peers.
Let's compute the shard on the stored key length. This was introduced in
2.7 by commit 36d156564 ("MINOR: peers: Support for peer shards") and
should be backported to all stable versions.
Gihyeon Ryu [Wed, 11 Nov 2026 10:00:12 +0000 (10:00 +0000)]
BUG/MINOR: mjson: bound the exponent in mystrtod()
The exponent is accumulated in an int without limit, so a long run of
exponent digits makes it wrap. Stop accumulating once it exceeds 100000:
the result is then already zero or infinite for a double.
This should be backported along with the previous patch.
Gihyeon Ryu [Wed, 11 Nov 2026 10:00:12 +0000 (10:00 +0000)]
BUG/MEDIUM: sample: parse json_query integers within the token length
For the "int" output type, sample_conv_json_query() converts the token
with strtoll(token, NULL, 0). The token points into the sample, which is
not NUL-terminated, and its length is ignored. When the input ends
inside a number (for example a truncated body '{"amount":1'), the
parsing goes on past the end of the sample, into the remaining bytes of
the buffer, which may hold digits left by a previous request, possibly
from another client. Those digits then become part of the returned
value, which may bypass a range check, or be reflected to the client.
Numbers using an exponent or a fraction are also misparsed ("1e5" gives
1).
The number is now parsed with mjson_get_number(), which stays within the
token, then range checked as a double before being converted. Truncation
of fractions is kept.
Amaury Denoyelle [Mon, 16 Nov 2026 08:52:34 +0000 (09:52 +0100)]
MINOR: h3: reject malformed push frames
MAX_PUSH_ID frames are ignored by haproxy, which does not support server
push and therefore never opens push streams. However, a legitimate
client may still emit such frames.
Implement minimal parsing via a new dedicated helper
h3_parse_push_frm(). If the frame is malformed, the connection is
immediately closed on error.
The same helper is also used for CANCEL_PUSH frames, although it is even
less useful here these frames are systematically rejected even if
well-formed because haproxy never initiates or allows push streams.
Amaury Denoyelle [Mon, 16 Nov 2026 09:23:02 +0000 (10:23 +0100)]
BUG/MINOR: h3: reject CANCEL_PUSH on backend side
CANCEL_PUSH frames are always rejected on the frontend side as haproxy
never emits PUSH_PROMISE frames.
Rejection must also be performed systematically on the backend side as
haproxy never emits MAX_PUSH_ID frames, hence any push IDs mentionned by
the server are invalid.
The outcome is the same on both sides: the connection is closed with
H3_ID_ERROR and a glitch is accounted.
Amaury Denoyelle [Mon, 16 Nov 2026 12:53:09 +0000 (13:53 +0100)]
BUG/MINOR: h3: skip content-length check on backend bodyless responses
Some specific HTTP responses are defined as having no content but with a
possible non-null content-length header value. This is the case for the
responses to HEAD requests or responses with status 204 or 304.
Prior to this patch, such responses were considered invalid due to
h3_check_body_size(), in opposition to the recommandation of RFC 9114.
This would result in a stream reset and an error reported to the client.
Fix this by detecting these bodyless responses and with the new stream
flag H3_SF_BODYLESS_RSP. This is performed during the request emission
in h3_req_headers_send() for HEAD method and during the response parsing
in h3_resp_headers_to_htx() for 204/304 status detection.
The final part of this change is to disable the check on body size in
h3_check_body_size() when the new flag is set.
Willy Tarreau [Mon, 16 Nov 2026 09:06:42 +0000 (10:06 +0100)]
MINOR: http-ana: also match text/event-stream with trailing parameters
Commit 5ff6ff1b7 ("MINOR: http-ana: automatically enable http-no-delay
for streaming events (SSE)") added detection for SSE, but as reported
in GH issue #3574, it fails when there's a parameter after the content
type because we're using an exact match. Let's instead use istmatchi()
that will check the beginning of the string (which is sufficient here).
Willy Tarreau [Mon, 16 Nov 2026 09:02:53 +0000 (10:02 +0100)]
DEV: sse-latency: add a parameter after the content-type
As reported in GH issue #3574, we're currently using an exact match for
text/event-stream, and it fails to match when a parameter is appended.
Let's add one here to trigger this problem.
Without the parameter:
=== gateway overhead (gateway minus loopback; negative = loopback noise) ===
emit->recv (1st token) mean +0.046ms p50 +0.046ms p95 +0.046ms p99 +0.046ms
emit->recv (tokens) mean +0.214ms p50 +0.234ms p95 +0.305ms p99 +0.322ms
TTFT (client) mean +0.493ms p50 +0.493ms p95 +0.493ms p99 +0.493ms
inter-token (client) mean -0.001ms p50 +0.230ms p95 +0.283ms p99 +0.299ms
With the parameter:
=== gateway overhead (gateway minus loopback; negative = loopback noise) ===
emit->recv (1st token) mean +214.379ms p50 +214.379ms p95 +214.379ms p99 +214.379ms
emit->recv (tokens) mean +303.484ms p50 +307.784ms p95 +405.797ms p99 +413.876ms
TTFT (client) mean +214.775ms p50 +214.775ms p95 +214.775ms p99 +214.775ms
inter-token (client) mean -0.026ms p50 -1.069ms p95 -1.260ms p99 -1.271ms
Let's backport this to 3.4 since sse-latency was backported there, and to
any version containing a backport of 345aa2b73 ("DEV: sse-latency: add a
latency measuring tool for SSE response streams")
Willy Tarreau [Mon, 16 Nov 2026 08:05:39 +0000 (09:05 +0100)]
MEDIUM: compression/slz: use the event content type for server-sent events
libslz's SLZ_CT_EVENT content type keeps the last 2 kB of a stream and its
reference table between calls, in a ring which the application allocates
(slz_ring_size bytes, zeroed) and sets in the stream. Server-sent events
now compress to ~4% instead of ~102% (inflating by ~2%).
A new pool "slz_ring" is created at boot with the size exported by
libslz, aligned on a cache line. The slz init functions allocate a zeroed
ring from it for COMP_CT_EVENT, unless "tune.comp.res.ring" is off, and
select SLZ_CT_EVENT, and comp_rfc195x_end() releases it. The pool is
created before the configuration is parsed, but stays empty when the
setting is off. If the pool or the ring can't be allocated, or the
compression level is 0, the default encoding is used, as the text tree
would have to send its header after each event. The support is detected
by the slz_ring_size macro, for older external versions of libslz.
Through haproxy, 942 events of a real capture from llama-server sent
10 ms apart, with gzip compression:
Content-Type output ratio
text/x-sse 265120 101.75% # previous default text compression
text/event-stream 10578 4.06%
Synthetic tests using the sse-latency tool shows this with 1000 tiny
messages:
bytes in bytes out ratio
before: 227584 199829 88%
after: 227584 20680 9%
Willy Tarreau [Sun, 15 Nov 2026 21:49:19 +0000 (22:49 +0100)]
MINOR: compression: add tune.comp.res.ring to disable the rings of responses
Some algorithms may need a ring to keep a history between flushes for
some responses, such as the upcoming support of server-sent events with
SLZ's event content type, which costs about 4 kB per stream. This new
global setting "tune.comp.res.ring" will allow to disable it ('off') to
save that memory, in which case these responses are compressed as if
their type were unknown. It is enabled by default ('on'). It's not used
yet, the next commit will make use of it.
The keyword is accepted whatever the algorithms and libraries, so that a
configuration doesn't depend on the build options.
Willy Tarreau [Sun, 15 Nov 2026 21:42:06 +0000 (22:42 +0100)]
MINOR: compression: pass COMP_CT_EVENT to the algorithms for server-sent events
Server-sent events ("text/event-stream"), as emitted by AI and API
gateways, are made of small events that are flushed one at a time, each
of which repeats most of the previous one. Compressing them one at a time
without any history is useless, but an algorithm may handle them
differently if it knows about them.
select_compression_response_header() now sets the content type to the new
COMP_CT_EVENT when the Content-Type header starts with "text/event-stream".
Requests are left untouched: server-sent events only exist in responses,
and since an algorithm may need memory for this content type, clients
must not be able to force it. The algorithms don't make use of it yet and
treat it as COMP_CT_GENERIC.
This already improves the compression ratio for SSE to be below unity:
bytes in bytes out ratio
before: 227584 232303 102%
after: 227584 199829 88%
Willy Tarreau [Mon, 16 Nov 2026 07:53:51 +0000 (08:53 +0100)]
IMPORT: slz: update slz to 1.4-dev5-24
This fixes a risk of oversized output at level 3 or text, includes
automatic switching between fixed and text trees at levels >= 2 and
with CT_TEXT, and introduces support for a ring for short repetitive
events compression (e.g. SSE).
Aleksandar Lazic [Fri, 30 Oct 2026 23:31:38 +0000 (00:31 +0100)]
DOC: config: explain the effect of the weights on random's draws
"balance random" draws the servers on the consistent hash ring, where a
server gets 16 points per unit of weight. With the default weight of 1,
the shares of the ring are uneven (between about 2% and 4% for 32
servers, computed from the ring), so some servers are drawn twice as
often as others. Using the same higher weight for all servers, such as
100, makes the shares almost even.
Measured on 32 servers with 4 slow ones (with the peak EWMA option under
review, which compares the response times of the drawn servers), raising
the weight of all servers from 1 to 100 brought the share of the
requests sent to the slow servers from 2.0% to 1.5%, the same as a
uniform draw.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Aleksandar Lazic <al-haproxy@none.at>
Willy Tarreau [Fri, 13 Nov 2026 09:39:55 +0000 (10:39 +0100)]
MEDIUM: backend: avoid picking the same server twice in random draws
Aleksandar Lazic suggested [1] that the random() distribution could
be improved to avoid picking the same server twice, comparing it with
itself and choosing it, possibly even if suboptimal. His mesurements
showed that a slow server was picked more often than desired.
It turns out that we don't need extra draws to avoid this situation,
because get_server_rnd() uses chash_get_server_hash(), which supports
a server to avoid (normally used for redispatch, but usable here as
well to avoid picking the same server twice), so we can pass there the
pointer to the currently chosen best server and count on the function
to pick another one.
Before the patch, a config with 1 slow server responding in 50ms,
and N-1 fast servers responding in 5ms would give this distribution
for 100k requests at 100 concurrency:
It's clear that the distribution is much better and follows the ratios
of response times, with little to no difference in maximum server load,
thus being much closer to a leastconn algo. The average rate is also
better, +33% for 4 servers and +5% for 8.
Note that in order to avoid wasting CPU cycles in degenerate farm cases,
the two previous patches are strongly recommended:
OPTIM: lb-chash: don't look for more servers when there is only one
OPTIM: lb-chash: limit the scan to few consecutive nodes
Willy Tarreau [Fri, 13 Nov 2026 13:17:29 +0000 (14:17 +0100)]
OPTIM: lb-chash: limit the scan to few consecutive nodes
Strongly imbalanced configs such as one server of weight 256 and another
one of weight 1 can result in high CPU usage with consistent hashing when
the first attempted server is the one to be avoided, or when affinity is
set to maxconn or maxqueue, because in this case, the frequent server may
appear a lot of consecutive times, on average 256 after a node before
meeting the other server, and if terribly unlucky, 4096 times.
Also in properly balanced farms, all servers are more or less well
distributed, so that after visiting a number of them we've seen them
all.
This patch takes this into account to avoid too long scans of the whole
tree caused by such imbalances. What it does is:
- limit the search of another server to 3 consecutive nodes of the
same server. If this happens, the tree is severely imbalanced so
there's no point looking for another server: not only will this
take a lot of time, but it may even result in a lot of traffic
being transferred to it at ratios well above the weights ratios ;
- limit the search of an eligible server to twice the number of servers
in the farm, considering that once we've witnessed 2N server changes,
it's fairly unlikely that a remaining server is worth being considered
beyond that point (as a reminder, each server is present 16 times).
For the last point we could also have decided to stop based on the
distance, e.g. 1/8 of the whole spectrum, but it would be more
probabilistic and there it remains understandable.
Willy Tarreau [Fri, 13 Nov 2026 10:06:31 +0000 (11:06 +0100)]
OPTIM: lb-chash: don't look for more servers when there is only one
The chash_get_server_hash() function never makes a special case for a
single server. Worse, when asked to avoid a specific one and it is the
only one, or when the chosen server is not eligible, the function will
run over all its positions at the end. Thus having a single server in
a config with a weight 256 and asking to avoid it burns a lot of CPU.
Let's just test for this case after picking the first server. If the
total servers count is 1, we can just leave.
Amaury Denoyelle [Fri, 13 Nov 2026 15:55:32 +0000 (16:55 +0100)]
BUG/MEDIUM: mux_quic: fix Rx flow control increment on RESET_STREAM
Since the following patch, on RESET_STREAM frame reception, its final
size field is used to account for non-received data in the connection
flow control.
This addition is not correct as it uses the read offset of the QCS
instance instead of the maximum offset already checked in flow control.
Over time, there is a risk to report a flow control violation despite
legitimate client usage.
Fix this by using the proper QCS field in the flow control calculation
check. Note that accounted data for MAX_DATA emission is still based on
the QCS read offset though.
This must be backported up to 2.8, after the above-mentioned patch.
Gihyeon Ryu [Wed, 11 Nov 2026 10:00:12 +0000 (10:00 +0000)]
BUG/MINOR: log: don't let an LF in a forwarded message create new events
A message received by a log-forward section over UDP or over TCP with
octet counting may contain CR or LF bytes. They are forwarded as is to
line-based outputs (rings, tcp@ servers, stdout/stderr), where each LF
starts a new event. A sender can then forge complete syslog lines with
any host name and program, which also defeats "option host".
syslog_process_message() now replaces every CR and LF but the trailing
ones with a space before parsing, so each received message gives one
line.
Gihyeon Ryu [Wed, 11 Nov 2026 10:00:12 +0000 (10:00 +0000)]
BUG/MINOR: http-ana: don't emit a network-path Location for a "/" redirect prefix
With the special prefix "/" (redirect prefix /, or server ... redir /),
or a log-format prefix which evaluates to an empty string, the Location
header is the request path alone. A request for "//evil.example/x" or
"/\evil.example/x" then gives "Location: //evil.example/x", which
browsers resolve to another host: an open redirect on a rule which is
only meant to keep the client on the same site.
When nothing is written before the path and it starts with "//" or "/\",
"/." is now written first. "/.//evil.example/x" resolves to the same
path on the same host. Prefixes which write something are unchanged.
Gihyeon Ryu [Wed, 11 Nov 2026 10:00:12 +0000 (10:00 +0000)]
BUG/MINOR: sample: reject a \0 byte in raw string fetches
These fetches return a string pointing to the raw client data, which may
contain a \0 byte, while string consumers rely on it not happening
(37204a71a). The pattern tree lookup used by case-sensitive "-m str"
matches and by maps stops at this byte, so "user\0admin" matches "user",
while the next hop sees the whole value. A rule based on these fetches
can then be bypassed.
req.ssl_sni and req.rdp_cookie now fail on such a value, and
req.ssl_alpn and req.body_param skip it and report the next one.
Legitimate values never contain a \0.
Gihyeon Ryu [Wed, 11 Nov 2026 10:00:12 +0000 (10:00 +0000)]
BUG/MINOR: sample: fix host_only and port_only on empty input
sample_conv_host_only() and sample_conv_port_only() scan backwards from
area + data - 1. With an empty sample whose area is NULL, as returned by
req.body for a request without a body, this pointer is (char *)-1, the
first dereference faults and the worker dies (SIGSEGV, also in release
builds). A configuration applying these converters to req.body can thus
be stopped by a plain "GET /".
Both converters now return early on an empty input, with an empty string
and 0 respectively.
Amaury Denoyelle [Fri, 13 Nov 2026 15:27:57 +0000 (16:27 +0100)]
BUG/MINOR: h3: prevent missing request FIN on empty trailers
Since the following patch, HTTP/3 trailers are only decoded when the
stream HTX buffer is empty, with previous data already consumed by the
upper layer. This is the simplest reason to ensure there is always
enough space for trailers decoding.
However, this check is also performed for an empty trailers frame, which
is unnecessary and thus suboptimal. Worse, QCS demux is blocked but when
it is woken up there is nothing left to decode as the empty trailers
frame header was already consumed and the demuxer starts on a new frame.
The trailer frame and its FIN signal are thus dropped.
To fix this, simply bypass the check on HTX buffer if the trailers frame
is empty. EOM is then reported and the rest of the frame parsing is
skipped.
Note that h3_resp_headers_to_htx() has a similar check. However, an
HTTP/3 headers frame cannot be empty as it must contain mandatory
pseudo-headers, thus an empty headers frame is rejected earlier.
Amaury Denoyelle [Fri, 13 Nov 2026 15:09:03 +0000 (16:09 +0100)]
BUG/MINOR: quic: remove CID on BE conn alloc failure
A QUIC backend connection is instantiated in qc_conn_init() via
xprt_quic. First, a random CID is generated and inserted into the tree.
On success, the quic-conn instance is allocated.
If the allocation fails, the CID is freed but not removed from the
global CID tree. This may cause a UAF issue later. Fix this by removing
the CID from the tree prior to freeing it.
BUG/MINOR: cache: skip already resolved filters when resolving caches
This is a latent bug with no visible impact today: when a proxy uses
several caches, resolving the second cache's name reads the first cache's
structure as if it were a string.
post_check_cache() resolves the caches one after the other, and for each
of them walks the cache filter configurations of all the proxies with
cache_postcheck_flt(), which compares the cache's name with cconf->c.name.
But c is a union: once a configuration is resolved, CACHE_FLT_INIT is set
and c.cache points to the cache, whose structure is then compared as a
string with the name of the next cache. This currently reads the first
bytes of the cache's first tree root, which are NULL at boot, so it never
matches, but any change to the layout of struct cache or to the moment
this runs could make it match or read past the structure.
The configurations already resolved, i.e. flagged with CACHE_FLT_INIT, are
now skipped.
This patch may be backported. If so, it must be adapted because this part
was reworked on 3.5.
BUG/MEDIUM: mux-h1: Report EOS when a demux error is handled by the app layer
Since 30ca6e01 ("BUG/MEDIUM: mux-h1: Don't close the connection on a payload
parsing error"), a demux error is reported as EOI on the SE when the stream
connector is still attached, leaving the app layer handle the error via the
htx flags and the termination events. But this is not enough for consumers
waiting for more data, such as health checks: tcpcheck_eval_recv() loops
while neither EOS nor ERROR is reported, and the mux does not provide any
data anymore after a demux error. Thus a health check waits until its
timeout and reports an L7TOUT instead of an immediate invalid response.
This is especially annoying because a server returning random data instead
of a valid HTTP response is reported as a timeout.
To fix the bug, SE_FL_EOS is now also reported on the SE. It does not carry
the error itself, which is still reported via the termination events and
consumed via the HTX flags. It only reports that no more data will be
received, which is true because the demux error is sticky. This is also
what mux-h2 does (h2s_propagate_term_flags()). The 400-response path in
streams is preserved because the close forwarding is gated by SC_FL_NOHALF,
which is never set on the front stream connector.
This fix must be backported as far as 2.6, but without 30ca6e01, which is
not needed on older versions. There, the demux error is always reported as
EOI on the SE and SE_FL_ERROR is never set. On 3.0 and 2.8, SE_FL_EOS is
only reported when there is no stream connector attached to the h1s, it
must also be reported when the stream connector is still attached. On 2.6,
SE_FL_EOS is never reported, it must be set in addition to SE_FL_EOI.
Olivier Houchard [Fri, 13 Nov 2026 14:39:34 +0000 (15:39 +0100)]
BUG/MEDIUM: fd: Mark a fd as dead on early close
Commit ad082111a04b4387f8aa76e386a2f340f9583bd2 made it so
conn_ctrl_close() will close a fd, if no xprt was created, because
nobody else would do it for us. But this is not entirely true, some code
paths, such as the checks, if connection failed, will take care of
closing the fd already, and doing it in conn_ctrl_close() will lead to a
second close, that may close an unrelated fd.
Fix that by changing the fd to DEAD_FD_MAGIC so that conn_ctrl_close()
knows the fd has already been closed, and don't have to do it.
It would probably be cleaner to just remove those calls to close(), and
always let conn_ctrl_close() do it, but for that we'd have to make sure
conn_ctrl_close() is always called, and that close to the release, I'd
rather go the safer way.
Amaury Denoyelle [Fri, 13 Nov 2026 10:42:29 +0000 (11:42 +0100)]
BUG/MINOR: init: fix missing error on no listener on config check
Since the conversion of the list of proxies, sinks and logs from a plain
linked list to a full struct list type, config check would not report an
error anymore if no listener is present.
This is caused because iterations are now performed via
list_for_each_entry() without producing a final NULL iterator value. Fix
this by using a plain boolean set during the loop and check its value at
the end instead of inspecting the iterator itself.
Amaury Denoyelle [Fri, 13 Nov 2026 09:47:56 +0000 (10:47 +0100)]
BUG/MINOR: qmux: remove invalid BUG_ON() on empty record
In QMux, a BUG_ON() was present in receive path to report about a
realign needed but not implemented. This is not necessary anymore as
realign is now implemented.
Worst, BUG_ON() could be triggered when receiving an empty record. Such
records are not (yet?) prohibited by the spec. Simply remove the
BUG_ON() to avoid any issue with it.
Amaury Denoyelle [Thu, 12 Nov 2026 17:48:14 +0000 (18:48 +0100)]
BUG/MINOR: quic: fix ACK_ECN parsing after optional ack ranges
QUIC acknowledgements are conveyed in ACK and ACK_ECN frame types. The
latter shares a similar structure, but also contains 3 varints at the
end related to explicit congestion notification.
The following patch differentiates ACK and ACK_ECN to ensure the latter
is correctly parsed.
However, ACK_ECN frame parsing is incorrect if the optional ack range
field is present. This patch fixes it by restoring a common parsing
function for ACK and ACK_ECN, which extracts only the first fields prior
to the optional ack ranges. ECN fields are now parsed later, at the end
of qc_parse_ack_frm(), after the optional ack ranges.
REGTESTS: cache: cover the object lifetime with a single script
The fixes about the object lifetime have no dedicated script each: the
reg-test reg-tests/cache/lifetime.vtc covers the whole lifetime
computation:
- the lifetime comes from s-maxage, max-age, Expires, or falls back to
the cache's max-age when the response has a validator (heuristic
lifetime);
- a null lifetime, written as "max-age=0", "max-age=00", a quoted
"max-age=\"0\"" or a null s-maxage, prevents the response from being
served from the cache;
- the Age received from the server reduces a relative lifetime but not
an absolute one given by Expires;
- "Age: 0" is a valid value, it does not prevent the response from being
cached;
- the Age of a copy delivered by the cache stays below the lifetime
announced by the server;
- the Age header of a stored response is still forwarded to the client
the response is delivered to, and the copies carry a single, freshly
computed Age header.
All the checks are made from the response headers, without any delay: the
X-Age-Relative header is set by an http-after-response rule on the
responses delivered from the cache whose Age reaches the max-age
announced by the server, which can only happen when the entry lifetime
was not reduced by the Age. X-Age-Count reports the number of Age headers
to check the forwarded response and the copies.
The script fails when any of the covered fixes is reverted, and it runs
in a few milliseconds.
BUG/MINOR: cache: do not ignore null lifetimes not written as "max-age=0"
A response carrying "Cache-Control: max-age=00", "max-age=\"0\"" or
"s-maxage=00, max-age=60" is delivered from the cache for the whole
max-age of the cache (60 seconds by default) or for the max-age, while
its null lifetime means it must not be reused without revalidation.
Clients thus receive outdated contents. Such forms are unusual but valid
(RFC 9111#1.2.2 and #5.2 allow leading zeroes and quoted values).
http_check_response_for_cacheability() only recognizes the exact forms
"max-age=0" and "s-maxage=0" as null lifetimes. Other forms are taken as
freshness information, and then http_calc_maxage() only considers values
strictly greater than zero, so a null value is ignored and the next
source of lifetime is used: max-age after s-maxage, Expires, or the
cache's max-age.
http_calc_maxage() now uses s-maxage and max-age as soon as they were
found, including when they are null, and the store action does not store
a response whose remaining lifetime is null, since it would already be
expired. This last check also avoids storing responses with an Expires
date in the past, which were stored expired.
This patch may be backported to all supported versions. It depends on
the previous fixes to http_calc_maxage() ("BUG/MINOR: cache: reduce the
max-age lifetime by the response's Age" and "BUG/MINOR: cache: compare
the Age to the heuristic lifetime when none is given"), but only for
context, the change is easy to adapt.
BUG/MINOR: cache: compare the Age to the heuristic lifetime when none is given
A response carrying a validator (Last-Modified or ETag) but no explicit
lifetime (no max-age, s-maxage nor Expires) is normally stored for the
cache's max-age. But as soon as such a response carries an Age header
with a non-null value, which is the case of all responses coming through
an upstream cache, it is never stored, which only affects performance and
the load of the servers.
When the response has no explicit lifetime, http_calc_maxage() returns the
cache's max-age but leaves the true max age untouched, i.e. zero. The
store action then refuses the response because its Age is greater than
this "true max age" of zero, as if it was stale.
When no explicit lifetime is found, the cache's max-age is used as a
heuristic lifetime (RFC 9111#4.2.2), so it is now also reported as the
true max age, and as a lifetime relative to the response's generation,
like max-age, so that the Age is deducted from it by the previous fix. A
response whose Age exceeds the cache's max-age is still refused.
This patch may be backported to all supported versions, along with the
previous one ("BUG/MINOR: cache: reduce the max-age lifetime by the
response's Age") on which it depends.
BUG/MINOR: cache: reduce the max-age lifetime by the response's Age
A response received with "Cache-Control: max-age=3" and "Age: 2" is kept
fresh in the cache for 3 seconds, and delivered with an Age reaching 4 or
5 seconds, while it only had one second of freshness left. In general,
responses coming through upstream caches are kept fresh for as long as
their Age in excess, at most the cache's max-age, which delivers stale
contents to clients, against RFC 9111#4.2. Clients may see outdated
versions of resources for longer than what the origin server specified.
The expiration date of an entry is computed as the reception date plus
the lifetime returned by http_calc_maxage(), capped by the cache's
max-age. The Age header is parsed afterwards, only to refuse responses
whose Age already exceeds their lifetime, and to compute the Age header of
the copies. But a lifetime given by max-age or s-maxage counts from the
generation of the response at the origin, so the time already spent in
upstream caches, given by Age, must be deducted from it. A lifetime given
by Expires is an absolute date and must not be reduced.
http_calc_maxage() now also reports through a new argument whether the
lifetime comes from s-maxage or max-age, and in this case the effective
lifetime is reduced to what remains after deducing the Age.
This patch may be backported to all supported versions.
BUG/MINOR: cache: do not eat the request while waiting for a buffer
The cache applet's I/O handler leaves through the "exit" label when it
cannot allocate its input or output buffer, when one of these buffers is
still pending or when the output buffer is full. But "exit" eats the whole
request with b_reset(&appctx->inbuf), and the request can still be needed on
the next call. For instance, in the HTX_CACHE_HEADER state, the handler
reads the request start line to know whether it is a HEAD request.
The input buffer is empty at this point, and appctx_release_buffers() also
frees it while it has no data, so http_get_stline() may return NULL and the
process crashes. This requires the output buffer allocation to fail exactly
after the request was received, which is rare since the buffers reserve
covers most transient failures, hence a latent bug.
Add a dedicated "wait" label for these paths: it flushes the pending HTX
message to the output buffer and returns without touching the request. The
"exit" label is kept for the states where the request must be consumed:
EOS/error, fast-forward blocked by the consumer, and the end of the
response.
This was introduced when the applet got its own buffers by commit 863417292
("MAJOR: cache: Update HTTP cache applet to handle its own buffers") in
3.0-dev3, so the fix should be backported to 3.0.
A debug patch forcing a single output buffer allocation failure on the
first call in the HTX_CACHE_HEADER state reproduced the crash with ASAN
on the htx_sl_req_meth() line; with this fix, the GET and HEAD requests
all succeed and the process stays alive.
BUG/MINOR: cache: recognize null qvalues with decimals in Accept-Encoding
With "process-vary on", a client refusing an encoding with a null weight
written with decimals, such as "Accept-Encoding: gzip;q=0.0, deflate", may
be delivered a cached gzip-encoded response, that it explicitly refused
and may not be able to decode. Only the client issuing such a request is
affected, it receives an encoding it cannot process.
The accept-encoding normalizer builds a bitmap of the accepted encodings,
from which the ones with a null weight are removed. A null weight was only
detected when the parameter was exactly "q=0", while RFC 9110#12.4.2
defines a qvalue as ( "0" [ "." 0*3DIGIT ] ) / ( "1" [ "." 0*3("0") ] ),
so "q=0.", "q=0.0", "q=0.00" and "q=0.000" are null weights as well. They
were considered as non-null, the encoding was accepted and a cached
response with this encoding matched the request's secondary key.
The weight is now considered null when "q=0" is only followed by an
optional dot and zeroes.
The reg-test reg-tests/cache/vary_accept_encoding.vtc is extended: it
stores a gzip response then sends requests refusing gzip with "q=0.0" or
"q=0.000". It fails without the fix since the cached gzip response is
delivered.
This patch may be backported to all supported versions.
BUG/MINOR: cache: do not remove the Age header from the forwarded response
When a response carrying an Age header is stored in the cache, the header
is removed from the response itself, so the client which triggered the
storage receives the object without its Age header, as if it had just
been produced by the origin server, while it may have been sitting in an
upstream cache for a long time. This client may then keep it fresh for
longer than allowed. Worse, when the storage finally fails after this
point (headers too large, unknown content-encoding with Vary, no room in
the cache...), the header is lost although nothing was stored. Copies
delivered from the cache are not affected, they carry a freshly computed
Age header.
The Age header was removed with http_remove_header() from the live
response, just so that the headers copied into the cache entry do not
contain it, since the applet adds its own when delivering the object.
Instead of altering the response, the Age headers are now simply skipped
when the headers are copied into the entry. The ETag offset is computed
from the copied data so it remains correct. This also removes all the Age
headers from the stored copy and not only the first one, so a copy is now
always delivered with a single Age header.
Thi patch fix may be backported to all supported versions. In versions
before 3.5, the removal is done unconditionally (no hints-only mode) but
the fix is the same.
BUG/MINOR: cache: do not refuse to store responses with "Age: 0"
Responses carrying an "Age: 0" header are never stored in the cache. This
header is commonly emitted by an upstream cache or CDN delivering an object
it just fetched, so in a setup chaining caches, the haproxy cache simply
never stores these objects and all requests for them reach the servers,
which only affects performance and the load of the servers.
The Age value is parsed with strl2llrc() and only accepted when strictly
positive, any other case jumping to the "out" label as an invalid value.
Zero is a perfectly valid Age value (RFC 9111#5.1), it is not stale and
needs no special treatment, so it is now accepted like positive values.
Negative or non-numerical values are still considered invalid.
This patch may be backported to all supported versions.
BUG/MEDIUM: filters: order the implicit filters around the explicit ones
In the legacy filter mode, flt_reorder_implicit_conf() reordered the
implicitly declared core filters but pinned the explicitly declared core
filters in their declaration position, treating them as segment
boundaries. An implicit filter bucketed after an explicit core filter
ended up in a wrong position: with an explicit "filter compression"
declaration followed by cache rules, the implicit cache-store filter
was placed after the compression filters, and the configuration checks
reported bogus errors:
proxy 'li': unable to enable the compression filter on response
before any cache filter.
proxy 'li': unable to enable the compression filter before the
cache 'c'.
while this configuration is valid: the implicit cache filter must be
placed at its canonical position, before the explicit compression
filters.
Explicitly declared core filters are now placed in the "any other
filter" class, like any explicitly declared filter: their manual
placement among the explicit filters is the user's responsibility, and
only the implicitly declared core filters are moved to their canonical
position. The placement policy is implemented in flt_order_class(),
which returns the "any other filter" class for an explicit core filter.
The order checks reporting conflicts between the compression,
decompression and cache filters are updated accordingly: an order
error is only reported when the filters involved are explicitly
declared. A filter that is automatically ordered never conflicts with
an explicitly declared one, since the reordering places them correctly
relative to each other.
BUG/MEDIUM: cache: forbid cache rules in defaults sections
A "cache-use" or "cache-store" rule declared in a defaults section has
never worked: the implicit cache-store filter it creates is attached to
the defaults section itself, where the "filter" directive is not
supported. The filter is never resolved, and the rule inherited by the
proxies references a configuration pointing at an unresolved cache name
instead of a cache, which leads to crashes or silently broken caching
depending on the filter mode of the proxies.
Supporting these rules with the legacy filters would require a deep
rework of the rule-to-filter binding, hard to backport. So, until the
new filter API covers this case, the rules are simply forbidden in a
defaults section, with an explicit alert:
[ALERT] : Proxy 'd': 'cache-use' rules are not supported in a defaults section.
This patch must be backported to all supported versions.
BUG/MEDIUM: cache: do not create a second applet when two cache-use rules hit
A configuration with two "http-request cache-use" rules that may both find
the requested object, for example two caches both fed by unconditional
"cache-store" rules, or a cache-use rule in a defaults section that is
repeated in the proxy, leaks memory and cache space on every request that
hits both of them. Each such request leaks one appctx and its task (about
1kB on x86_64) and leaves the row of the first cache's entry retained
forever. The memory grows with the number of requests until the process is
restarted, which affects the system owner, and the rows retained this way
can never be evicted anymore: once their entry expires, their blocks are
lost and the cache progressively shrinks, until it cannot store anything.
Any client may trigger this by simply requesting cached objects. With
2000 requests, "show pools" reports 2016 appctx used and "show cache"
reports a refcount of 2000 on the entry, which stays like this after all
the streams are gone.
The cache-use action is not a final one. On a hit, it sets s->target to
the cache applet and creates the applet on the back stream connector with
sc_applet_create(), after retaining the entry and detaching its row. The
next cache-use rule is still evaluated and, when it also hits, it calls
sc_applet_create() again on the same stream connector. The new appctx
takes the same sedesc, so the first one is not referenced anymore: it was
woken up once, found no request in its input buffer and waits for one
forever. Its release callback is never called, so the entry it retained is
never released and its row never reattached to the avail list.
Let's simply ignore the cache-use rule when the stream already has a
target: the response will be produced by the applet that is already
there. This is consistent with the stats applet that is only set up when
s->target is NULL. An alternative would be to make the action final on a
hit, but this would change the evaluation of the following rules for all
users. Note that "use-service" has the same weakness, it creates its
applet without checking whether one is already attached, so a cache hit
followed by a matching use-service rule could leak the cache applet the
same way. This one is left as is since use-service is a final action and
mixing it with a cache hit is not a sensible configuration.
This patch should be backported to all supported versions. In older versions,
http_action_req_cache_use() may register the applet with a different
function (si_register_handler(), stream_int_register_handler()) but the
fix remains the same: return ACT_RET_CONT at the beginning of the function
when s->target is set.
BUG/MEDIUM: cache: fix "show cache" crash/skip with several caches
With "show cache" cli command, a crash could be experienced when several
caches are configured. This happened when iterating on the second cache in
the list. Indded the cache tree array was not reset when the dump of a cache
was finished, leading to computing the cache tree index against the wrong
cache tree and to lock the wrong cache tree.
This is a regression introduced by the resumable CLI output.
Fix it by clearing ctx->cache_tree when the dump of a cache finishes: the
pointer must only be non-NULL while the dump is paused on the cache it
belongs to.
This patch must be backported to all supported versions.
BUG/MAJOR: cache: do not mix variants varying on different headers
With "process-vary on", a variant of a resource stored for one client may
be delivered to other clients it was not meant for. This happens when the
server does not always vary on the same headers for a given resource,
which is very common: CORS implementations typically add "Vary: origin"
only when the request carries an Origin header. If a first variant varying
only on accept-encoding is stored, then a client sending
"Origin: https://evil.example" gets a response varying on
"accept-encoding, origin" with "Access-Control-Allow-Origin:
https://evil.example", this response is stored with a null hash for the
origin, and is then delivered from the cache to every client whatever its
Origin header. Any client can thus poison the cache for all the other
clients of the resource, breaking the CORS checks of legitimate sites
(availability of the service for these users) or, with Referer, mixing
contents meant for different referrers. The same may happen without any
malicious intent.
When an entry already exists for the primary key, cache-use builds the
request's secondary key only for the headers of the first entry's
signature, the hashes of the other headers being zero-filled. It then
compares this key with each variant. On a miss, the same key is kept in
the transaction and reduced with the response's signature by
cache-store, which expects it to be complete, so the new variant is
stored with zeroes for the headers that were not part of the first
signature. Subsequent lookups build their keys the same way, so the
zeroes match whatever the request's Origin or Referer.
The fix consists in always building the complete secondary key on lookup,
as is already done when there is no entry yet, and in reducing it to the
signature of each variant before comparing it to the variant's key, which
is how the variant's key was built when it was stored. This is done by a
new function, secondary_key_entry_cmp(), used by get_secondary_entry(). A
variant varying on Origin is thus only delivered to requests carrying the
same Origin, and variants varying on different headers can all be found.
On the store side, get_secondary_entry() is passed the key already
reduced to the response's signature, so reducing it again to the
signature of an existing variant does not change the comparison for a
variant with the same signature. Note that a request with a duplicate
Origin or Referer header now never uses the entries of a resource which
has variants, as it already happened when the resource had no entry yet.
The reg-test reg-tests/cache/vary_signature_change.vtc reproduces the
scenario above with an "evil" and a "good" origin and checks that each
variant is delivered to the right requests only. Without the fix, the
request with the good origin receives the evil variant.
This exists since the Vary support was introduced by commit 1785f3dd9
("MEDIUM: cache: Add the Vary header support") in 2.4-dev2, so the fix
must be backported to all supported versions. The severity is set to
MAJOR because this is a cache poisoning that any client can trigger, but
it requires "process-vary on", which is not the default.
BUG/MEDIUM: mux-fcgi: put BE conn back in idle list after deferred shut
When a stream cannot send its FCGI_ABORT record or its end of stream at
detach time because the mux buffer is busy or full, fcgi_detach() leaves
early to keep the stream as an orphan. This skips the idle/avail list
management performed at the end of the function. The orphan is later
destroyed by fcgi_deferred_shut() once the record can be sent, but nothing
makes the connection idle or available again at this point. The timeout is
not refreshed either.
If the orphan was the last stream of the connection, the connection is then
in no idle list, it is not released and it remains accounted in
srv->curr_used_conns. Its timeout is the one armed when the stream was
orphaned, so the connection is closed after "timeout server" instead of
being reused, and it is wasted in the mean time.
To fix the issue, the idle/avail list management is extracted from
fcgi_detach() into a new fcgi_may_idle_conn() function, which is now also
called from fcgi_deferred_shut() after the orphan was destroyed and the
timeout was refreshed, as fcgi_detach() does.
In fcgi_deferred_shut(), the stream's session cannot be used, since it may
have been released in the mean time. The connection owner is used instead,
but only if the connection is still attached to its session, because
session_free() resets conn->owner only in this case. For a private
connection, if there is no session anymore when the last stream leaves, the
connection can no longer be reused and it is destroyed.
The orphans destroyed from fcgi_strm_wake_one_stream() are not covered here.
This mostly happens on connection errors or shutdowns, in which case the
connection is released anyway.
This is the same fix as the one applied on mux-h2 by the commit
"BUG/MEDIUM: mux-h2: put BE conn back in idle list after deferred shut".
This could be backported to all supported versions, after the recent
fcgi_detach() fixes: a167d39a5 ("BUG/MEDIUM: mux-fcgi: arm the connection
timeout only when data remains"), 170a6469c ("BUG/MEDIUM: mux-fcgi: ignore
conn->owner when deciding if a connection is dead"), b77b044d3 ("MINOR:
mux-fcgi: check for a dead connection before refreshing the timeout") and 2acf116bf ("MINOR: mux-fcgi: don't add a closed connection to an idle list
on detach").
MINOR: mux-spop: don't add a closing connection to an idle list on detach
In spop_detach(), the test deciding whether the connection may be moved to
an idle list checks SPOP_CF_RCVD_SHUT, SPOP_CF_ERR_PENDING and
SPOP_CF_ERROR, but not the connection state. A connection that already
switched to SPOP_CS_ERROR, SPOP_CS_CLOSING or SPOP_CS_CLOSED may thus be
inserted in the session server list or in the server's idle pool, while
spop_avail_streams() reports no available stream for it.
This can only happen with a private connection, since srv_add_to_idle_list()
already rejects connections without available streams. It is not harmful
either, since session_get_conn() also requires an available stream, so such
a connection is never reused. But it is still wrong to park it: it prevents
the session from dropping it and forces a useless idle counter increment.
This is the same fix as the one applied on mux-fcgi by commit 2acf116bf
("MINOR: mux-fcgi: don't add a closed connection to an idle list on
detach"). Unlike FCGI, all states from SPOP_CS_ERROR are excluded, which
matches the test performed by spop_avail_streams().
BUG/MEDIUM: mux-spop: refresh the connection timeout before parking it idle
spop_detach() refreshes the connection timeout in two places only: in the
early return taken when the stream is blocked, and at the very end of the
function. The branches that move the connection to an idle list (the
session's private list or the server's idle pool) return before reaching
the tail. Since the timeout is disabled while streams are attached, a
connection detached with data still queued in the mux buffer is thus parked
without any timeout and nothing drains it. It is only released by the purge
of the idle connections.
The refresh is now performed right after spop_strm_destroy(), before the
connection may be given away, and the call at the end of the function is
dropped: everything between the two points only manipulates session and
idle lists, so it recomputed the very same expiration date.
spop_conn_update_timeout() already returns early when there is no task, so
no guard is needed at the call site. Note that an idle connection without
pending data now also gets the default timeout when it is parked, as it is
already the case each time it is processed by spop_process().
The dead connection check is moved ahead of the refresh, so that a
connection about to be released is not armed and requeued just before
spop_release() clears its task context. This only reorders statements:
spop_conn_update_timeout() touches neither the stream tree nor the flags
and states spop_conn_is_dead() looks at. And since the previous commit
removed the conn->owner test from spop_conn_is_dead(), clearing conn->owner
in the non-private branch below has no effect on the predicate.
This is the same fix as the one applied on mux-h2 by commit 5e7bb2063
("BUG/MEDIUM: mux-h2: refresh the connection timeout before parking it
idle") and on mux-fcgi by commits a167d39a5 ("BUG/MEDIUM: mux-fcgi: arm the
connection timeout only when data remains") and b77b044d3 ("MINOR:
mux-fcgi: check for a dead connection before refreshing the timeout").
This should be backported to 3.1 with the previous commit.
MINOR: mux-spop: ignore conn->owner when deciding if a connection is dead
spop_conn_is_dead() reports a connection as dead when it has no stream left
and conn->owner is NULL, on the assumption that an ownerless connection has
nobody left to take care of it. This no longer holds since idle backend
connections are stored in the server and may legitimately have conn->owner
NULL while still being usable. The same test was removed from h2c_is_dead()
by commit a0541f5d2 ("BUG/MEDIUM: mux-h2: ignore conn->owner when deciding
if a connection is dead") and from fcgi_conn_is_dead() by commit 170a6469c
("BUG/MEDIUM: mux-fcgi: ignore conn->owner when deciding if a connection is
dead").
In the SPOP mux, spop_conn_is_dead() is only called at the end of
spop_detach(), which is never reached for an idle connection moved to an
idle list, and the stream test makes the predicate false as long as streams
remain. So the test has no visible effect for now. But it prevents the dead
connection check from being performed before the idle list management, the
non-private branch clearing conn->owner before parking the connection. So
let's remove it.
BUG/MEDIUM: mux-spop: do not enforce the timeout on connections with streams
spop_conn_update_timeout() leaves the connection task unarmed while stream
connectors are attached, since the timeouts are then enforced by the upper
layer. But spop_attach() does not touch the task, so a connection which got
a timeout while it had no stream, for instance because of pending output
data or because of the default timeout applied to connections without
stream, keeps it once a new stream is attached. When it strikes,
spop_timeout_task() kills the connection and aborts the streams attached
to it, while nothing indicates that the agent is not responding.
As done for the H2 mux by commit c2ea47fb1 ("BUG/MEDIUM: mux-h2: do not
enforce timeout on long connections") and for the FCGI mux by commit 6e3bad2f3 ("BUG/MEDIUM: mux-fcgi: do not enforce the timeout on connections
with streams"), spop_timeout_task() now does not kill the connection when
stream connectors are still attached, it only disarms the timeout.
BUG/MEDIUM: mux-h2: put BE conn back in idle list after deferred shut
When a backend stream cannot send its RST_STREAM or ES at detach time
because the mux buffer is busy or full, or because the connection window
is exhausted, h2_detach() leaves early to keep the stream as an orphan.
This skips the idle/avail list management performed at the end of the
function. The orphan is later destroyed by h2_deferred_shut() once the
frame can be sent, but nothing makes the connection idle or available
again at this point.
If the orphan was the last stream of the connection, the connection is
then in no idle list, it is not released and it remains accounted in
srv->curr_used_conns. Its timeout is not armed either, because a backend
connection without stream only relies on idle-ping. So it cannot be
reused and it stays there until the server closes it or an error occurs,
holding an FD and preventing the server from being deleted.
To fix the issue, the idle/avail list management is extracted from
h2_detach() into a new h2_may_idle_conn() function, which is now also
called from h2_deferred_shut() after the orphan was destroyed and the
timeout was refreshed, as h2_detach() does.
In h2_deferred_shut(), the stream's session cannot be used, since it may
have been released in the mean time. The connection owner is used instead,
but only if the connection is still attached to its session, because
session_free() resets conn->owner only in this case. For a private
connection, if there is no session anymore when the last stream leaves,
the connection can no longer be reused and it is destroyed.
The orphans destroyed from h2s_wake_one_stream() are not covered here.
This mostly happens on connection errors or shutdowns, in which case the
connection is released anyway.
This bug exists since orphaned streams are destroyed from
h2_deferred_shut() with backend connections reuse. It could be backported
to all supported versions. Note that 5e7bb2063 ("BUG/MEDIUM: mux-h2:
refresh the connection timeout before parking it idle") reworked the
h2_detach() tail, so it should be backported first. However, it could be
good to wait for a period of observation first.
BUG/MINOR: tcpcheck: fix out-of-bounds reads on short MySQL error packets
tcpcheck_mysql_expect_packet() only verifies that the packet header is
present before reading inside it.
This covers the 3 length bytes and the sequence id, but not the packet type
byte read at offset+4 right after. Then the whole packet is checked against
the buffer, which only guarantees that 4 bytes past offset were received.
When the packet announces a length lower than 4, the error branch below is
entered even though the bytes it reads were never received: it reads the
error code at offset+5 and offset+6 and uses offset+7 as the start of the
message body, while the body length is computed as b_data()-offset-7, which
wraps around when b_data() is lower than offset+7. A 5-byte response, i.e. a
packet announcing plen == 0 followed by a 0xff byte, is enough to trigger
this.
The wrapped length does not lead to a copy today because chunk_istcat()
refuses to append more than b_room(), but the reads still happen and the
error code and status reported are garbage.
Thus, first make sure the packet type byte is available before reading it,
and then reject error packets announcing less than 4 payload bytes, the
minimum for the packet type, a 2-byte error code and at least one byte of
description. As a consequence, such packets are now reported as a Layer7
invalid response instead of a Layer7 wrong status with a bogus error code,
and a response carrying only the 4 header bytes is now considered incomplete
and waits for more data instead of being parsed from bytes that were never
received. Truncated responses keep waiting for more data as before.
This bug is present since 2.2, so it should be backported to all
maintained branches.
Willy Tarreau [Thu, 12 Nov 2026 17:14:04 +0000 (18:14 +0100)]
[RELEASE] Released version 3.5-dev12
Released version 3.5-dev12 with the following main changes :
- CLEANUP: quic: compute the STREAM frame end offset once in qc_stream_frm_is_acked()
- CLEANUP: quic: fix and complete the comments in quic_retransmit.c
- CLEANUP: quic: remove a redundant test in the fast retransmission lookups
- CLEANUP: quic: use QUIC_PACKET_PN_MAXLEN instead of the magic 4
- CLEANUP: quic: remove the dead encryption level variable in qc_prep_hdshk_fast_retrans()
- CLEANUP: quic: drop the intermediate packet tree pointer in the fast retransmissions
- CLEANUP: quic: remove the duplicate qc_prep_hdshk_fast_retrans() prototype
- REGTESTS: protobuf: cover the ungrpc message realignment
- BUG/MINOR: fd: allow fd_write_frag_line() to run before fdtab allocation
- BUG/MINOR: http/hardening: don't count unregistered hdr/tlr too early
- MINOR: http/hardening: turn it to a macro and count matches with COUNT_IF()
- BUG/MEDIUM: stream: reset analyse_exp when analysers are stripped on error
- BUG/MINOR: http-ana: also set FINAL on http-response actions on server error
- BUG/MEDIUM: spoe: stop waiting on a dead producer channel
- BUG/MINOR: tcpcheck: check the number of "hdr" in http-check send
- MINOR: tcpcheck: add post-80-sha2 mode to mysql-check for caching_sha2_password
- BUG/MINOR: stick-table: reject invalid gpc/gpt array indexes
- MEDIUM: h1/violations: restrict valid version strings to "1.0" and "1.1"
- BUG/MEDIUM: filters: avoid NULL block access in decompression
- BUG/MEDIUM: mux-fcgi: do not enforce the timeout on connections with streams
- BUG/MEDIUM: quic: fix loss time selection in quic_loss_pktns()
- BUILD: http: fix build of macro http_harden() with clang
- MINOR: debug: add a COUNT() macro which doesn't take a condition
- CLEANUP: debug/tree-wide: replace COUNT_IF(1, ...) with COUNT()
- BUG/MINOR: applet: accept a temporarily owned tid in appctx_init()
- BUG/MINOR: server: fix a leak when completing a named default-server
- DOC: minor: update VTest2 URL everywhere
- BUG/MEDIUM: compression: use a trash chunk as large as the buffer for the output
- BUILD: debug: fix _COUNT undefinied with USE_OBSOLETE_LINKER
- BUG/MEDIUM: mux-h2: consider the send list as pending data for the timeout
- BUG/MEDIUM: mux-h2: refresh the connection timeout before parking it idle
- BUG/MEDIUM: mux-fcgi: arm the connection timeout only when data remains
- BUG/MEDIUM: mux-fcgi: detect an early connection error during the handshake
- BUG/MEDIUM: mux-fcgi: ignore conn->owner when deciding if a connection is dead
- MINOR: mux-fcgi: check for a dead connection before refreshing the timeout
- MINOR: mux-fcgi: don't add a closed connection to an idle list on detach
- BUG/MEDIUM: mux-h2: also consider the fctl_list as pending data for the timeout
- BUG/MEDIUM: ssl: don't use MSG_MORE for kTLS control records
- MINOR: cli: factorize CLI session reset
- MINOR: cli: store active CLI sessions in a global list
- MINOR: cli: implement basic mechanism for uninterruptible jobs
- MINOR: cli: implement uninterruptible mode for wait
- MINOR: ring: support inactivity timeout in show ring CLI handler
- MINOR: sink: add timeout argument for "show events"
- MINOR: cli: add "kill" CLI command
- REGTESTS: cli: check uninterruptible mode
- CLEANUP: mux-h2: clarify that bptr is not NULL when calling to h2_get_buf()
- BUG/MEDIUM: mux-h2: always return already allocated buffers in h2_get_buf()
- BUG/MEDIUM: mux-h2: permit the buffer callback to allocate despite the queue
- BUG/MEDIUM: mux-h2: wake the connection up after a delayed mbuf allocation
- BUG/MEDIUM: mux-h2: serve all pending buffer allocations in the buffer callback
- BUG/MINOR: mux-h2: unblock the demux when destroying the stream it was blocked on
- BUG/MEDIUM: mux-h2: don't send RST_STREAM for backend streams whose HEADERS were not sent
- BUG/MEDIUM: mux-h2: also emit the HPACK dynamic table size update on requests
- BUG/MINOR: mux-h2: also emit the HPACK Dynamic Table Size Update before trailers
- BUG/MINOR: mux-h2: only convert GET upgrade requests to Extended CONNECT
- BUG/MINOR: mjson: fix out-of-bounds reads on malformed JSON paths
- BUG/MEDIUM: flt-decomp: preserve pending output before decoding again
- REGTEST: ocsp: make the ocsp_client_check test fast
- CI: github: switch development builds back to ubuntu-latest
- CI: github: remove MIPS targets from cross-zoo.yml
- CI: temporarily disable AWS-LC 3.x (fips-2024-09-27)
- CI: github: install libcrypt-dev:i386 for the i686 build
- BUG/MEDIUM: resolvers: detach servers without resolvers from the SRV request
- BUG/MEDIUM: resolvers: don't ignore records not matching a resolve-net family
- BUG/MEDIUM: resolvers: skip the data of ignored additional records
- BUG/MINOR: resolvers: reject a null or negative resolve_retries value
- BUG/MINOR: resolvers: reject null "timeout resolve" and "timeout retry" values
- BUG/MINOR: resolvers: preserve nameserver identity on "clear counters all"
- BUG/MINOR: resolvers: don't dump a nameserver twice in "show resolvers"
- BUG/MINOR: resolvers: Always init a new resolution's list element
- BUG/MINOR: resolvers: count nameserver timeouts
- BUG/MEDIUM: resolvers: reject servers sharing an SRV record with different resolvers
- BUG/MINOR: resolvers: check the SRV expiration date again under the lock
- OPTIM: resolvers: only walk duplicates when looking up an existing record
- BUG/MINOR: resolvers: warn about ignored arguments on datagram nameservers
- BUG/MINOR: resolvers: fix leaks on do-resolve's fetch availability error
- BUG/MINOR: resolvers: report a timeout when a TCP fallback gets no response
- BUG/MINOR: resolvers: use truncated SRV responses when no TCP fallback is possible
- BUG/MEDIUM: resolvers: properly skip root-named authority and additional records
- BUG/MINOR: resolvers: compute a name's wire length by walking its labels
- BUG/MINOR: quic/ssl: record TLS version bounds for certificate selection
- CI: github: pin ARM development builds to Ubuntu 26.04
- BUG/MINOR: cfgparse: detect unsupported crypt() hashes on Debian/Ubuntu
- DOC: configuration: clarify normalize-uri version availability
- BUG/MINOR: ssl/ckch: fix an invalid free() in the domains/ips error paths
- BUG/MINOR: tools: ha_freearray() must also free the array
- CI: github: re-enable AWS-LC 3.x (fips-2024-09-27)
- BUG/MAJOR: quic: don't reference a retired CID from a NEW_CONNECTION_ID frame
- BUG/MINOR: quic: reject RETIRE_CONNECTION_ID for a CID not sent to the peer
- BUG/MINOR: ssl: skip the cipher workaround with AWS-LC API 38 and newer
- BUILD: Makefile: force $(shell command -v ...) to run through the shell
- BUG/MINOR: quic: reject invalid stream ID after MUX closure
- BUG/MEDIUM: quic: limit reject after MUX closure to once per stream
- BUG/MINOR: quic-be: fix Initial token length check on backend connections
- BUG/MINOR: mux_quic: remove dangling qc->qcc ref on MUX init failure
- MINOR: http: add <need_eot> to trailers parsing function
- MINOR: mux_quic: refactor qcs_http_handle_standalone_fin()
- BUG/MINOR: h3: fix missing EOM after trailers without FIN
- BUG/MINOR: h3: close connection on response start-line alloc failure
- BUG/MINOR: h3: fix error code on incomplete request
- BUG/MEDIUM: h3: reject standalone FIN on invalid request/response
- BUG/MEDIUM: threads: don't read lock history entries that don't fit in ulong
- BUG/MINOR: quic-be: drop long header packets with unsupported version
- BUG/MINOR: stick-table: release server_key on any stksess destruction
- BUG/MINOR: acl: check the presence of an argument to "-u"
- BUG/MINOR: server: don't report dyncookie collision on same IP servers
- SCRIPTS: create-release: do not match the word "version" isolated
- MEDIUM: sched: fix the default runqueue-depth
- DOC: security: clarify how to send proper reports
- DOC: threat-model: add a few more entries for stuff that should be public
- DOC: configuration: add a section on secure filtering of HTTP requests
- MINOR: sample: add SMP_USE__MAY_ALIAS to mark fetches returning aliasable contents
- MINOR: http-fetch: mark URI-based sample fetches with SMP_USE__MAY_ALIAS
- MINOR: acl: add acl_cond_find_positive_use() to find positive terms by usage
- MINOR: http-act: mark http-request access control actions with KWF_ACCESS_CTRL
- MINOR: http-rules: accept "no-warn" before the condition of access control rules
- REGTESTS: add a no-warn directive on deny rules using a path
- MEDIUM: http-rules: report access control rules relying on aliasable contents
- MINOR: http: add a global setting to decide on warnings for http rules
- DEBUG: stream: do not emit debug messages for internal proxies
- MINOR: mux-quic: add an sctl() callback to the application ops
- MINOR: mux: add sctl MUX_SCTL_GET_HDNG_FOUND/FIXED to report hardening results
- MINOR: http-fetch: add {fs,bs}.hdng.{found,fixed} to report hardening results
- MINOR: http-conv: add hdng_rej_name to name the HTTP hardening reject rule
- REGTESTS: http-messaging: test the reporting of HTTP hardening results
Willy Tarreau [Tue, 10 Nov 2026 10:55:41 +0000 (11:55 +0100)]
REGTESTS: http-messaging: test the reporting of HTTP hardening results
This new test checks fs.hdng.found, fs.hdng.fixed, bs.hdng.found and
bs.hdng.fixed from a log-format, as well as the hdng_rej_name converter.
The same anomalies (underscore in a header name, unregistered header,
CTL in a trailer) are sent:
- through the "trusted" profile on both sides: everything passes, and
only "found" reports them;
- in a request to a "strict" profile which deletes the two headers and
rejects the trailer: the 400 is logged with the three rules in "fixed"
and hdng_rej_name only names the reject. The trailers are sent apart so
that the stream exists when they are rejected;
- in a response from a server using the "strict" profile: same with a 502
on the backend side;
- in an H2 request with only the deleted headers: nothing is named.
Willy Tarreau [Tue, 10 Nov 2026 10:54:56 +0000 (11:54 +0100)]
MINOR: http-conv: add hdng_rej_name to name the HTTP hardening reject rule
The hdng_rej_name converter takes a mask of HTTP_HRD_* flags such as returned
by fs.hdng.fixed or bs.hdng.fixed, keeps only the "reject" rules, and
returns the name of the lowest one, as found in http_hardening_kws[]. Since
a reject stops the processing, at most one is normally present. Other rules
are ignored, and the converter fails when no reject rule remains, so that
nothing is logged when nothing was rejected:
Willy Tarreau [Tue, 10 Nov 2026 10:41:32 +0000 (11:41 +0100)]
MINOR: http-fetch: add {fs,bs}.hdng.{found,fixed} to report hardening results
These new sample fetches return, for the frontend or backend mux stream,
the mask of HTTP hardening conditions that were met (found) and of the
rules that were enforced (fixed). They rely on the new mux stream controls
MUX_SCTL_GET_HDNG_FOUND and MUX_SCTL_GET_HDNG_FIXED, and fail when the mux
doesn't support them. The main purpose is to log them, e.g.:
Willy Tarreau [Tue, 10 Nov 2026 10:19:20 +0000 (11:19 +0100)]
MINOR: mux: add sctl MUX_SCTL_GET_HDNG_FOUND/FIXED to report hardening results
The H1, H2 and H3 streams store in their http_hdng_chk what HTTP hardening
conditions were met (found) and what rules were enforced (fixed). This adds
two new mux stream controls to retrieve them as uint32_t, so that they can
be reported by sample fetches and logged:
They're implemented in the H1 and H2 muxes. The QUIC mux passes them to
the application layer's sctl() after checking that it's H3, and h3_sctl()
implements them. Other muxes return -1 as they don't support hardening.
Willy Tarreau [Tue, 10 Nov 2026 10:18:01 +0000 (11:18 +0100)]
MINOR: mux-quic: add an sctl() callback to the application ops
The QUIC mux will need to pass some stream controls to the application
layer, which holds information that the mux doesn't know about (e.g. the
HTTP hardening results of the H3 stream). This adds a new sctl() callback
to qcc_app_ops, which takes the qcs, the mux_sctl_type and an output
pointer, and works like mux->sctl(), returning -1 when not supported.
For now, h3_sctl() doesn't implement anything and the mux doesn't call it
yet.
Willy Tarreau [Thu, 12 Nov 2026 13:56:14 +0000 (14:56 +0100)]
DEBUG: stream: do not emit debug messages for internal proxies
The debug mode that is triggered via "haproxy -d" remains helpful in
unit tests during development, typically to see HTTP headers being
processed. However, for historic reasons it doesn't make any difference
between service connections and maintenance connections such as peers
or CLI, making it close to useless in environments involving one of
these.
This patch just eliminates logs for sessions coming from an internal
proxy, since this is not something users are expected to deal with nor
want to observe. Thus, it finally becomes possible to use "haproxy -d"
while a monitoring script polls the CLI or when peers are configured.
Willy Tarreau [Thu, 12 Nov 2026 10:33:23 +0000 (11:33 +0100)]
MINOR: http: add a global setting to decide on warnings for http rules
The default choice of "notice" as level to emit a warning for an
http-request rule relying on unreliable processing may not always be
the best choice. This commit adds a new global "on-unreliable-rules"
directives which takes 3 parameters, "notice" (the default), "warn"
and "ignore". Choosing "warn" will emit a warning instead of a notice,
so that a config using "zero-warning" will detect them. This might be
helpful after a config was sanitized in order to make sure no new
warnings are introduced. And "ignore" may be used to silence all
messages when migrating a config.
Willy Tarreau [Wed, 11 Nov 2026 13:55:02 +0000 (15:55 +0200)]
MEDIUM: http-rules: report access control rules relying on aliasable contents
Rules such as "http-request deny if { path_beg /admin }" are regularly
reported as bypassable using another form of the same request (case,
%-encoding, "//", "/./", "../", backslashes etc). This is expected, since
these aliases depend on what lies behind haproxy, and the only reliable
way to filter requests is to reject what was not explicitly accepted.
Now when an http-request rule using an action marked KWF_ACCESS_CTRL
(auth, deny, reject, silent-drop, tarpit) has a condition which may be
true because of a match on a sample fetch marked SMP_USE__MAY_ALIAS, it
is reported at boot. Only terms making the condition true when they
match are considered (non-negated after "if", negated after "unless"),
so that allow-lists are not reported. Converters are not considered, as
most of them do not handle all aliases.
Some rules are legitimately used as an extra filter (e.g. blocking %2E or
"<script" in the query string as a complement to other protections). For
these ones, the "no-warn" keyword placed right before "if" or "unless"
excludes the rule from the report. It also indicates to future readers
that the rule is known not to be reliable by itself. It is not made a
warning so as not to cause problems to configs running in zero-warning
mode.
Willy Tarreau [Thu, 12 Nov 2026 08:37:18 +0000 (09:37 +0100)]
REGTESTS: add a no-warn directive on deny rules using a path
Historically a number of reg-tests were built with action "deny" and
deny_status followed by a path match in order to distinguish client
requests in the tests. These ones will soon emit warnings, so let's
add a no-warn directive to them.
Willy Tarreau [Wed, 11 Nov 2026 11:05:02 +0000 (13:05 +0200)]
MINOR: http-rules: accept "no-warn" before the condition of access control rules
The http-request actions marked with KWF_ACCESS_CTRL (auth, deny, reject,
silent-drop, tarpit) now accept the "no-warn" keyword placed right before
"if" or "unless". It is removed from the arguments before the action's
parser is called so that the parsers don't have to know about it. It is
only looked up for these actions so that it cannot be confused with an
argument value of another action (e.g. a header value).
It has no effect for now. It will be used to exclude a rule from the
upcoming report of conditions relying on aliasable contents. It comes
separately so that it can be backported to stable versions along with
the previous commit (KWF_ACCESS_CTRL), allowing configurations which
use it to still parse after a rollback, and so that the reg-tests can
be updated before the report is introduced.
Willy Tarreau [Wed, 11 Nov 2026 10:49:20 +0000 (12:49 +0200)]
MINOR: http-act: mark http-request access control actions with KWF_ACCESS_CTRL
This new keyword flag indicates that an action is used to block traffic,
and as such that the reliability of its condition matters. It is set on
the "deny", "tarpit", "reject", "auth" and "silent-drop" http-request
actions. It will be used to detect such rules relying on a deny-list of
aliasable contents. "return" is deliberately not marked, as it's used
for many other purposes (e.g. serving local contents).
Willy Tarreau [Wed, 11 Nov 2026 10:42:38 +0000 (12:42 +0200)]
MINOR: acl: add acl_cond_find_positive_use() to find positive terms by usage
This function looks for a term of a condition which makes the condition
true when it matches (a non-negated term after "if", or a negated one
after "unless") and which involves a sample fetch having certain
SMP_USE_* bits. It returns the first matching ACL and keyword, in the
same way as acl_cond_kw_conflicts() does. The combination of terms is
not considered, a single positive term is enough.
It will be used to detect deny-lists built on aliasable contents.
Willy Tarreau [Wed, 11 Nov 2026 12:02:20 +0000 (14:02 +0200)]
MINOR: http-fetch: mark URI-based sample fetches with SMP_USE__MAY_ALIAS
The path, the query string and the parameters they convey may be written
in many equivalent forms (case, %-encoding, "+" vs "%20", "/./", "../",
"//", backslashes etc), depending on what lies behind haproxy. Let's mark
the fetches returning or depending on these contents with
SMP_USE__MAY_ALIAS: base, base32, base32+src, baseq, capture.req.uri,
path, pathq, query, req.body_param, url, url32, url32+src, url_param,
urlp and urlp_val.
The host part is left aside for now (url_ip, url_port, Host header), as
it's much less commonly used to deny access, and that it's generally
used the same way to route the traffic.
Willy Tarreau [Wed, 11 Nov 2026 11:31:41 +0000 (13:31 +0200)]
MINOR: sample: add SMP_USE__MAY_ALIAS to mark fetches returning aliasable contents
Some sample fetches return contents which may be written in multiple
equivalent forms that are interpreted the same way by the next hop, for
example the path with its %-encoding, its case, or its "/./" and "../"
segments. Matching such contents against a pattern to deny requests is
unreliable, and we'll want to be able to detect such constructs at boot.
This adds SMP_USE__MAY_ALIAS, which is not a source but a property of the
fetched contents. It is placed in the ->use field so that it doesn't
require a new field in all fetch keywords, and since this field is
already or'ed into the ACLs and conditions, it will be possible to
quickly check if a condition involves such a fetch.
The double underscore marks the values which are properties of the
contents and not sources. They're not mapped to any SMP_SRC_* value, so
they're ignored when computing the validity domain. They are allocated
from the topmost bit downwards, leaving all the room to the sources
below, and a build time check verifies that the sources never reach
bit 31.
Willy Tarreau [Wed, 11 Nov 2026 12:36:57 +0000 (12:36 +0000)]
DOC: configuration: add a section on secure filtering of HTTP requests
Deny rules matching a path, an URL or a query string are regularly
reported as bypassable using alternate encodings or aliases (case,
repeated slashes, "." and ".." segments, %-encoding, "%u" encoding,
backslashes, path parameters etc). This is expected: HTTP has many
aliases and which ones apply depends on what is behind haproxy, so no
normalization performed here can be correct in the general case.
The only reliable approach is an allow-list: accept what is explicitly
recognized and reject everything else. Let's document this in a new
section 7.5, starting with a table of aliases of a trivially denied path
to make the problem obvious, explain why it cannot be solved by code,
show how to write allow-list rules with "deny unless" or with a variable
set by each accepting rule and checked once at the end, and list the
patterns worth spotting when reviewing a configuration.
Willy Tarreau [Thu, 12 Nov 2026 16:12:03 +0000 (17:12 +0100)]
DOC: threat-model: add a few more entries for stuff that should be public
Some reports still contain well-known claims that need to be re-explained
and would be better described publicly, particularly because they come
with zero real risk. Let's clarify a few such points.