]> git.kaiwu.me - haproxy.git/log
haproxy.git
5 hours agoREGTESTS: quic: undecryptable 0-RTT packets must not exhaust the Rx buffer master
Frederic Lecaille [Wed, 18 Nov 2026 16:47:39 +0000 (17:47 +0100)]
REGTESTS: quic: undecryptable 0-RTT packets must not exhaust the Rx buffer

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, with
a reference on the connection Rx buffer. That buffer is reclaimed in order
and stops at the first referenced packet, so a queued 0-RTT packet pins all
the data behind it. When no 0-RTT RX secret exists, because the early data
were rejected by the TLS stack or because the TLS library does not support
0-RTT, those packets can never be decrypted and are never released: past
about 64 kB, every packet of the connection is dropped until the idle
timeout.

The test completes a handshake, keeps the connection healthy with an HTTP/3
request, then injects 120 long header 0-RTT packets whose payload is
encrypted with keys haproxy does not know, which reproduces the state
reached when 0-RTT keys are absent. Dropped packets are counted as
dropped_pkt_bufoverrun, shown as dropbuff= by "show quic full", so the vtc
asserts through the CLI that this field does not appear: the Rx buffer was
not exhausted and the connection was not stalled.

It needs the Python client in reg-tests/quic/qclient, so it carries
'#REGTEST_EXTRA=qclient' and only runs when requested.

Covers 2335f9196.

5 hours agoREGTESTS: quic: NEW_CONNECTION_ID must not reference a retired CID
Frederic Lecaille [Wed, 18 Nov 2026 16:45:37 +0000 (17:45 +0100)]
REGTESTS: quic: NEW_CONNECTION_ID must not reference a retired CID

A NEW_CONNECTION_ID frame stored pointers to the CID and the stateless
reset token of its quic_connection_id. RETIRE_CONNECTION_ID frees that
object at once, while a frame built for it may still be queued, in flight,
or duplicated later for a retransmission: it was then built from freed
memory.

Retiring sequence numbers 1 and 2 in the same packet is enough to reach
it: the second RETIRE frees the CID the first NEW_CONNECTION_ID frame
still points to. With the pool cache, the freed object is handed back to
the next CID of the same connection, so two frames carry the same CID,
which the client detects. Without it (ASan, DEBUG_DONT_SHARE_POOLS), freed
heap content is sent and the sanitizer reports a use-after-free.

The test drives a real handshake through the QUIC client in
reg-tests/quic/qclient, then retires both sequence numbers in one packet,
and checks two things: no duplicate CID is advertised for two different
sequence numbers, and the connection is closed with a transport error of
type PROTOCOL_VIOLATION, as RFC 9000 19.16 requires for a sequence number
that was never sent. A crash instead of the CONNECTION_CLOSE frame leaves
the test waiting, which also fails it.

It needs the Python client, so it carries '#REGTEST_EXTRA=qclient' and
only runs when requested.

Covers 827354038 and a50bb45ba.

5 hours agoREGTESTS: quic: backend must drop packets with an unsupported version
Frederic Lecaille [Wed, 18 Nov 2026 16:39:29 +0000 (17:39 +0100)]
REGTESTS: quic: backend must drop packets with an unsupported version

On backend connections, quic_rx_pkt_parse() accepts long header packets
carrying an unsupported version, since the version checks only apply to
listeners. Such packets keep QUIC_PACKET_TYPE_UNKNOWN, which maps to no
encryption level, and reach BUG_ON(!qel || !pktns) in qc_enc_level_alloc()
from qc_try_rm_hp().

A server which does not support the negotiated version answers with a
Version Negotiation packet (RFC 9000 6.1), so no malicious peer is needed.

The test starts a socket that replies to the Initial with a long header
packet using an unsupported version, and checks that the request fails with
a 503 instead of killing the process. It needs no helper beyond python3, so
it carries no #REGTEST_EXTRA directive.

Covers f12c7c7d9.

5 hours agoREGTESTS: quic: add a Python QUIC client
Frederic Lecaille [Wed, 18 Nov 2026 16:36:19 +0000 (17:36 +0100)]
REGTESTS: quic: add a Python QUIC client

Replaying some QUIC bugs requires a peer that completes a handshake and
then sends specific frames. Hand-crafted datagrams cannot do that.

Add a minimal QUIC v1 + TLS 1.3 + HTTP/3 client in reg-tests/quic/qclient:

  - qcrypto.py: RFC 9001 packet protection (HKDF, initial keys, varints,
    long and short header protection).

  - qclient.py: a QClient object over a real socket, with the received
    frames exposed. Hooks on the send and handshake paths let a caller
    alter packets, and the helpers cover key updates, connection migration
    and HTTP/3 requests, so tests can drive whatever scenario they need.

Both need the 'cryptography' package. Tests using them will carry
'#REGTEST_EXTRA=qclient' and run only when requested.

5 hours agoMINOR: reg-tests: add --extra to run tests needing optional tools
Frederic Lecaille [Wed, 18 Nov 2026 16:30:52 +0000 (17:30 +0100)]
MINOR: reg-tests: add --extra to run tests needing optional tools

Some VTC files need helper programs that are not built with HAProxy, such
as the Python QUIC client in reg-tests/quic/qclient/. They cannot simply be
typed 'slow' or 'devel' instead: their type says what they check, and the CI
jobs select tests by type.

Add a new --extra option to run-regtests.sh. A VTC file declares the helper
it needs:

    #REGTEST_EXTRA=qclient

and is skipped unless that name is listed in the --extra option. From the
Makefile, options are passed after '--':

    $ make reg-tests -- --extra qclient

The filter only adds tests: files without the directive, and the selection
made by --type/REGTESTS_TYPES, are unchanged.

Not to be backported: this is development tooling.

5 hours agoBUG/MEDIUM: mux-quic: cap elastic MAX_STREAMS to stream.max-total
Olivier Houchard [Wed, 18 Nov 2026 16:41:03 +0000 (17:41 +0100)]
BUG/MEDIUM: mux-quic: cap elastic MAX_STREAMS to stream.max-total

With "tune.streams-elasticity", qcc_release_remote_stream() grants as
MAX_STREAMS increment the difference between the elastic limit and the
streams still usable by the peer. Unlike the static path, nothing caps
the new limit to "tune.quic.fe.stream.max-total". If the window was
reduced under load and the load then drops, the increment computed close
to the end of the connection may exceed the remaining streams, and the
next released stream hits BUG_ON(qcc->lfctl.ms_bidi > max).

Let's cap the increment to the remaining streams. It is still at least 1
since ms_bidi is below max there.

This was introduced by commit e139dd90e ("MAJOR: mux_quic: support
stream elasticity during connection lifetime") in 3.4-dev13 and must be
backported to 3.4.

5 hours agoBUG/MEDIUM: quic: never advertise more streams than configured
Olivier Houchard [Wed, 18 Nov 2026 16:52:44 +0000 (17:52 +0100)]
BUG/MEDIUM: quic: never advertise more streams than configured

With "tune.streams-elasticity", the initial max-streams-bidi transport
parameter is set to conn_calc_max_streams() of the configured limit,
i.e. the lowest of "tune.quic.fe.stream.max-concurrent" and
"tune.quic.fe.stream.max-total". But this function may return more than
the value it is passed, as it also considers the share of the extra
streams budget left for each remaining connection, which does not depend
on it: with "tune.streams-elasticity 1000", it returns 10 at low load.

When "tune.quic.fe.stream.max-total" is lower than this, releasing the
first remote stream hits BUG_ON(qcc->lfctl.ms_bidi > max) in
qcc_release_remote_stream(), so the process dies on the first completed
request.

Let's not advertise more than the configured limit. The stream_max_total
reg-test now enables stream elasticity to cover this.

This was introduced by commit d21ec4c70 ("MINOR: quic: use stream
elasticity value for initial advertisement") in 3.4-dev13 and must be
backported to 3.4.

6 hours agoBUG/MINOR: mux-quic: fix QMux Rx buffer leak on MUX init failure
Olivier Houchard [Wed, 18 Nov 2026 15:55:27 +0000 (16:55 +0100)]
BUG/MINOR: mux-quic: fix QMux Rx buffer leak on MUX init failure

On QMux, qcm_init() takes over the Rx buffer of the xprt layer. When it
fails later, its error path resets qcc->conn before calling
qcc_release(), which only releases the QMux connection buffers when a
connection is attached, so the Rx buffer is leaked. A client connecting
with TLS but without ALPN to a "proto qmux" listener makes
qcc_install_app_ops() fail and leaks one buffer per connection.

Let's release the QMux Rx buffer in the qcm_init() error path, where the
connection type is still known. The Tx one cannot be allocated yet.

This was introduced in 3.4 by commit 81f22cd68 ("MINOR: mux-quic: define
Rx connection buffer for QMux") and must be backported to 3.4.

6 hours ago[RELEASE] Released version 3.5-dev13 v3.5-dev13
Willy Tarreau [Wed, 18 Nov 2026 15:58:50 +0000 (16:58 +0100)]
[RELEASE] Released version 3.5-dev13

Released version 3.5-dev13 with the following main changes :
    - BUG/MINOR: tcpcheck: fix out-of-bounds reads on short MySQL error packets
    - BUG/MEDIUM: mux-h2: put BE conn back in idle list after deferred shut
    - BUG/MEDIUM: mux-spop: do not enforce the timeout on connections with streams
    - MINOR: mux-spop: ignore conn->owner when deciding if a connection is dead
    - BUG/MEDIUM: mux-spop: refresh the connection timeout before parking it idle
    - MINOR: mux-spop: don't add a closing connection to an idle list on detach
    - BUG/MEDIUM: mux-fcgi: put BE conn back in idle list after deferred shut
    - BUG/MAJOR: cache: do not mix variants varying on different headers
    - BUG/MEDIUM: cache: fix "show cache" crash/skip with several caches
    - BUG/MEDIUM: cache: do not create a second applet when two cache-use rules hit
    - BUG/MEDIUM: cache: forbid cache rules in defaults sections
    - BUG/MEDIUM: filters: order the implicit filters around the explicit ones
    - BUG/MINOR: cache: do not refuse to store responses with "Age: 0"
    - BUG/MINOR: cache: do not remove the Age header from the forwarded response
    - BUG/MINOR: cache: recognize null qvalues with decimals in Accept-Encoding
    - BUG/MINOR: cache: do not eat the request while waiting for a buffer
    - BUG/MINOR: cache: reduce the max-age lifetime by the response's Age
    - BUG/MINOR: cache: compare the Age to the heuristic lifetime when none is given
    - BUG/MINOR: cache: do not ignore null lifetimes not written as "max-age=0"
    - REGTESTS: cache: cover the object lifetime with a single script
    - BUG/MINOR: quic: fix ACK_ECN parsing after optional ack ranges
    - BUG/MINOR: qmux: remove invalid BUG_ON() on empty record
    - BUG/MINOR: init: fix missing error on no listener on config check
    - BUG/MEDIUM: fd: Mark a fd as dead on early close
    - BUG/MEDIUM: mux-h1: Report EOS when a demux error is handled by the app layer
    - BUG/MINOR: cache: skip already resolved filters when resolving caches
    - BUG/MINOR: quic: remove CID on BE conn alloc failure
    - BUG/MINOR: h3: prevent missing request FIN on empty trailers
    - BUG/MINOR: sample: fix host_only and port_only on empty input
    - BUG/MINOR: sample: reject a \0 byte in raw string fetches
    - BUG/MINOR: http-ana: don't emit a network-path Location for a "/" redirect prefix
    - BUG/MINOR: log: don't let an LF in a forwarded message create new events
    - BUG/MEDIUM: mux_quic: fix Rx flow control increment on RESET_STREAM
    - OPTIM: lb-chash: don't look for more servers when there is only one
    - OPTIM: lb-chash: limit the scan to few consecutive nodes
    - MEDIUM: backend: avoid picking the same server twice in random draws
    - DOC: config: explain the effect of the weights on random's draws
    - IMPORT: slz: update slz to 1.4-dev5-24
    - MINOR: compression: pass COMP_CT_EVENT to the algorithms for server-sent events
    - MINOR: compression: add tune.comp.res.ring to disable the rings of responses
    - MEDIUM: compression/slz: use the event content type for server-sent events
    - DEV: sse-latency: add a parameter after the content-type
    - MINOR: http-ana: also match text/event-stream with trailing parameters
    - BUG/MINOR: h3: skip content-length check on backend bodyless responses
    - BUG/MINOR: h3: reject CANCEL_PUSH on backend side
    - MINOR: h3: reject malformed push frames
    - BUG/MEDIUM: sample: parse json_query integers within the token length
    - BUG/MINOR: mjson: bound the exponent in mystrtod()
    - BUG/MEDIUM: stick-tables: compute the shard of string keys on the stored key
    - BUG/MINOR: hq-interop: skip zero-copy with large buffers
    - BUG/MINOR: hq-interop: ignore uni streams in HTTP/0.9
    - BUG/MINOR: hq-interop: drop data after request
    - REGTESTS: http-messaging: Fix abortonclose issue with connect_tunnels
    - REGTESTS: http-messaging: Properly handle WINDOW_UPDATEs with connect_tunnels
    - BUG/MEDIUM: quic: do not keep 0-RTT packets which cannot be decrypted
    - BUG/MEDIUM: quic-be: keep the source port range of a closing backend connection
    - BUG/MINOR: quic-be: do not register the connection before the quic_conn is initialized
    - BUG/MINOR: quic: initialize the members read by quic_conn_release() first
    - BUG/MINOR: debug: Do not allocate context when we don't need one
    - DEV: h2: add h2dec, a raw HTTP/2 frame decoder
    - DEV: h2: add mkhdr.c, a C port of mkhdr.sh
    - DEV: h2: mkhdr: add -n to repeat the emitted frames
    - DEV: h2: mkhdr: support stream ID ranges with -i
    - DEV: h2: mkhdr: support "--" as a delimiter between frame descriptions
    - MINOR: ssl: add alpn_remove_token() to drop a protocol from an ALPN string
    - MINOR: global: add tune.options2 to host new GTUNE2_* flags
    - MINOR: global: add tune.h2.fe.enabled to disable HTTP/2 on frontends
    - MINOR: sample: add h2_enabled to report whether H2 may be used on frontends
    - REGTEST: ssl: test tune.h2.fe.enabled and h2_enabled on two instances
    - IMPORT: slz-prv: work around lobotomized compilers' fallthrough diagnostics
    - MINOR: sample: add smp_prepare_out() to prepare an output buffer
    - OPTIM: sample: use smp_prepare_out() in the lower and upper converters
    - MINOR: sample: add a "tr" converter
    - BUG/MINOR: http/hardening: free the new profile on strdup() failure
    - BUG/MEDIUM: stick-tables/cli: "set table" without key must not clear the table
    - BUG/MEDIUM: peers: make the soft-stop "dont_stop" state per peers section
    - BUG/MEDIUM: htx: never merge the next DATA block into the referenced one on defrag
    - BUG/MEDIUM: flt-decomp: don't expose EOM before the end of decompression
    - REGTESTS: decompression: test a large decompressed Content-Length response
    - BUG/MEDIUM: mux-h2: don't abort a tunnel attempt on interim responses
    - REGTESTS: http-messaging: check that 1xx don't abort H2 backend tunnels
    - REGTESTS: decompression: don't use yes(1) in http_large_cl
    - BUG/MEDIUM: dns: release the session slot of expired TCP queries
    - BUG/MAJOR: buf: make the shift distance check less strict in b_move()
    - BUG/MAJOR: mux-h2: fail on impossible data transfers in rcv_buf()
    - BUG/MAJOR: h3: do not panic on HTX_FL_PARSING_ERROR after htx_xfer()
    - BUG/MAJOR: mux-quic: fail on impossible data transfers in rcv_buf()
    - Revert "BUG/MINOR: h3: fix missing EOM after trailers without FIN"
    - CI: github: include WolfSSL version in job name
    - CI: github: test WolfSSL with and without debugging
    - Revert "MINOR: http: add <need_eot> to trailers parsing function"
    - CI: github: restrict WolfSSL sanitizer flags to debug jobs
    - BUG/MINOR: ssl: exclude wolfSSL from custom extension support
    - BUG/MEDIUM: stream: keep channel_auto_close() on the request error path
    - REGTESTS: http-messaging: send h1_big_chunk_size_line request at once
    - BUG/MINOR: checks: only trigger a DNS resolution with the resolvers lock
    - BUG/MINOR: dns: detect the server's shutdown on a partial TCP response
    - SCRIPTS: vtest: allow overriding the Git repository URL
    - BUG/MINOR: map: split "add map/acl" payload keys on line breaks
    - CI: github: use haproxytech/VTest2 for regression tests
    - BUG/MEDIUM: peers: bound stick-table update messages
    - BUG/MEDIUM: peers: bound stick-table switch messages
    - BUG/MINOR: peers: bound stick-table acknowledge messages
    - CLEANUP: peers: remove the unused intencode()
    - BUG/MINOR: quic/ssl: report SSL_CTX allocation failure
    - MINOR: peers: move message length constants to peers-t.h
    - BUG/MEDIUM: stick-table: fix the peers overhead in proto_size
    - BUG/MEDIUM: peers: trim received string keys to fit in a buffer

7 hours agoBUG/MEDIUM: peers: trim received string keys to fit in a buffer
Olivier Houchard [Wed, 18 Nov 2026 10:02:39 +0000 (11:02 +0100)]
BUG/MEDIUM: peers: trim received string keys to fit in a buffer

Commit b224f63c1 ("BUG/MEDIUM: stick-table: restrict key sizes to what
fits in a buffer") trims string keys in stksess_setkey() so that the
update message fits in a buffer, but string keys received from a peer
are copied directly and only bounded by the table's key size. A peer
with a larger bufsize, or a forged message, can thus store a key which
cannot be encoded when it is later taught to another peer. Since commit
ef4405d67 ("BUG/MEDIUM: peers: bound stick-table update messages") this
does not overflow the trash buffer anymore, but the peer session is
closed and reopened in loop and the resync never completes, as reported
in GitHub issue #3576.

Let's apply the same trimming on the receive path. This must be
backported wherever b224f63c1 was.

7 hours agoBUG/MEDIUM: stick-table: fix the peers overhead in proto_size
Olivier Houchard [Wed, 18 Nov 2026 10:07:58 +0000 (11:07 +0100)]
BUG/MEDIUM: stick-table: fix the peers overhead in proto_size

proto_size accounts for 11 bytes of encapsulation, but update messages
are built in place with the header, room for the encoded length, the
update id and the expiration date, plus the string key length. String
keys trimmed to fit the estimate, such as a large header tracked on a
table whose len is close to or above bufsize, thus never fit an update
message, and neither do binary keys of a table accepted at the limit by
the config check. Since commit ef4405d67 ("BUG/MEDIUM: peers: bound
stick-table update messages") this does not overflow the trash buffer
anymore, but the peer session is closed and reopened in loop and the
resync never completes. See GitHub issue #3576.

Let's count the real overhead. This was brought by commit 858263591
("MINOR: stick-table: calculate the on-wire size of each key") and must
be backported wherever it was, along with previous commit "MINOR: peers:
move message length constants to peers-t.h".

7 hours agoMINOR: peers: move message length constants to peers-t.h
Olivier Houchard [Wed, 18 Nov 2026 10:07:49 +0000 (11:07 +0100)]
MINOR: peers: move message length constants to peers-t.h

PEER_MSG_HEADER_LEN and PEER_MSG_ENC_LENGTH_MAXLEN are needed by the
stick-table code to estimate the size of update messages, so let's
move them out of peers.c.

This is needed by the next commit, so it must be backported along with
it.

7 hours agoBUG/MINOR: quic/ssl: report SSL_CTX allocation failure
Frederic Lecaille [Wed, 18 Nov 2026 14:36:42 +0000 (15:36 +0100)]
BUG/MINOR: quic/ssl: report SSL_CTX allocation failure

ssl_quic_initial_ctx() stores the result of SSL_CTX_new() into
bind_conf->initial_ctx without checking it, unlike ssl_sock_initial_ctx()
which alerts and returns an error. On allocation failure the QUIC bind
therefore crashed without any diagnostic.

Report the failure the same way the TCP path does.

Must be backported to all stable versions.

7 hours agoCLEANUP: peers: remove the unused intencode()
Frederic Lecaille [Wed, 18 Nov 2026 14:21:21 +0000 (15:21 +0100)]
CLEANUP: peers: remove the unused intencode()

All peers message builders now use encode_varint(), which knows the end of
the destination buffer and can fail. intencode() has no caller left, and
its comment still advises callers to ensure the room left after the
pointer, which is exactly what the new code checks explicitly.

Remove it.

7 hours agoBUG/MINOR: peers: bound stick-table acknowledge messages
Frederic Lecaille [Wed, 18 Nov 2026 14:17:28 +0000 (15:17 +0100)]
BUG/MINOR: peers: bound stick-table acknowledge messages

peer_prepare_ackmsg() was the last message builder of the peers code
still encoding without knowing the buffer end: lengths went through
intencode(), which cannot fail, and the last acknowledged update counter
was copied with a plain memcpy().

Its payload is a bounded varint plus a 32-bit counter, i.e. 9 bytes at
most, so it could not overflow. The bounds are added anyway, for
consistency with the update and switch message builders, and they make
intencode() unused: being defined without any prototype in a header, the
compiler cannot report it as unused, so it is removed here along with its
comment, otherwise it would have stayed in the binary silently.

Must be backported to all stable versions.

7 hours agoBUG/MEDIUM: peers: bound stick-table switch messages
Frederic Lecaille [Wed, 18 Nov 2026 14:03:37 +0000 (15:03 +0100)]
BUG/MEDIUM: peers: bound stick-table switch messages

peer_prepare_switchmsg() builds the table definition message in the
<size>-byte trash buffer but, like its update counterpart before commit
8e0f311ff, never checked that the encoded data fit. The table name was
copied with a plain memcpy() following an intencode() of its length, and
all other fields were encoded with intencode(), which cannot fail.

Unlike the update message, this one is mostly made of a variable-length
field, the table name: the peers section name, a '/', and the table name,
which gives a nid as large as the configuration line allows. The rest is
a fixed 33-byte overhead plus the data type parameters. Nothing accounts
for that name when validating the stick-table at configuration time, so
a table whose name is close to tune.bufsize is accepted and its copy runs
past the end of the trash buffer when the peer sessions start.

Let's check the room left before every copy and every varint encoding,
using the same peer_bufcpy() helper and the same single-exit error
convention as for the update message. The data type parameters are
staged in a trash chunk, not in <msg>, so their encoding is bounded by
the chunk itself through a distinct chunk_end pointer, while the varints
written to <msg>, the bitfield and the expiration are bounded by the
message end.

The payload length becomes a size_t for consistency with the update
message, though the definition message is inherently small.

Thank you to @h110hawk for having reported this issue in GH #3576.

This should be backported to all supported versions.

7 hours agoBUG/MEDIUM: peers: bound stick-table update messages
Frederic Lecaille [Wed, 18 Nov 2026 11:46:10 +0000 (12:46 +0100)]
BUG/MEDIUM: peers: bound stick-table update messages

peer_prepare_updatemsg() builds a stick-table update in the <size>-byte
trash buffer but never checked that the encoded data actually fit, and
still carried its "TODO: check size" comment. Fixed-size fields were
copied with memcpy() and every length was encoded with intencode(),
which cannot fail and has no knowledge of the buffer end.

An entry learned from a peer may hold a string key up to key_size - 1,
which the peers protocol accepts in a full-size message. Re-encoding it
adds a 2-byte header, the update identifier and, for timed updates, an
expiration before the key, so the copy runs past the end of the trash
buffer. ASan reports a heap-buffer-overflow WRITE right after the
16384-byte trash region, and on a normal build the two overflowing bytes
land in the next chunk.

Let's check the room left before every copy and every varint encoding.
A new peer_bufcpy() helper copies at most what the buffer can take,
advances the cursor on success and leaves it untouched on failure, so
the success path is unchanged. Lengths are now encoded with
encode_varint(), whose bounds are those of the destination buffer, and
all failures return 0 through a single exit point that releases the
session lock.

The payload length becomes a size_t: as an unsigned short it silently
truncated messages larger than 65535 bytes, which tune.bufsize above 64k
makes reachable.

This should be backported to all supported versions.

7 hours agoCI: github: use haproxytech/VTest2 for regression tests
William Lallemand [Wed, 18 Nov 2026 14:42:38 +0000 (14:42 +0000)]
CI: github: use haproxytech/VTest2 for regression tests

The official VTest2 repository frequently causes CI failures. Use the
haproxytech/VTest2 repository instead.

Point the shared VTest setup action and the FreeBSD workflow at the
haproxytech/VTest2 repository for both cache SHA lookups and builds.
Select the build source through VTEST_URL, leaving the script default
unchanged.

This could be backported together with the previous commit,
691e22fbbd ("SCRIPTS: vtest: allow overriding the Git repository URL").

8 hours agoBUG/MINOR: map: split "add map/acl" payload keys on line breaks
Olivier Houchard [Wed, 18 Nov 2026 14:23:21 +0000 (15:23 +0100)]
BUG/MINOR: map: split "add map/acl" payload keys on line breaks

The payload of "add map" and "add acl" contains one entry per line, but
the key was only split on spaces and tabs. A map line without a value
was thus merged with the next line into a single bogus entry instead of
being reported as an error, as is done for the last line. For "add acl",
whose patterns contain no space, all the lines were merged into a single
pattern, and the parser then stepped past the end of the payload, where
it only reads the payload terminator line.

Let's also stop the key on line breaks, and consider that a line without
a space or tab after the key has no value.

This was introduced in 1.9 by commit 25650ce51 ("MINOR: map: Add payload
support to "add map"") and may be backported to all stable branches.

8 hours agoSCRIPTS: vtest: allow overriding the Git repository URL
William Lallemand [Wed, 18 Nov 2026 14:02:51 +0000 (14:02 +0000)]
SCRIPTS: vtest: allow overriding the Git repository URL

Read the VTest repository URL from VTEST_URL so that builds can use
an alternate repository. Keep the current URL as the default when the
variable is unset or empty.

8 hours agoBUG/MINOR: dns: detect the server's shutdown on a partial TCP response
Olivier Houchard [Wed, 18 Nov 2026 13:53:37 +0000 (14:53 +0100)]
BUG/MINOR: dns: detect the server's shutdown on a partial TCP response

When a DNS response is only partially received over TCP, the session's
I/O handler reads the available data with applet_getblk() and waits for
more. When nothing new is available, the requested length is zero, and
applet_getblk() never reports the shutdown in this case since
applet_may_get() only checks it when more data than available is
requested. If the server closes after sending part of a response, the
session then waits for data that will never come, and queries assigned
to it are lost until it times out, about 20s later.

Let's check for the shutdown when the message is incomplete: the rest
cannot come anymore. This was brought in 3.3 by commit 217da087f
("MEDIUM: dns: Update the dns_session applet to use its own buffers").
It must be backported to 3.3.

9 hours agoBUG/MINOR: checks: only trigger a DNS resolution with the resolvers lock
Olivier Houchard [Wed, 18 Nov 2026 13:06:45 +0000 (14:06 +0100)]
BUG/MINOR: checks: only trigger a DNS resolution with the resolvers lock

When a health check fails to establish its L4 connection, the check code
calls resolv_trigger_resolution() on the server's requester to force a
new resolution. This function reads the resolution's status, step and
last_resolution, and writes last_resolution, while these fields are
otherwise only accessed under the resolvers' lock, possibly from another
thread processing a response. At worst a resolution is triggered again
too early, causing an extra DNS query. The resolution itself cannot be
freed in the meantime since the check holds the server's lock, which the
unlinking paths take before releasing the resolution.

The resolvers take the server's lock under their own lock, so we cannot
wait for the resolvers' lock here. The trigger being opportunistic, let's
just try to take it and skip the trigger when it is busy.

No backport is needed.

10 hours agoREGTESTS: http-messaging: send h1_big_chunk_size_line request at once
Olivier Houchard [Wed, 18 Nov 2026 12:44:29 +0000 (13:44 +0100)]
REGTESTS: http-messaging: send h1_big_chunk_size_line request at once

The test expects the headers and the chunk-size line to fill the buffer
on the first read, so that the request is rejected before being
forwarded. But they were sent as ~986 small writes, and when haproxy
received them in two parts (seen on FreeBSD CI), the first read did not
fill the buffer: the headers were forwarded and the server's 200 was
logged instead of the expected 400. Let's send the whole request in a
single write, with a chunk-size line longer than the buffer.

10 hours agoBUG/MEDIUM: stream: keep channel_auto_close() on the request error path
Christopher Faulet [Wed, 18 Nov 2026 12:00:35 +0000 (13:00 +0100)]
BUG/MEDIUM: stream: keep channel_auto_close() on the request error path

Commit 6c5df88d ("BUG/MEDIUM: stream: reset analyse_exp when analysers are
stripped on error") replaced channel_auto_close(req) with
req->analyse_exp = TICK_ETERNITY instead of adding the new statement, so
auto-close is no longer re-enabled on the client error/timeout path while
the remaining request analysers are stripped. The response path correctly
kept channel_auto_close(res) and got the analyse_exp reset in addition.

Restore channel_auto_close(req) so shutdowns are still forwarded when an
unhandled client error is caught, as fixed by b1368adc ("BUG/MEDIUM: stream:
Forward shutdowns when unhandled errors are caught"): without it the stream
may freeze when no analyser remains and no wakeup happens.

This patch must be backported with 6c5df88d to all stable versions.

12 hours agoBUG/MINOR: ssl: exclude wolfSSL from custom extension support
William Lallemand [Wed, 18 Nov 2026 10:33:35 +0000 (10:33 +0000)]
BUG/MINOR: ssl: exclude wolfSSL from custom extension support

wolfSSL provides SSL_CTX_add_server_custom_ext() as a stub which always
returns zero. Do not advertise HAVE_SSL_CTX_ADD_SERVER_CUSTOM_EXT when
building with wolfSSL.

Since 8957622353 ("BUG/MEDIUM: ssl: fix an out-of-bounds read on SSL_CTX
switch with a .sctl file"), the extension is registered on every frontend
context. Calling the stub therefore makes certificate loading fail even
when no .sctl file is present.

Exclude wolfSSL from the capability guard while keeping the OpenSSL
registration unchanged.

Verified an ERR=1 build against wolfSSL 5.7.0, the verifyhost_san VTest,
and live TLS requests using all three certificates from that test.

This must be backported to all supported versions.

12 hours agoCI: github: restrict WolfSSL sanitizer flags to debug jobs
William Lallemand [Wed, 18 Nov 2026 10:18:51 +0000 (10:18 +0000)]
CI: github: restrict WolfSSL sanitizer flags to debug jobs

Only override WolfSSL CFLAGS and HAProxy ARCH_FLAGS when debug=1.
Keep WolfSSL debugging and AddressSanitizer enabled for that variant.

For debug=0, use the default WolfSSL compiler flags and HAProxy's
default ARCH_FLAGS=-g, matching the flags of the removed VTest job.
Leave the shared HAProxy debug defines unchanged.

12 hours agoRevert "MINOR: http: add <need_eot> to trailers parsing function"
Willy Tarreau [Wed, 18 Nov 2026 09:05:19 +0000 (10:05 +0100)]
Revert "MINOR: http: add <need_eot> to trailers parsing function"

This reverts commit 6b3b676eb9878862c72bc19ed60068b553b678df.

As seen with Amaury, for now this is not the right approach, we'll
have to rework on it, so let's just revert it for now.

12 hours agoCI: github: test WolfSSL with and without debugging
William Lallemand [Wed, 18 Nov 2026 09:53:37 +0000 (09:53 +0000)]
CI: github: test WolfSSL with and without debugging

Add a debug matrix axis to run WolfSSL 5.7.0 with WOLFSSL_DEBUG=0 and
WOLFSSL_DEBUG=1 in parallel. Include the debug setting in each job name
and disable fail-fast so one variant cannot cancel the other.

Keep AddressSanitizer enabled for both variants and leave the HAProxy
build flags unchanged.

12 hours agoCI: github: include WolfSSL version in job name
William Lallemand [Wed, 18 Nov 2026 09:36:15 +0000 (09:36 +0000)]
CI: github: include WolfSSL version in job name

Define the WolfSSL version once in the job matrix and use it in both the
job display name and the WOLFSSL_VERSION build setting.

This makes the tested version visible in GitHub Actions without
duplicating the version string. The workflow still runs a single job
using WolfSSL 5.7.0.

13 hours agoRevert "BUG/MINOR: h3: fix missing EOM after trailers without FIN" quic-interop
Amaury Denoyelle [Wed, 18 Nov 2026 09:19:20 +0000 (10:19 +0100)]
Revert "BUG/MINOR: h3: fix missing EOM after trailers without FIN"

This reverts commit 2aed0c9bea4a61c0c58a1fc89f4fa98647fe0528.

This fix introduces a major regression as emitting trailers without EOT
is not supported by htx_xfer(). A BUG_ON() in this function is triggered
if rcv_buf runs between the trailers parsing and the FIN reception.

This may reveals deeper limitation which may requires a different
approach for the original issue. A revert is considered the most viable
solution for now until a decision is made the most viable as the
original issue is not a major one.

Several conflits were fixed as code changed multiple times in
H3/hq-interop due to other minor fixes introduced since the bug
introuction.

The faulty patch was not yet picked in stable releases as it was under
observation. As such, it must now be skipped and thus this revert is
only relevant for the current dev tree.

28 hours agoBUG/MAJOR: mux-quic: fail on impossible data transfers in rcv_buf()
Willy Tarreau [Tue, 17 Nov 2026 16:55:22 +0000 (17:55 +0100)]
BUG/MAJOR: mux-quic: fail on impossible data transfers in rcv_buf()

When some data couldn't be transferred from the rxbuf to the channel,
leaving the channel empty (e.g. due to the reserve), we must not set
SE_FL_WANT_ROOM otherwise we cannot get out of this situation and
sc_conn_recv() detects it and panics. Let's just report a stream
error for non-fragmentable contents that exceed the maximum size
and stop here.

This must be backported to all versions.

28 hours agoBUG/MAJOR: h3: do not panic on HTX_FL_PARSING_ERROR after htx_xfer()
Willy Tarreau [Tue, 17 Nov 2026 16:41:01 +0000 (17:41 +0100)]
BUG/MAJOR: h3: do not panic on HTX_FL_PARSING_ERROR after htx_xfer()

After various tests and a long code analysis, it turns out that this
condition which was thought never to be triggerable can finally be
triggered if some data cannot be transferred to the channel due to
the reserve. The condition is rare but not impossible, so let's get
rid of it. This patch must be backported to all stable releases.

28 hours agoBUG/MAJOR: mux-h2: fail on impossible data transfers in rcv_buf()
Willy Tarreau [Tue, 17 Nov 2026 17:27:58 +0000 (18:27 +0100)]
BUG/MAJOR: mux-h2: fail on impossible data transfers in rcv_buf()

When some data couldn't be transferred from the rxbuf to the channel,
leaving the channel empty (e.g. due to the reserve), we must not set
SE_FL_WANT_ROOM otherwise we cannot get out of this situation. There's
even already a BUG_ON() for this. However it turns out that in some
tricky circumstances it can be triggered. The test is thus not correct
and instead we should simply report a stream error.

This needs to be backported as far as 2.6.

Many thanks to Adam Crawford for reporting this issue along with a
repro and a candidate fix. In the end the current fix is different
as it addresses the root cause (WANT_ROOM + no-data) so it should
be more future-proof.

28 hours agoBUG/MAJOR: buf: make the shift distance check less strict in b_move()
Willy Tarreau [Mon, 16 Nov 2026 15:21:26 +0000 (16:21 +0100)]
BUG/MAJOR: buf: make the shift distance check less strict in b_move()

Yuqi Qiu and Xiang Li from Nankai University (AOSP Lab) found during
code analysis that the check "BUG_ON(-shift > size)" in b_move() is
incorrect and can trigger too easily. The test as written like this
to only consider a one-byte minimum move, but the function could also
be called either with a larger move and a large offset, or with no data
and a larger move, typically the result of a full buffer deletion. What
matters is that the moved data plus the shift do not go larger than the
buffer.

Let's fix the test to consider both the length and the distance to save
it from triggering too easily.

The test was added in 2.6-dev3 with commit 8873b85bd9 ("DEBUG: buf: add
BUG_ON_HOT() to most buffer management functions") so this fix must be
backported to all stable versions.

29 hours agoBUG/MEDIUM: dns: release the session slot of expired TCP queries
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.

30 hours agoREGTESTS: decompression: don't use yes(1) in http_large_cl
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.

31 hours agoREGTESTS: http-messaging: check that 1xx don't abort H2 backend tunnels
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.

31 hours agoBUG/MEDIUM: mux-h2: don't abort a tunnel attempt on interim responses
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.

31 hours agoREGTESTS: decompression: test a large decompressed Content-Length response
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.

31 hours agoBUG/MEDIUM: flt-decomp: don't expose EOM before the end of decompression
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.

31 hours agoBUG/MEDIUM: htx: never merge the next DATA block into the referenced one on defrag
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.

33 hours agoBUG/MEDIUM: peers: make the soft-stop "dont_stop" state per peers section
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.

33 hours agoBUG/MEDIUM: stick-tables/cli: "set table" without key must not clear the table
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.

35 hours agoBUG/MINOR: http/hardening: free the new profile on strdup() failure
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.

36 hours agoMINOR: sample: add a "tr" converter
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.

The doc and a reg-test were added.

36 hours agoOPTIM: sample: use smp_prepare_out() in the lower and upper converters
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.

36 hours agoMINOR: sample: add smp_prepare_out() to prepare an output buffer
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.

36 hours agoIMPORT: slz-prv: work around lobotomized compilers' fallthrough diagnostics
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.

This is slz commit 06e2caf45e.

36 hours agoREGTEST: ssl: test tune.h2.fe.enabled and h2_enabled on two instances
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.

36 hours agoMINOR: sample: add h2_enabled to report whether H2 may be used on frontends
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.

36 hours agoMINOR: global: add tune.h2.fe.enabled to disable HTTP/2 on frontends
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

36 hours agoMINOR: 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.

36 hours agoMINOR: ssl: add alpn_remove_token() to drop a protocol from an ALPN string
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.

36 hours agoDEV: h2: mkhdr: support "--" as a delimiter between frame descriptions
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

36 hours agoDEV: h2: mkhdr: support stream ID ranges with -i
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.

36 hours agoDEV: h2: mkhdr: add -n to repeat the emitted frames
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.

36 hours agoDEV: h2: add mkhdr.c, a C port of mkhdr.sh
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).

It's built with "make dev/h2/mkhdr".

36 hours agoDEV: h2: add h2dec, a raw HTTP/2 frame decoder
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".

Example:

  $ dev/h2/mkhdr.sh -t h -i 1 -f es,eh -e :method GET -e :path / | dev/h2/h2dec
  00 00 16 01 05 00 00 00 01  type=HEADERS sid=1 len=22 flags=0x05(ES,EH)
      :method: GET
      :path: /

It's built with "make dev/h2/h2dec".

36 hours agoBUG/MINOR: debug: Do not allocate context when we don't need one
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

38 hours agoBUG/MINOR: quic: initialize the members read by quic_conn_release() first
Frederic Lecaille [Mon, 16 Nov 2026 16:37:50 +0000 (17:37 +0100)]
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().

Must be backported up to 3.3.

38 hours agoBUG/MINOR: quic-be: do not register the connection before the quic_conn is initialized
Frederic Lecaille [Mon, 16 Nov 2026 15:32:13 +0000 (16:32 +0100)]
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.

Must be backported to 3.4.

38 hours agoBUG/MEDIUM: quic-be: keep the source port range of a closing backend connection
Frederic Lecaille [Fri, 13 Nov 2026 17:26:44 +0000 (18:26 +0100)]
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.

38 hours agoBUG/MEDIUM: quic: do not keep 0-RTT packets which cannot be decrypted
Frederic Lecaille [Fri, 13 Nov 2026 16:31:10 +0000 (17:31 +0100)]
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.

38 hours agoREGTESTS: http-messaging: Properly handle WINDOW_UPDATEs with connect_tunnels
Christopher Faulet [Tue, 17 Nov 2026 07:47:17 +0000 (08:47 +0100)]
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.

39 hours agoREGTESTS: http-messaging: Fix abortonclose issue with connect_tunnels
Christopher Faulet [Tue, 17 Nov 2026 07:04:04 +0000 (08:04 +0100)]
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.

2 days agoBUG/MINOR: hq-interop: drop data after request
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.

2 days agoBUG/MINOR: hq-interop: ignore uni streams in HTTP/0.9
Amaury Denoyelle [Mon, 16 Nov 2026 16:16:31 +0000 (17:16 +0100)]
BUG/MINOR: hq-interop: ignore uni streams in HTTP/0.9

HTTP/0.9 only relies on bidirectional streams. To ensure there is no
undefined behavior, this is now enforced this in rcv_buf and attach
callbacks.

Along with this change, redundant checks on bidi stream types are
removed in functions used in the context of these callbacks.

This may be backported to stable releases if needed.

2 days agoBUG/MINOR: hq-interop: skip zero-copy with large buffers
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.

This must be backported up to 3.4.

2 days agoBUG/MEDIUM: stick-tables: compute the shard of string keys on the stored key
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.

2 days agoBUG/MINOR: mjson: bound the exponent in mystrtod()
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.

2 days agoBUG/MEDIUM: sample: parse json_query integers within the token length
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.

This should be backported to all stable branches.

2 days agoMINOR: h3: reject malformed push frames
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.

2 days agoBUG/MINOR: h3: reject CANCEL_PUSH on backend side
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.

This must be backported up to 3.3.

2 days agoBUG/MINOR: h3: skip content-length check on backend bodyless responses
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.

This must be backported up to 3.3.

2 days agoMINOR: http-ana: also match text/event-stream with trailing parameters
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).

Before:
  === 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

After:
  === 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

This should be backported to 3.4 since the commit above is already there.
Thanks to @glenn-jocher for reporting and diagnosinc this limitation.

2 days agoDEV: sse-latency: add a parameter after the content-type
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")

2 days agoMEDIUM: compression/slz: use the event content type for server-sent events
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%

2 days agoMINOR: compression: add tune.comp.res.ring to disable the rings of responses
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.

2 days agoMINOR: compression: pass COMP_CT_EVENT to the algorithms for server-sent events
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%

2 days agoIMPORT: slz: update slz to 1.4-dev5-24
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).

5 days agoDOC: config: explain the effect of the weights on random's draws
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>
5 days agoMEDIUM: backend: avoid picking the same server twice in random draws
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:

  4 srv: req rate= 11.1k/s    8 srv: req rate = 15.8k/s
    srv  max  total             srv  max  total
     s0   63   8525              s0   29   2248
     s1   27  28296              s1   17  13874
     s2   28  31049              s2   17  13869
     s3   29  32130              s3   18  13996
                                 s4   18  14316
                                 s5   17  14325
                                 s6   16  13758
                                 s7   16  13614

Now with the patch:

  4 srv: req rate= 14.6k/s    8 srv: req rate = 16.6k/s
    srv  max  total             srv  max  total
     s0   29   3572              s0   17   1669
     s1   28  31380              s1   15  14007
     s2   29  32513              s2   16  14010
     s3   29  32535              s3   15  14059
                                 s4   16  14205
                                 s5   16  14215
                                 s6   16  13968
                                 s7   15  13867

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

[1] https://www.mail-archive.com/haproxy@formilux.org/msg47740.html

5 days agoOPTIM: 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.

5 days agoOPTIM: lb-chash: don't look for more servers when there is only one
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.

5 days agoBUG/MEDIUM: mux_quic: fix Rx flow control increment on RESET_STREAM
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.

  1b2bd2aeef08209664585e4b3f230744835257d9
  BUG/MINOR: mux_quic: report conn error on RESET_STREAM fctl violation

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.

5 days agoBUG/MINOR: log: don't let an LF in a forwarded message create new events
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.

This should be backported to all stable branches.

5 days agoBUG/MINOR: http-ana: don't emit a network-path Location for a "/" redirect prefix
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.

The reg-test redirect-self-path.vtc covers it.

This should be backported to all stable branches.

5 days agoBUG/MINOR: sample: reject a \0 byte in raw string fetches
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.

The reg-test str_embedded_nul.vtc covers it.

This should be backported along with 37204a71a.

5 days agoBUG/MINOR: sample: fix host_only and port_only on empty input
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.

This should be backported to 2.8 and later.

5 days agoBUG/MINOR: h3: prevent missing request FIN on empty trailers
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.

  8020cefc30ceadf61b45130609b90fdbb0741840
  BUG/MEDIUM: h3: prevent conn failure on trailers decoding without space

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.

This must be backported up to 2.8.

5 days agoBUG/MINOR: quic: remove CID on BE conn alloc failure
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.

This must be backported up to 3.3.

5 days agoBUG/MINOR: cache: skip already resolved filters when resolving caches
Christopher Faulet [Wed, 21 Oct 2026 09:25:01 +0000 (09:25 +0000)]
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.

5 days agoBUG/MEDIUM: mux-h1: Report EOS when a demux error is handled by the app layer
Christopher Faulet [Fri, 13 Nov 2026 09:02:36 +0000 (10:02 +0100)]
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.

5 days agoBUG/MEDIUM: fd: Mark a fd as dead on early close
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.

This should be backported to all supported versions, when
ad082111a04b4387f8aa76e386a2f340f9583bd2 has been backported already.

This should fix github issue #3573.

5 days agoBUG/MINOR: init: fix missing error on no listener on config check
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.

This should fix github issue #3567.

No need to backport.

5 days agoBUG/MINOR: qmux: remove invalid BUG_ON() on empty record
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.

This must be backported up to 3.4.

6 days agoBUG/MINOR: quic: fix ACK_ECN parsing after optional ack ranges
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.

  7aa839296de9e6d330c6a952ae2197aa49db1c66
  BUG/MEDIUM: quic: fix ACK ECN frame parsing

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.

This must be backported up to 2.6.

6 days agoREGTESTS: cache: cover the object lifetime with a single script
Christopher Faulet [Thu, 12 Nov 2026 15:39:34 +0000 (16:39 +0100)]
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.

6 days agoBUG/MINOR: cache: do not ignore null lifetimes not written as "max-age=0"
Christopher Faulet [Wed, 21 Oct 2026 09:02:42 +0000 (09:02 +0000)]
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.

6 days agoBUG/MINOR: cache: compare the Age to the heuristic lifetime when none is given
Christopher Faulet [Wed, 21 Oct 2026 09:02:01 +0000 (09:02 +0000)]
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.