]> git.kaiwu.me - haproxy.git/log
haproxy.git
2 hours agoBUG/MEDIUM: ssl: do not resume sessions whose client cert failed the verification master
William Lallemand [Tue, 1 Dec 2026 16:59:57 +0000 (16:59 +0000)]
BUG/MEDIUM: ssl: do not resume sessions whose client cert failed the verification

The ssl_c_err, ssl_c_ca_err and ssl_c_ca_err_depth sample fetches read
the verify errors that ssl_sock_bind_verifycbk() stores in the
connection's xprt_st. This callback is only called during a full
handshake: on a resumed session (TLS ticket, session ID or TLS 1.3 PSK),
xprt_st is reset and the callback does not run, so the three fetches
return 0 (X509_V_OK) even when the session was established with a client
certificate whose verification failed, whether the error was ignored by
"ca-ignore-err" or "crt-ignore-err" or not. ssl_c_verify is not affected
because it reads the verify result stored in the session.

A user may mistakenly rely on these fetches for access control on resumed
sessions, for example after ignoring verification errors with
"ca-ignore-err" or "crt-ignore-err". Such a configuration can reject an
expired, revoked or self-signed client certificate on the first
connection, then accept the same client when it resumes the session.

Fix this by clearing the session id context when the verification fails,
whether the error is ignored or not, so that a session established with
a failed verification cannot be resumed: the next connection performs a
full handshake and the verify callback fills xprt_st again.

Sessions whose verification succeeded keep resuming as before.

This should be backported to all stable branches after an observation period.

Reported-by: Justin Sun <justin@capy.ai>
3 hours agoDOC: config: ssl_c_err, ssl_c_ca_err and ssl_c_ca_err_depth on resumed sessions
William Lallemand [Tue, 1 Dec 2026 16:59:52 +0000 (16:59 +0000)]
DOC: config: ssl_c_err, ssl_c_ca_err and ssl_c_ca_err_depth on resumed sessions

The ssl_c_err, ssl_c_ca_err and ssl_c_ca_err_depth fetches are only filled
by ssl_sock_bind_verifycbk(), which only runs during a full handshake: on
a resumed session they read 0 (X509_V_OK), even when the session was
established with a client certificate whose verification reported an
error, ignored or not. ssl_c_verify reads the verify result stored in the
session and is not affected.

Document this limitation for each of the three fetches, and mention that
access decisions should rather be taken on ssl_c_verify, which stays
correct on resumed sessions.

This must be backported to all stable branches.

4 hours agoMINOR: ssl: unset SSLKEYLOGFILE unless explicitly allowed
William Lallemand [Tue, 1 Dec 2026 12:56:42 +0000 (12:56 +0000)]
MINOR: ssl: unset SSLKEYLOGFILE unless explicitly allowed

OpenSSL 3.5 builds configured with enable-sslkeylog honor SSLKEYLOGFILE
and write TLS connection secrets directly to a file. This bypasses HAProxy
logging, adds filesystem access during handshakes, degrades performance
and leaks file descriptors across master-worker reloads. HAProxy already
provides tune.ssl.keylog and sample fetches for logging these secrets
through its normal logging facilities.

Replace the startup warnings with a conditional unsetenv() before full
configuration parsing can load certificates and create SSL contexts.
Add the experimental ssl-workaround-bogus-keylogfile { on | off } global
option, defaulting to off. Setting it to on leaves the variable untouched;
setting it to off keeps the default behavior of removing the variable.

Discover this option and expose-experimental-directives during the initial
configuration pass so the decision is known before certificate loading.
Repeat the conditional unsetenv() after a worker restores its initial
environment. Keep the original environment backup unchanged so reloads
can reevaluate the option, without copying or restoring the variable.

Document the OpenSSL version and build option requirements, discourage
native key logging due to its filesystem access and reload issues, and
recommend tune.ssl.keylog instead.

5 hours agoBUG/MINOR: server: reject from/name in peers section
Amaury Denoyelle [Tue, 1 Dec 2026 12:58:55 +0000 (13:58 +0100)]
BUG/MINOR: server: reject from/name in peers section

The new positional keywords 'from' and 'name' were introduced to extend
server inheritance. However, nothing was implemented to ensure they were
rejected in a peers section.

Thus, it would be possible for a peer server to inherit from a
default-server in a standard backend. This could cause unexpected
behavior as a peer server does not support the full keyword range of the
instances declared in standard proxies.

Clarify this situation by rejecting usage of these keywords in a peers
section. A fatal error is reported if this is encountered.

Note that _srv_parse_from() is still called for peers server and
default-server, as it is necessary to preserve the original unnamed
default-server overloading mechanism. The new error is only reported if
'from' is found.

This is not a breaking change since 'from' and 'name' were implemented
in the current dev branch.

No need to backport.

5 hours agoBUG/MEDIUM: peers: don't push updates before a reloaded process resyncs
Frederic Lecaille [Tue, 1 Dec 2026 14:16:33 +0000 (15:16 +0100)]
BUG/MEDIUM: peers: don't push updates before a reloaded process resyncs

On a soft reload, the new process starts with empty stick-tables and
serves immediately. As soon as its sessions to the remote peers are up,
peer_send_msgs() pushes its own values to them: it only checks the learn
state of the destination peer, never the resync state of the process
itself. The remote peers overwrite their entries with those values, then
count them and push them back, possibly after the old process's lesson
has arrived. Since updates carry absolute values and no ordering, the key
then continues from the value counted from scratch on every peer, and its
whole history is lost.

The same race is visible before the local lesson is even assigned: the
first push to a remote peer happens as soon as that session is up, which
is what makes the reset possible when both nodes write the same key.

Fix this by not pushing anything while the process has not finished its
resync (PEERS_RESYNC_FINISHED). Updates made meanwhile are not lost:
they are sent with their current value once the resync is over, which is
correct since a message carries a value and not an increment.

This is restricted to a process started from older ones, which is what
nb_oldpids accounts for: it is non-zero only when -sf or -st was used and
the signal could be delivered to the old processes. An instance started
on its own has no older process to learn from, and holding its pushes
back delays the replication of its entries by up to PEER_RESYNC_TIMEOUT
(5s): with no ancestor and two peers starting empty, neither can teach
the other, so the remote resync state is only left on timeout. This is
not theoretical: with the condition applied unconditionally, both
reg-tests/stickiness/{srvkey-addr,lb-services}.vtc fail. They start two
instances without ancestors, one side reports used:0, and the requests
routed there get a 504 or time out. Both pass with the nb_oldpids
restriction, which only affects processes that really are reloaded.

The condition was introduced with the peers code itself, so it should be
backported to all stable versions.

This fixes GitHub issue #3613. Thank you to @swenske for the detailed
report, the traces and the analysis of the race.

5 hours agoMEDIUM: ssl: never return 0 from the BIO read callback
Olivier Houchard [Tue, 1 Dec 2026 14:35:29 +0000 (15:35 +0100)]
MEDIUM: ssl: never return 0 from the BIO read callback

Commit "BUG/MEDIUM: ssl: ignore unexpected EOFs reported by the SSL
library" sets SSL_OP_IGNORE_UNEXPECTED_EOF so that a close without a
close_notify is no longer turned into an error by OpenSSL 4.0 and AWS-LC
5.9. But with this option, the library reports such a close exactly as
if a close_notify had been received, so there is no way to tell them
apart anymore. We don't use that information for now, but we may want
to in the future.

Let's remove the option, and make ha_ssl_read() return -1 with no retry
flag instead of 0 when the connection is shut or in error, as is already
done for a shutdown during a frontend handshake. The library then
reports a syscall failure, as older versions did, which
ssl_sock_to_buf() handles as a regular shutdown.

This should not be backported, the commit above is enough for the
stable versions.

5 hours agoBUG/MEDIUM: ssl: ignore unexpected EOFs reported by the SSL library
Olivier Houchard [Tue, 1 Dec 2026 14:35:29 +0000 (15:35 +0100)]
BUG/MEDIUM: ssl: ignore unexpected EOFs reported by the SSL library

When the peer closes the connection without sending a close_notify,
ha_ssl_read() returns 0. OpenSSL 4.0 and AWS-LC 5.9 now take this for an
unexpected EOF and fail the connection, where older versions reported a
syscall failure that ssl_sock_to_buf() handles as a regular shutdown.
Such closes are then logged as errors ("CD" or "SD") and the other side
gets a reset. With OpenSSL 4.0 a fatal alert is also emitted on the
closed connection, which prevents TLSv1.2 sessions from being resumed
and makes tcp-check-ssl.vtc fail.

Let's set SSL_OP_IGNORE_UNEXPECTED_EOF on the bind and server contexts
when the library provides it, so that such a close is reported as a
clean shutdown again.

This must be backported to all supported versions. This was reported in
GitHub issue #3605 by Yeonggi Kim, who also suggested this fix.

5 hours agoDOC: vars: Add missing http/tcp-check part of the set-vars-from-map action
Remi Tricot-Le Breton [Tue, 1 Dec 2026 14:30:47 +0000 (15:30 +0100)]
DOC: vars: Add missing http/tcp-check part of the set-vars-from-map action

This action can be used in both tcp-check and http-check rules but it
was never mentioned in the doc.

6 hours agoBUG/MINOR: ocsp: Fix too strict parser of 'do-ocsp-request' action
Remi Tricot-Le Breton [Tue, 1 Dec 2026 13:33:37 +0000 (14:33 +0100)]
BUG/MINOR: ocsp: Fix too strict parser of 'do-ocsp-request' action

The parsing function of the 'do-ocsp-request' action raised an error on
any argument different than the expected 'reason-var' and 'status-var'
ones, but it prevented any 'if' condition from being added at the end.

This patch does not need to be backported.

6 hours agoBUG/MINOR: pattern: do not index too large prefixes using the tree
Willy Tarreau [Tue, 1 Dec 2026 13:25:01 +0000 (14:25 +0100)]
BUG/MINOR: pattern: do not index too large prefixes using the tree

This is exactly the same as commit 60904f86 ("BUG/MINOR: pattern: do
not index too large strings using the tree") but for pat_idx_tree_pfx()
this time: we need to limit the length of indexed prefixes with trees
to 4095 bytes, the other ones need to use the list.

This needs to be backported to all versions.

6 hours agoIMPORT: uslz: fix a build warning with gcc -O1
Willy Tarreau [Tue, 1 Dec 2026 10:56:22 +0000 (11:56 +0100)]
IMPORT: uslz: fix a build warning with gcc -O1

At -O1, gcc emits this warning because it doesn't clearly see that all
paths reach this place with sym properly initialized:

  src/uslz.c: In function 'uslz_eob_follows':
  src/uslz.c:745:18: warning: 'sym' may be used uninitialized in this function [-Wmaybe-uninitialized]
    745 |         if (!ret || sym != 256)
        |             ~~~~~^~~~~~~~~~~~~

Let's just preset it to zero. Unfortunately it slightly inflates the code
with more instructions and stack usage because the compiler does not see
that the called functions don't use it, but it has almost no impact on
measured performance. Another approach consists in passing the pointer to
state->symbol, but even if it reduces the code, it suffers a bigger slowdown
likely due to having to access the member that's a bit colder in the cache.

This is slz commit 544c4d5cca. No backport to haproxy stable versions is
needed.

7 hours agoBUILD: mux-quic: silence an invalid null-deref warning at -O1
Willy Tarreau [Tue, 1 Dec 2026 10:52:40 +0000 (11:52 +0100)]
BUILD: mux-quic: silence an invalid null-deref warning at -O1

It's just because it sees that qcs_sc(qcs) can return a NULL, but on
the second call it forgets it just tested it, as usual. Let's pass it
via a local variable.

9 hours agoBUG/MEDIUM: peers: do not clear the alive flag of a replacement session
Hyeonggeun Oh [Mon, 30 Nov 2026 16:31:20 +0000 (16:31 +0000)]
BUG/MEDIUM: peers: do not clear the alive flag of a replacement session

When an incoming connection supersedes an established session with the
same peer, the old applet is shut down with peer_session_forceshutdown(),
then the new one is installed and the peer is flagged PEER_F_ALIVE. But
when the old applet is released later, peer_session_release() clears
PEER_F_ALIVE unconditionally, even though the applet does not own the
peer anymore. The collision delay before the next liveness check is 50 to
2049ms while the first heartbeat is due after 3s, so the sync task finds
the replacement not alive and kills it.

The liveness is tracked per session, so clear the flag in
__peer_session_deinit(), which is only called for the applet owning the
peer, instead of on every applet release. In the collision path, the
deinit happens before the new session is flagged, so the order is
preserved.

This should fix GH issue #3519. It must be backported to all stable
versions.

Signed-off-by: Hyeonggeun Oh <hyeonggeun.oh@plaintexting.com>
9 hours agoRevert "BUG/MINOR: http-ana: Increment scf bytes_out value if an haproxy error is...
Christopher Faulet [Tue, 1 Dec 2026 08:12:29 +0000 (09:12 +0100)]
Revert "BUG/MINOR: http-ana: Increment scf bytes_out value if an haproxy error is sent"

This reverts commit 306931dfb1d3b40cf0e2364be0fe719389905feb. The internal
responses are already accounted when data are forwarded to the mux on front
side, in sc_conn_send().

This patch should fix the issue #3614. It must be backported as far as 3.3.

9 hours agoRevert "OPTIM: acl: only reset ctx and flags, not the whole sample"
Willy Tarreau [Tue, 1 Dec 2026 10:40:50 +0000 (11:40 +0100)]
Revert "OPTIM: acl: only reset ctx and flags, not the whole sample"

This reverts commit 903405ce3c3c09352503423cb67117a7e95a518d.

According to Claude (?) this is the one that breaks the CI because some
bogus sample fetches rely on pre-existing data before the call. This
possibly indicates a new class of bugs to take care of, so that's not
in scope for this version.

10 hours agoBUG/MEDIUM: leastconn: don't hide an avoided server from later lookups
Olivier Houchard [Tue, 1 Dec 2026 10:15:30 +0000 (11:15 +0100)]
BUG/MEDIUM: leastconn: don't hide an avoided server from later lookups

When fwlc_get_next_server() walks past a node without picking a server
from it, it raises the smallest key recorded in lbprm.lb_seq so that the
next lookups start further. It also does so after skipping the server to
avoid on a redispatch, though this server remains usable for everybody
else. The server then stays out of the lookups until another one is
queued at a key at or below its own: it gets no traffic while being the
least loaded, and if the other servers leave, requests are queued and
end with a 503 while a server is up.

Fix it by no longer raising the smallest key once a server was avoided
in the lookup. It can be reproduced with two servers, "retry-on 503" and
"option redispatch": hold a few requests on one server and have the
other one return a 503, the next requests all go to the busy server.

This was introduced by commit 9fe72bba3 ("MAJOR: leastconn; Revamp the
way servers are ordered.") in 3.2-dev9. This must be backported as far
as 3.2.

9 hours agoBUG/MEDIUM: ssl: fix verify bypass on duplicated crt-list ssl configs
William Lallemand [Tue, 1 Dec 2026 10:09:18 +0000 (10:09 +0000)]
BUG/MEDIUM: ssl: fix verify bypass on duplicated crt-list ssl configs

crtlist_dup_ssl_conf() duplicates a ssl_bind_conf for the crt-list
entries created by the multi-keytype bundle emulation (crt.pem.ecdsa +
.pem.rsa) and for each "ssl-f-use" rule, but it never copied the
verify, no_ca_names, early_data and ktls scalar fields. Because dst
is allocated with calloc(), the duplicates always carried
verify == SSL_SOCK_VERIFY_NONE, so the switch in
ssl_sock_prepare_ctx() fell back to the bind-level ssl_conf and
configured OpenSSL with SSL_VERIFY_NONE: a "verify required ca-file"
set on a crt-list line or on a ssl-f-use line was silently ignored
for every keytype of a bundle (and for the whole frontend with
ssl-f-use), letting unauthenticated clients complete the TLS
handshake and reach the backend with ssl_c_used == 0, without any
warning at startup or under "haproxy -c".

The bundle duplication exists since 2.3 and the ssl-f-use rules since
3.2. Copying the scalar fields is enough to restore the intended
behaviour: entry-level verify is now enforced on every duplicated
entry.

Note for backports: the ktls field of struct ssl_bind_conf was
introduced in 3.3 (e8674658aec "MINOR: cfgparse: Add a new ktls option
to bind and server"), so the "dst->ktls = src->ktls;" line must be
dropped when backporting to 3.2, 3.1 and 3.0. The other three fields
(verify, no_ca_names, early_data) exist in every concerned branch.

Reported-by: Dominik Maier <dmnk@google.com>
9 hours agoBUG/MINOR: ssl: fix ALPN/NPN loss on duplicated crt-list ssl configs
William Lallemand [Tue, 1 Dec 2026 10:08:57 +0000 (10:08 +0000)]
BUG/MINOR: ssl: fix ALPN/NPN loss on duplicated crt-list ssl configs

The npn_str and alpn_str buffers of a ssl_bind_conf are not plain C
strings but length-prefixed wire-format buffers built by
ssl_sock_parse_alpn(), where each protocol name is preceded by its
length byte and the total length is kept in npn_len/alpn_len. The
duplicates produced by crtlist_dup_ssl_conf() for the multi-keytype
bundle emulation and for the "ssl-f-use" rules were copied with
strdup() up to the first NUL byte, so any protocol name whose wire
length byte is zero terminated the copy early, and npn_len and alpn_len
were left to their calloc() default of 0. As a result
ssl_sock_prepare_ctx() saw alpn_len == 0 and never registered the ALPN
selection callback: the "alpn" and "npn" parameters of a crt-list line
or of a ssl-f-use line were silently dropped for every duplicated
entry, and the negotiation fell back to no ALPN.

Copy the buffers with their explicit lengths and carry npn_len and
alpn_len over to the duplicate, so the callback is registered and
advertises the full protocol list.

This must be backported to 3.4, 3.3, 3.2 and 3.1.

Reported-by: Dominik Maier <dmnk@google.com>
9 hours agoBUG/MINOR: ssl: free ech_filedir in ssl_sock_free_ssl_conf()
William Lallemand [Tue, 1 Dec 2026 10:08:08 +0000 (10:08 +0000)]
BUG/MINOR: ssl: free ech_filedir in ssl_sock_free_ssl_conf()

The "ech" parameter of a bind line stores the ECH keys directory in
ssl_bind_conf.ech_filedir, and the bind-level ssl_conf goes through
ssl_sock_free_ssl_conf() in ssl_sock_free_bind_conf(), but the
function never freed the field: the string was leaked at each proxy
stop and start, so on every reload of a configuration using
"bind ... ssl ech <dir>".

Free ech_filedir in ssl_sock_free_ssl_conf(), guarded by USE_ECH like
its assignment in bind_parse_ech().

This must be backported to 3.4, 3.3, 3.2 and 3.1.

Reported-by: Dominik Maier <dmnk@google.com>
10 hours agoCLEANUP: quic: refactor qc_new_conn() to use an obj_type
Amaury Denoyelle [Tue, 1 Dec 2026 09:36:49 +0000 (10:36 +0100)]
CLEANUP: quic: refactor qc_new_conn() to use an obj_type

Function qc_new_conn() is used both on frontend and backend sides. First
parameter was a void pointer, either referring to a listener or a server
instance, depending on the proxy side. This was used to set either the
local listener or the local server variable, the other one remaining
NULL.

This code works as expected, but it triggers a false report from
coverity, which has no way to know that either the listener or the
server is set. Adjust the code to use an obj_type enum pointer instead
of an opaque one, plus a switch statement that makes this state
explicit.

This should fix coverity report from github issue #3247.

12 hours agoOPTIM: pattern: use ebst_lookup_len() when possible
Willy Tarreau [Mon, 30 Nov 2026 19:49:54 +0000 (20:49 +0100)]
OPTIM: pattern: use ebst_lookup_len() when possible

In pat_match_str(), we're looking up strings using ebst_lookup(),
but we know the length and already have ebst_lookup_len() that is
made for this purpose, so better rely on it since it's a bit faster.
This speeds up request rate by 1% on configs with a few tens of
string lookups.

12 hours agoOPTIM: acl: only reset ctx and flags, not the whole sample
Willy Tarreau [Mon, 30 Nov 2026 18:56:25 +0000 (19:56 +0100)]
OPTIM: acl: only reset ctx and flags, not the whole sample

When evaluating an ACL, each expression starts with a memset(0) on the
local sample before calling sample_process(). This is a waste, as the
comment clearly says that the goal is to reset ctx and flags (i.e. 52
bytes), not the whole 144 (no need to erase a possibly older IPv6
address). Let's just do precisely that, because tests with many ACLs
show that up to 1.5% CPU is spent there with a few tens of rules, and
this memset() alone is responsible for 12-20% of the whole function's
time for short matches.

12 hours agoOPTIM: acl: always keep the local sample 64-byte aligned
Willy Tarreau [Mon, 30 Nov 2026 18:55:29 +0000 (19:55 +0100)]
OPTIM: acl: always keep the local sample 64-byte aligned

Better have this sample aligned in the stack, it's used for literally
every match and it experiences a memset(0) for each of them. Having it
aligned encourages the compiler to use SIMD instructions instead of
rep stos to clear it.

12 hours agoCLEANUP: sample: reduce struct sample by filling a hole
Willy Tarreau [Mon, 30 Nov 2026 18:55:00 +0000 (19:55 +0100)]
CLEANUP: sample: reduce struct sample by filling a hole

The struct sample keeps a 32-bit hole at the beggining after the flags,
and ends up with a 32-bit member (opt) that imposes extra padding.
Let's just move opt into the hole and reduce it from 152 to 144 bytes.
That counts more than it seems because a lot of expression processing
creates copies of samples or memset() them (e.g. in every pattern match
in ACLs).

12 hours agoCLEANUP: pattern: remove the unneeded strlen in pat_idx_tree_pfx()
Willy Tarreau [Mon, 30 Nov 2026 18:01:15 +0000 (19:01 +0100)]
CLEANUP: pattern: remove the unneeded strlen in pat_idx_tree_pfx()

The pattern's length is already known since it's passed with the
string, so let's use it as-is instead of calling strlen() on the
pattern to be indexed.

12 hours agoMINOR: tools: add memupper() / memlower() to convert a memory block
Willy Tarreau [Tue, 1 Dec 2026 06:59:26 +0000 (07:59 +0100)]
MINOR: tools: add memupper() / memlower() to convert a memory block

These were taken from sample_conv_str2upper() andample_conv_str2lower()
respectively. They're inline and operate on an opaque memory block cast
to uchar. They're vectorizable when the compiler knows the length. The
original functions were updated to call them, the code does not change.

28 hours agoBUG/MINOR: h1-htx: report the trailer parsing error position
Christopher Faulet [Mon, 30 Nov 2026 15:31:05 +0000 (16:31 +0100)]
BUG/MINOR: h1-htx: report the trailer parsing error position

Trailer parsing uses a dedicated h1m (tlr_h1m) whose err_pos is relative to
the start of the trailers in the source buffer, i.e. to the offset passed
to h1_parse_msg_tlrs(). On a parsing error the main message's err_pos was
set to h1m->next, the chunk-parsing position, so the error snapshot taken
by h1_capture_bad_message() pointed to the wrong location.

h1_parse_msg_tlrs() now seeds tlr_h1m.err_pos with -1 or -2 depending on
the caller's leniency instead of copying h1m->err_pos. This way a stale
non-negative err_pos left over from a tolerated violation in the main
message headers can no longer suppress the trailer parser's capture (all
capture branches in h1_headers_to_hdr_list() are gated on err_pos == -1),
and it cannot be leaked back into the main message either.

On error, when the trailer parser pinpointed the faulty byte, the main
message's err_pos is now set to ofs + tlr_h1m.err_pos, i.e. the position
in the source buffer. Otherwise the previous behavior (h1m->next) is kept
as the fallback. This mirrors what h1_parse_msg_hdrs() already does for
headers via h1m->next, and makes mux_h1/mux_fcgi capture the correct
position for the H1_MSG_TRAILERS state.

No backport needed, this only affects error snapshots reporting.

29 hours agoDOC: config: document the FCGI path handling and its security implications
Christopher Faulet [Mon, 30 Nov 2026 14:15:15 +0000 (15:15 +0100)]
DOC: config: document the FCGI path handling and its security implications

Some users report the FCGI support as a security issue because the
request path is URL-decoded and used to build the SCRIPT_NAME,
SCRIPT_FILENAME, PATH_INFO and PATH_TRANSLATED parameters without any
check: a path with '.' or '..' segments, or an absolute path, may point
outside the document root, and if the FastCGI application executes the
corresponding script, it may serve arbitrary files.

This is intentional. HAProxy does not normalize request paths by
default and passes them as-is, because only the component that will
interpret the request reliably knows how to normalize its paths
depending on its environment. HAProxy is not aware of the file system
layout, the mount points or the symlinks on the remote host, so it
cannot safely know if a path is finally inside or outside the document
root. It is the application's responsibility to check the script it is
asked to execute, exactly like for a web server, and it may also be
handled by the administrator with http-request rules.

To prevent the same question from being raised again, this is now
clearly documented in a new section 10.4 'Path handling and security
considerations', with a pointer from the docroot directive.

No backport is needed.

29 hours agoDOC: config: Fix docroot description indentation
Christopher Faulet [Mon, 30 Nov 2026 14:22:21 +0000 (15:22 +0100)]
DOC: config: Fix docroot description indentation

The description of the FCGI docroot directive was not properly
indented. Let's fix it.

29 hours agoMINOR: htx: never create, leave nor accept an empty HTX block
Christopher Faulet [Mon, 30 Nov 2026 13:36:36 +0000 (14:36 +0100)]
MINOR: htx: never create, leave nor accept an empty HTX block

An HTX block of any type must never have a size of 0. A zero-sized DATA
block especially has a special meaning on the wire: for a chunked
message, mux-h1 emits a zero-sized chunk, i.e. the last-chunk,
prematurely ending the message for the peer, and any data following in
the HTX message would then be interpreted as a new message (request
smuggling towards a server, response splitting towards a client).

HTX producers are not supposed to leave empty blocks and no way was
found to make a client or server create one, but the HTX API itself
could create or leave them, and the consequence would be dramatic. So
the invariant is now enforced by the HTX API:

  * __htx_add_blk() is the single entry point for block creation, it
    now refuses to create a block of size 0. htx_add_data_atonce() and
    htx_add_last_data() thus also refuse empty data.

  * htx_replace_blk_value() refuses a replacement that would empty the
    block, returning NULL as if there was not enough space. The caller
    must then remove the block itself with htx_remove_blk().

  * htx_change_blk_value_len() and htx_set_blk_value_len() now BUG_ON
    if they would empty a block, except for a header or a trailer whose
    value may legitimately be empty because the name is never empty.

  * htx_cut_data_blk() now BUG_ONs if the cut removes the whole block.

Special blocks (EOH, EOT, NOOP) are created with a size of 1, and no
other block is ever created empty, so no legitimate caller is affected.
The two callers that could produce an empty block were fixed in the two
previous commits.

29 hours agoBUG/MINOR: flt-decomp: don't leave an empty DATA block when draining
Christopher Faulet [Mon, 30 Nov 2026 13:36:33 +0000 (14:36 +0100)]
BUG/MINOR: flt-decomp: don't leave an empty DATA block when draining

When there is not enough room to drain the decompressed data,
decomp_stream_blk_drain() replaces the fully consumed part of the DATA
block with the drained data. But if nothing could be drained, i.e. the
drainable length is 0, and the block was fully consumed, the block was
left empty in the HTX message. Similarly, when the function is called
without a block, because there is no DATA block to drain into, a
zero-sized DATA block could be added if nothing was drainable.

An empty DATA block is not supposed to remain in an HTX message. For a
chunked message, mux-h1 would emit a zero-sized chunk, i.e. the
last-chunk, prematurely ending the message for the client and making
it interpret any remaining data as a new message (response splitting).

So, when the block is fully consumed and nothing can be drained in its
place, the block is now removed instead of being emptied, taking care
of the EOM flag, if the block was carrying it. And when there is no
block to drain into, nothing is added if nothing is drainable. This
latter case is handled by htx_add_last_data() which refuses empty data.

This is a latent bug, no way was found to trigger it with a
well-behaving client or server, but the HTX API is about to enforce the
no-empty-data-block invariant, so the filter must behave accordingly.

No backport needed.

29 hours agoBUG/MINOR: stats: never add an empty DATA block in the HTX message
Christopher Faulet [Mon, 30 Nov 2026 13:28:10 +0000 (14:28 +0100)]
BUG/MINOR: stats: never add an empty DATA block in the HTX message

In stats_putchk(), the current chunk is added to the HTX message with
htx_add_data_atonce(), without checking the chunk is not empty. If the
chunk is empty when the function is called, a zero-sized DATA block is
added to the HTX message. For a chunked response, mux-h1 would emit a
zero-sized chunk, i.e. the last-chunk, prematurely ending the message
for the client and making it interpret any remaining data as a new
message (response splitting).

No way was found to make a stats dump produce an empty chunk, so this
is a latent bug, but the HTX API is not supposed to accept empty data
blocks and the consequence would be dramatic. So, let's simply skip the
add when the chunk is empty. It also avoids stats_putchk() to wrongly
report a full buffer once the HTX API starts to refuse empty data.

This may be backported if desired.

29 hours agoBUG/MINOR: spoe: force "always" reuse policy when converting SPOP backend
MarcWort [Mon, 30 Nov 2026 07:37:21 +0000 (08:37 +0100)]
BUG/MINOR: spoe: force "always" reuse policy when converting SPOP backend

When an SPOE agent uses a backend declared in "mode tcp", the backend is
automatically converted to "mode spop" during configuration validation.
The conversion is done in spoe_check(), which is called from flt_check(),
i.e. after proxy_finalize() has already normalized the mode-dependent
options of that backend. Seeing the backend was still in TCP mode at the
time, its http-reuse policy was stripped down to "never", while explicit
"mode spop" backends are unconditionally forced to "always".

Fix this by forcing PR_O_REUSE_ALWS (after clearing the reuse bits) when
the backend is converted to SPOP mode, which is exactly the policy an
explicit "mode spop" backend ends up with in proxy_finalize().

This patch should fix the issue #3611. It should to be backported as far as
3.2.

29 hours agoBUG/MEDIUM: mux-h1: defer read0 while input is buffered
Andrea Cocito [Fri, 27 Nov 2026 15:19:57 +0000 (16:19 +0100)]
BUG/MEDIUM: mux-h1: defer read0 while input is buffered

On kqueue, backend EOF may be reported while the H1 mux still has response
body bytes in h1c->ibuf. With a flow-controlled H2 or H3 consumer,
h1_fastfwd() can forward only part of those bytes, then observe read0 while
h1m->curr_len is still nonzero. It reports a truncated response and aborts
the client stream even though the remaining bytes are already in memory.
In the affected FreeBSD/H3 workload, 16 KiB responses reached the client
as 16,066 bytes and curl reported a partial transfer.

Classify read0 in this fast-forward path only after h1c->ibuf is empty.
Keep fast forwarding active so a later consumer window update can drain the
buffer. The existing EOS/EOI and genuine-truncation decisions then run with
the correct remaining message length.

A VTest reproducer holds the H2 window closed until the backend closes,
then opens it in steps to force read0 with buffered H1 input. It fails on
unpatched macOS and FreeBSD kqueue builds and passes with the fix. The same
fix passes on the affected 3.4.7 source and current 3.4.9 maintenance source.
A genuinely short Content-Length response still forwards exactly the sent
bytes and resets the H2 stream.

This patch should fix the issue #3612. It must be backported as far as 3.0.

29 hours agoREGTESTS: quic: backend must adopt the SCID of the first valid Initial
Frederic Lecaille [Mon, 30 Nov 2026 14:58:45 +0000 (15:58 +0100)]
REGTESTS: quic: backend must adopt the SCID of the first valid Initial

Add a regression test for the QUIC backend connection: a fake backend
answers haproxy's Initial with a header-protected packet whose AEAD tag
is corrupted, then with a valid Initial carrying another Source
Connection ID. The ACK sent back by haproxy must use the SCID of the
valid Initial only, since RFC 9000 7.2 requires the first valid Initial
to be adopted and RFC 9000 11.1 forbids a discarded packet from leaving
effects behind.

The test relies on a Python driver (scid_initial_backend.py) reserving
the backend UDP port and emulating the server side of the handshake.

29 hours agoBUG/MINOR: quic-be: install the peer CID only from an accepted Initial
deanliang06 [Mon, 30 Nov 2026 14:31:40 +0000 (09:31 -0500)]
BUG/MINOR: quic-be: install the peer CID only from an accepted Initial

On backend QUIC connections, parsing an Initial header sets the peer
CID before the packet is validated. If that packet is discarded, a
later valid Initial cannot replace the CID. If the CIDs differ, the
backend handshake can fail.

Install the peer CID only after the Initial has been decrypted and its
frames have been parsed. Preserve the existing Retry handling.

This should be backported up to 3.3, where the bug was introduced by
2d076178c ("MINOR: quic-be: Store asap the DCID").

33 hours agoBUG/MINOR: log: preserve NULL bytes of strings with "bin"
Hyeonggeun Oh [Sat, 28 Nov 2026 10:40:43 +0000 (10:40 +0000)]
BUG/MINOR: log: preserve NULL bytes of strings with "bin"

This fixes issue #3489: when forwarding a received TLV with
set-proxy-v2-tlv-fmt(<id>) "%[fc_pp_tlv(<id>)]", the value is cut at
the first NULL byte. fc_pp_tlv returns a string, and _lf_text_len()
copies strings with strlcpy2(). The "bin" option did not help since it
only applied to binary samples.

With the patch, when "bin" is set, strings are copied according to thier
length, like binary samples. Without "bin", nothing changes. CBOR
encoding is untouched.

Note: lf_text()/lf_rawtext() used to pass the remaining buffer size as
the length of NUL-terminated fields (relying on strlcpy2() to stop).
With "bin" they now pass strnlen(src, size), otherwise "%{+bin}o%f"
would read past the end of the string (caught with ASAN on an earlier
version of this patch).

Tested on master c2852d5b7: new reg-test plus reg-tests/log pass, full
reg-tests 299 pass / 0 fail (no SSL/Lua build). An earlier version was
also tested with ASAN + SSL/Lua (394 pass / 0 fail).

One open question: since TLV values are binary by nature, should
set-proxy-v2-tlv-fmt enable "bin" by default? I did not do it because
it changes the behavior of existing configurations, but I can send a
follow-up patch if you think it makes sense.

It may be backported to 3.0, where "bin" was introduced.

Signed-off-by: Hyeonggeun Oh <hyeonggeun.oh@plaintexting.com>
33 hours agoBUG/MINOR: deviceatlas: fix free() of an uninitialized cnew in checkinst
William Lallemand [Mon, 30 Nov 2026 10:57:48 +0000 (10:57 +0000)]
BUG/MINOR: deviceatlas: fix free() of an uninitialized cnew in checkinst

Reported by GitHub user brhenc in issue #3597 (a follow-up of the Coverity
report in #2428). In da_haproxy_checkinst(), "cnew" is filled by
da_atlas_compile(), which does not guarantee to write anything back to
the caller-supplied pointer when the compilation fails. The free() on
the error path could then be called on an indeterminate stack value and
crash the process. The fix introduced by d8ff676592 ("fix resource leak
on hot-reload compile failure") is preserved since free(NULL) is a no-op
if the library leaves the output untouched.

This must be backported to 3.4, 3.3, 3.2, 3.1 and 3.0, which all received
d8ff676592.

34 hours agoBUG/MINOR: mux-quic: fix crash with double qcc_set_error() on QCS free quic-interop
Amaury Denoyelle [Fri, 27 Nov 2026 16:14:38 +0000 (17:14 +0100)]
BUG/MINOR: mux-quic: fix crash with double qcc_set_error() on QCS free

The following patch adjusts connection flow-control when a QCS is
released early with unconsumed data. While it is still incomplete in
some situations, it may prevent desync between client and server
flow-control levels.

  9d2af5174bc8b01e3c4b7b7604d75873ff4bc0e3
  BUG/MINOR: mux_quic: account data in conn fctl on early detach

However, this can cause a crash if qcs_destroy() has been called while
the connection is already flagged on error. Indeed, in case of frame
allocation failure in qcc_account_for_conn_fctl(), qcc_set_error() is
called a second time, which is forbidden and enforced by a BUG_ON()
statement.

Fix this by skipping the qcc_account_for_conn_fctl() call if the
connection is already on error. This is also the case if a failure
occurs during qcc_release_remote_stream() as it sometimes also perform
faillible frame allocation. Both fixes are valid as we do not care about
flow-control accounting anymore as the connection will be released soon.

This must be backported up to 2.8.

34 hours agoBUG/MINOR: mux-quic: fix crash on frame alloc failure after glitch error
Amaury Denoyelle [Fri, 27 Nov 2026 15:54:35 +0000 (16:54 +0100)]
BUG/MINOR: mux-quic: fix crash on frame alloc failure after glitch error

App layer rcv_buf callback may report a connection error using
qcc_set_error(). A negative return value must be used to abort remaining
processing in qcc_decode_qcs().

However, this was not the case when the connection was set on error
because of the glitch level counter. Some work is thus still being
executed, most notably the stream and connection flow-control accounting
via qcs_consume(). This is suboptimal as the connection will soon be
released.

Worse, this may cause a crash if a flow-control frame allocation fails,
as qcc_set_error() is called again. This is forbidden and a BUG_ON() is
used to catch it.

Add a check on the new QC_CF_GLITCH flag after rcv_buf(). If set,
qcc_decode_qcs() is interrupted and qcs_consume() is skipped, so that
the connection can be quickly released.

This must be backported up to 3.0. It relies on the following patch.
  a4ae233d42315a77dec78fc573ab606748f9dcaf
  MINOR: mux-quic: add conn flag on glitch error set

34 hours agoMINOR: mux-quic: add conn flag on glitch error set
Amaury Denoyelle [Fri, 27 Nov 2026 16:13:42 +0000 (17:13 +0100)]
MINOR: mux-quic: add conn flag on glitch error set

Define a new connection flag QC_CF_GLITCH. It is set when the connection
has hit its maximum glitch level and an error was reported due to it.

This flag is a subset of QC_CF_ERRL: every connection flagged with
QC_CF_GLITCH is also flagged with QC_CF_ERRL, but not the reverse. The
main purpose of the new flag is to allow finer handling of connection
errors. This is also useful when debugging a connection that is on
error.

4 days agoBUG/MINOR: http-ana: do not store responses to requests with "no-store"
Christopher Faulet [Wed, 21 Oct 2026 09:05:01 +0000 (09:05 +0000)]
BUG/MINOR: http-ana: do not store responses to requests with "no-store"

A request carrying "Cache-Control: no-store" normally prevents its
response from being stored in the cache. But when the response carries
"Cache-Control: public", it is stored anyway and delivered to other
clients, while RFC 9111#5.2.1.5 says that a cache must not store any part
of the request or of its response, whatever the response says. A client
asking for its response not to be stored, for privacy reasons, may thus
see it delivered to others, though the server marked it as public.

http_check_request_for_cacheability() handles "no-store" by clearing
TX_CACHEABLE and TX_CACHE_COOK, but http_check_response_for_cacheability()
sets them again on "public", since this directive may legitimately make
cacheable a response which is not by default.

The request's directive is now remembered in the TX_CACHE_NOSTORE flag
added by the previous patch, and the response is never considered
cacheable when it is set, whatever its own directives.

The reg-test reg-tests/cache/request_nostore.vtc sends a request with
"no-store" receiving a public response, and checks that it was not
stored. It fails without the fix.

The request's "no-store" was handled since commit 0ad8e0dfe ("MINOR: http:
add a function to check request's cache-control header field") in 1.8,
and the response's "public" could always override it. The fix may be
backported to all supported versions, along with the previous commit
("MINOR: http-ana: add a transaction flag for requests forbidding
storage").

4 days agoMINOR: http-ana: add a transaction flag for requests forbidding storage
Christopher Faulet [Wed, 21 Oct 2026 09:04:27 +0000 (09:04 +0000)]
MINOR: http-ana: add a transaction flag for requests forbidding storage

The new TX_CACHE_NOSTORE flag will be set on transactions whose request
carries a "Cache-Control: no-store" directive, which forbids caches from
storing the response (RFC 9111#5.2.1.5). It is needed by the next fix,
since the request's directives are not available anymore when the
response is checked. The flag is also reported by the flags decoding
helper.

This patch is needed by the next fix which may be backported.

4 days agoBUG/MEDIUM: http-ana: do not let "public" cancel directives forbidding storage
Christopher Faulet [Wed, 21 Oct 2026 09:03:58 +0000 (09:03 +0000)]
BUG/MEDIUM: http-ana: do not let "public" cancel directives forbidding storage

A response carrying "Cache-Control: private, public, max-age=60" is
stored in the cache and delivered to all clients, while "private" forbids
a shared cache from storing it (RFC 9111#5.2.2.7). The same happens with
"no-store" or "no-cache" followed by "public", and with "no-cache=
"set-cookie"" followed by "public", where the response may then be stored
with its Set-Cookie header. Contradictory directives are commonly met
when several layers add their own Cache-Control header, for example an
application emitting "private" for a personalized page behind a component
adding "public, max-age=60" to everything. Personalized responses, or
session cookies, of a user are then delivered from the cache to other
users. This requires the server to emit such directives, so the severity
is limited, but the consequence is a cross-user data leak.

http_check_response_for_cacheability() processes the Cache-Control values
in order. "private", "no-cache", "no-store" and "s-maxage=0" clear
TX_CACHEABLE and TX_CACHE_COOK, and "no-cache="set-cookie"" clears
TX_CACHE_COOK, but "public" sets both flags again, so the last one wins.

The directives forbidding storage are now only recorded during the walk,
and applied after it, so that they always prevail over "public", wherever
it is. "public" still makes cacheable a response that was not cacheable
by default, e.g. because of its status code or of an Authorization header
in the request, as permitted by RFC 9111#3.5.

The reg-test reg-tests/cache/public_order.vtc checks "private, public" in
one header and "no-store" followed by "public" in two headers, as well as
"public" alone. It fails without the fix.

This has always been the case, the processing of the directives came
from the legacy code, and was last reworked by commit 40ed97b04
("BUG/MINOR: cache: Manage multiple values in cache-control header
value") in 2.3-dev9. The fix may be backported to all supported versions.

4 days agoBUG/MINOR: http-ana: let s-maxage override a null max-age whatever their order
Christopher Faulet [Wed, 21 Oct 2026 08:47:22 +0000 (08:47 +0000)]
BUG/MINOR: http-ana: let s-maxage override a null max-age whatever their order

A response carrying "Cache-Control: s-maxage=60, max-age=0" is not stored
in the cache, while "Cache-Control: max-age=0, s-maxage=60" is. Both mean
that private caches must not reuse the response while shared caches like
haproxy's may keep it for 60 seconds (RFC 9111#5.2.2.10), and the order
of the directives does not matter. Servers emitting the directives in
the first order, or as two separate Cache-Control headers in this order,
do not get their responses cached, which only affects performance.

http_check_response_for_cacheability() iterates over the Cache-Control
values. A "max-age=0" sets has_null_maxage and an "s-maxage" resets it,
so a "max-age=0" found after the "s-maxage" sets it again and the
response is finally considered as not cacheable.

The s-maxage directive is now recorded in its own variable, and the null
max-age only makes the response non-cacheable in the absence of s-maxage.
Note that "s-maxage=0" is handled earlier and does not count as an
s-maxage here, so it still makes the response non-cacheable.

The reg-test reg-tests/cache/smaxage_override.vtc checks the two orders
and the case of two headers. It fails without the fix.

This was introduced by commit ca4fd7393 ("BUG/MINOR: cache: A 'max-age=0'
cache-control directive can be overriden by a s-maxage") in 2.9-dev2
which only handled the first order, so the fix may be backported to 3.0.

4 days agoBUILD: compression: silence clang's -Wunused-but-set-global on comp_res_ring
Christopher Faulet [Fri, 27 Nov 2026 14:45:19 +0000 (15:45 +0100)]
BUILD: compression: silence clang's -Wunused-but-set-global on comp_res_ring

'comp_res_ring' is only read when haproxy is built with SLZ, but it is
unconditionally set by the 'tune.comp.res.ring' parser, so with a zlib-only
or compression-less build, clang 23 reports:

  src/compression.c:334:12: error: variable 'comp_res_ring' set but not used
                        [-Werror,-Wunused-but-set-global]

This is caught by the Fedora rawhide CI (clang 23) which builds with
USE_ZLIB=1. It is not reproducible with older clang releases which do
not implement -Wunused-but-set-global.

Mark the variable __maybe_unused like other variables only used
conditionally. This does not change the behavior: the keyword remains
accepted and ignored on non-SLZ builds.

This should fix the issue #3609.

4 days agoMINOR: ssl: warn at startup when SSLKEYLOGFILE is set
William Lallemand [Fri, 27 Nov 2026 14:36:54 +0000 (14:36 +0000)]
MINOR: ssl: warn at startup when SSLKEYLOGFILE is set

A non-empty SSLKEYLOGFILE environment variable can make OpenSSL write
TLS secrets directly to the filesystem, outside HAProxy logging. This
is unsupported, degrades performance and leaks file descriptors across
master-worker reloads.

Warn during configuration pre-checks and recommend tune.ssl.keylog on.
Emit a separate warning about the descriptor leak in master-worker mode.
Skip the master to avoid duplicate warnings, and leave the environment
unchanged. Empty and unset values do not trigger either warning.

Verified configuration checks, setenv/unsetenv handling, zero-warning
rejection, and successful TLS requests before and after a master-worker
reload.

No backport is required for this new startup diagnostic; the separate
documentation update is intended for all stable branches.

4 days agoDOC: configuration: warn against using SSLKEYLOGFILE
William Lallemand [Fri, 27 Nov 2026 14:36:48 +0000 (14:36 +0000)]
DOC: configuration: warn against using SSLKEYLOGFILE

OpenSSL builds with native SSLKEYLOGFILE support can write TLS secrets
directly to a file. This bypasses HAProxy logging, causes filesystem
access in the traffic path and degrades performance. In master-worker
mode, the keylog file descriptor also leaks across reloads.

Document that this environment variable is unsupported and direct users
to tune.ssl.keylog and the existing sample fetches instead.

This documentation update must be backported to all stable branches.

4 days agoBUG/MINOR: stick-table: don't deinit the buckets of a never initialized table
Bruno Henc [Thu, 5 Nov 2026 06:28:06 +0000 (07:28 +0100)]
BUG/MINOR: stick-table: don't deinit the buckets of a never initialized table

stktable_init() is skipped for the table of a disabled proxy, so its
buckets' in_bucket_toadd lists are never initialized. stktable_deinit()
still calls MT_LIST_DELETE() on them when the proxy is freed, and
mt_list_delete() dereferences their NULL pointers. As a result, a config
with a disabled backend declaring a stick-table segfaults at the end of
"haproxy -c" (exit 139) and on every graceful stop, so on every reload.

Only walk the buckets once the table was initialized, which t->pool
tells. The rest of the function is already safe on a never initialized
table.

This was introduced with the per-bucket expiration tasks in commit
8bc8a21b2 ("MEDIUM: stick-tables: Use a per-shard expiration task"),
3.3-dev11, so it must be backported to 3.3.

It should fix the issue #3581.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4 days agoBUG/MINOR: connection: don't use the cached ALPN if SSL_NO_CACHED_INFO
Olivier Houchard [Fri, 27 Nov 2026 13:12:13 +0000 (14:12 +0100)]
BUG/MINOR: connection: don't use the cached ALPN if SSL_NO_CACHED_INFO

conn_select_mux_be() and conn_install_mux_be() fall back to the ALPN
cached in the server when the connection has none, even when the
connection has CO_FL_SSL_NO_CACHED_INFO. A websocket connection that
only offers http/1.1 to a server which then selects no ALPN gets an H2
mux if the regular connections negotiated h2, and the request ends in a
502.

Let's not use the cache for those connections. This should help with
github issue #3473, and must be backported to 3.3.

4 days agoBUG/MEDIUM: connection: use the websocket mux after the handshake too
Olivier Houchard [Fri, 27 Nov 2026 13:12:13 +0000 (14:12 +0100)]
BUG/MEDIUM: connection: use the websocket mux after the handshake too

When the mux is created after the handshake, conn_create_mux() ignores
the "ws" setting of the server and uses its "proto". With a server using
"ssl alpn h2 proto h2 ws h1", a websocket connection gets its ALPN forced
to http/1.1, then an H2 mux, and every websocket request ends in a 502.

Let's give the websocket mux to conn_install_mux_be() there too, as
connect_server() does. This is a regression from commit a0db93f3d
("MEDIUM: backend: delay MUX init with ALPN even if proto is forced") in
3.3-dev2, and it happens for every websocket since commit 73ce20faa
("BUG/MEDIUM: server: Don't use the cached ALPN for websocket"). This
configuration was suggested as a workaround in github issue #3473.

This must be backported to 3.3.

4 days agoBUG/MEDIUM: backend: read the cached ALPN only once in connect_server()
Olivier Houchard [Thu, 26 Nov 2026 17:52:41 +0000 (18:52 +0100)]
BUG/MEDIUM: backend: read the cached ALPN only once in connect_server()

When connect_server() wants to start the mux before the handshake, it
checks under the path parameters lock that an ALPN is cached for this
connection's hash, but the mux is then chosen by conn_install_mux_be(),
which reads the cache again, without the lock. If another thread
completed a handshake for a different hash in between, the hash no
longer matches, no ALPN is found and the default mux, H1, is installed.
Once the handshake negotiates H2, the request is sent in H1 to an H2
server, and the client receives a 502.

Let's copy the cached ALPN while holding the lock, pick the mux from
that copy, and give it to conn_install_mux_be(). This is a regression
from commit de3f245df ("BUG/MEDIUM: servers: Store the connection hash
with the parameter cache") in 3.4-dev13. It can be reproduced with a
server using "ssl alpn h2,http/1.1 allow-0rtt", several threads, and
requests using a few different Host header values.

This should help with github issue #3473, and must be backported to 3.3.

4 days agoBUG/MEDIUM: backend: only start the mux early when 0-RTT may be used
Olivier Houchard [Thu, 26 Nov 2026 17:51:47 +0000 (18:51 +0100)]
BUG/MEDIUM: backend: only start the mux early when 0-RTT may be used

Since commit d4c51a4f5 ("MEDIUM: server: Make use of the stored ALPN
stored in the server"), the mux is installed before the handshake, from
the cached ALPN, for every SSL server with an ALPN, while this is only
needed to send early data. If the handshake then negotiates another
protocol, the wrong mux stays in place and the request ends in a 502.

Let's only do it for servers with "allow-0rtt". This should help with
github issue #3473, and must be backported to 3.3.

4 days agoMINOR: http-ana: remove the HTX defrag when waiting for a message payload
Christopher Faulet [Thu, 26 Nov 2026 19:36:22 +0000 (20:36 +0100)]
MINOR: http-ana: remove the HTX defrag when waiting for a message payload

When http_wait_for_msg_body() was introduced, an HTX defragmentation was
performed on any fragmented or unordered message, hoping it would ease the
payload analysis afterwards. In fact, this defrag is useless because the
same condition is already handled by sc_conn_recv() and sc_applet_recv(),
which defragment the HTX message on every receive when the buffer is
stuck and the message is fragmented or its free space wraps. Thus, while
we are waiting for the payload, the message is defragmented as soon as
new data arrive.

In addition, since the previous commit, the sample fetches retrieving the
body from an HTX message now defrag it themselves if needed. So there is
no consumer left relying on the message being defragmented when the wait
ends.

This defrag was introduced in 3.4 with the commit f559c202f ("MINOR:
http-ana: Do a defrag on unaligned HTX message when waiting for payload").
Given its speculative nature, it does not need to be backported.

4 days agoBUG/MINOR: http-fetch: only defrag HTX message with payload when fetching body
Christopher Faulet [Thu, 26 Nov 2026 19:36:17 +0000 (20:36 +0100)]
BUG/MINOR: http-fetch: only defrag HTX message with payload when fetching body

In smp_fetch_body() and smp_fetch_body_param(), the defragmentation was
performed as soon as the HTX message was fragmented or unordered, or when
its free space was wrapping, without checking if the message had a payload.
In practice, it means a full HTX defragmentation was done for any bodyless
request or response when the HTX message was fragmented, which may happen
for instance after a header removal.

Now, the defragmentation is only performed if the message contains payload,
i.e. if the tail block type is higher than or equal to HTX_BLK_DATA. It is
not a strict check, but it is a cheap one, and messages with a single DATA
block never require a defragmentation anyway, since a single DATA block is
always contiguous.

This bug was introduced in 3.4 with the commit ee309bafc ("MINOR:
http-fetch: Use pointer to HTX DATA block when retrieving HTX body"). It
must be backported as far as 3.4.

5 days agoBUG/MEDIUM: ssl: prevent CN fallback when a SAN extension is present
William Lallemand [Thu, 26 Nov 2026 17:48:04 +0000 (17:48 +0000)]
BUG/MEDIUM: ssl: prevent CN fallback when a SAN extension is present

Yang Hailong of Alipay Security Team reported that backend hostname
verification accepts a certificate with a URI-only SAN and a matching
subject CN. The fallback was disabled only after encountering a DNS SAN,
so certificates containing other SAN types could still match their CN.

Use the status returned by X509_get_ext_d2i() to allow CN fallback only
when the SAN extension is absent. Present but undecodable or duplicate
SAN extensions do not permit fallback either.

RFC 9525 obsoletes RFC 6125 and prohibits using the subject Common Name
to identify a service. This change does not fully implement that policy:
CN fallback is retained for certificates without a SAN extension to
preserve compatibility with legacy deployments.

This intentionally tightens certificate acceptance: non-DNS SANs now
suppress CN matching, while certificates without SAN retain CN fallback.

Verified with the existing verifyhost regression and live backend TLS
checks covering URI-only SAN rejection, mixed URI/DNS SAN acceptance,
and CN-only compatibility, using both verifyhost and SNI.

This change must not be backported because it changes certificate
acceptance and could break existing deployments on stable branches.

Reported-by: Yang Hailong
5 days agoBUG/MINOR: ocsp: Increment certificate_ocsp refcount in 'ssl_sock_copy_cert_key_and_c...
Remi Tricot-Le Breton [Thu, 26 Nov 2026 14:38:59 +0000 (15:38 +0100)]
BUG/MINOR: ocsp: Increment certificate_ocsp refcount in 'ssl_sock_copy_cert_key_and_chain'

ssl_sock_copy_cert_key_and_chain() duplicates a ckch_data and duplicates
its ocsp_cid via OCSP_CERTID_dup(). Since the response tree is keyed on
the OCSP_CERTID itself, the copy points to the very same
certificate_ocsp entry as the original ckch_data, but no additional
reference was taken on it.

This was an issue because ssl_sock_free_cert_key_and_chain_contents
unconditionally decrements this certificate_ocsp's refcount_store while
the matching increment was only performed in ssl_sock_load_ocsp(),

If a duplicated ckch_data is freed (an aborted "set ssl cert"
transaction for instance) while the original ckch_store is still alive,
refcount_store can fall to 0 and the shared certificate_ocsp entry be
freed, leaving the original ckch_store with a dangling pointer. The next
OCSP response lookup or update would then use freed memory.

This was reported by brhenc in GitHub issue #3591.

This patch should be backported up to 2.8.

5 days agoBUG/MINOR: jwe: check that the EC point is on the curve
Gihyeon Ryu [Thu, 26 Nov 2026 14:38:58 +0000 (15:38 +0100)]
BUG/MINOR: jwe: check that the EC point is on the curve

EC_POINT_set_affine_coordinates() returns 0 when the point is not on the
curve, but curve_param_to_pubkey() only treats a negative value as an
error, as do the two tests of the OpenSSL 1.1.1 branch. An off-curve
ECDH-ES "epk" is then rejected later by OpenSSL itself in the tested
version (3.0), so no impact was found, but the check should not rely on
it. The three tests now require a return value of 1.

This may be backported up to 3.4.

5 days agoBUG/MEDIUM: mux-h2: don't block other streams while waiting for a tunnel
Olivier Houchard [Thu, 26 Nov 2026 14:22:08 +0000 (15:22 +0100)]
BUG/MEDIUM: mux-h2: don't block other streams while waiting for a tunnel

On the backend side, a stream with data to send for a CONNECT before the
server's response is blocked with H2_SF_BLK_MBUSY but stays in the
send_list, and h2_snd_buf() and h2_nego_ff() make the other streams wait
as long as this list is not empty. So all the other streams of the
connection, possibly from other clients with "http-reuse always", are
blocked until the server responds. It can be reproduced with a CONNECT
followed by a DATA frame sent to a server which delays its response, and
a GET on the same backend connection.

The send_list is only for streams which are ready to write. Let's use a
dedicated flag, H2_SF_WAIT_TUNNEL, not part of H2_SF_BLK_ANY, for which
the stream leaves the send_list and is only added back once the tunnel
is established or aborted. This was introduced in 2.4 by commit
f95f87650 ("MEDIUM: mux-h2: Block client data on server side waiting
tunnel establishment"), and must be backported to all supported
versions.

5 days agoDEV: sslkeylogger: mark it as a debugging tool only
Amaury Denoyelle [Thu, 26 Nov 2026 14:32:03 +0000 (15:32 +0100)]
DEV: sslkeylogger: mark it as a debugging tool only

Add a comment to mark sslkeylogger as a debugging tool only. Its usage
in production must be avoided, as Lua access to filesystem on haproxy
runtime is a bad idea which can hurt haproxy traffic handling
performances.

5 days agoCLEANUP: mux_quic: fix indentation in rcv_buf
Amaury Denoyelle [Thu, 26 Nov 2026 10:23:20 +0000 (11:23 +0100)]
CLEANUP: mux_quic: fix indentation in rcv_buf

Recently added code was badly indented as spaces were used. Adjust the
code to use tabs for alignment.

5 days agoBUG/MAJOR: h3: prevent demux full BUG_ON() crash with incomplete DATA
Amaury Denoyelle [Thu, 26 Nov 2026 10:06:00 +0000 (11:06 +0100)]
BUG/MAJOR: h3: prevent demux full BUG_ON() crash with incomplete DATA

Function h3_data_to_htx() transcodes a DATA frame into HTX content. If a
truncated frame is received, content is reduced to the data available in
the buffer. However, the code is murky when only the frame header has
been received but its payload is truncated. Content is set to 0 but the
whole function still executes, which is suboptimal.

Worse, this becomes a major issue if QC_SF_DEM_FULL is set in the same
function call. This violates the invariant on this flag, which must only
be set when there is data to read. This triggers a BUG_ON() crash in
rcv_buf callback, which exists to detect unnecessary wakeups.

This is fixed by adjusting h3_data_to_htx() so that it returns early
when no content is available, preventing unnecessary instructions from
being executed. Most importantly, the HTX output buffer is not checked
anymore so the QC_SF_DEM_FULL flag is not set.

This issue is present since the following patch. Prior to it, empty DATA
frames were totally ignored, but this could prevent FIN reporting, hence
its purpose.

  6c706c1a758b1e8bcdfe0816535edbd5c624db80
  BUG/MEDIUM: h3: do not block FIN on empty DATA frame

Thanks to AndyAnh174 for reporting this issue.

This must be backported up to 2.6.

5 days agoRevert "BUG/MINOR: jwt: Create jwt tree entry even for new empty certificates"
William Lallemand [Thu, 26 Nov 2026 13:33:46 +0000 (14:33 +0100)]
Revert "BUG/MINOR: jwt: Create jwt tree entry even for new empty certificates"

This reverts commit e0783e24263c1bd3ea15837039e4c8b37cabaecf.

Applied the patch twice by accident.

5 days agoBUG/MINOR: jwt: Create jwt tree entry even for new empty certificates
Remi Tricot-Le Breton [Thu, 26 Nov 2026 10:11:53 +0000 (11:11 +0100)]
BUG/MINOR: jwt: Create jwt tree entry even for new empty certificates

A new empty certificate created by calling "new ssl cert" directly
followed by "commit ssl cert" would not have a corresponding JWT tree
entry created since only the data-loading code paths were covered in the
previous jwt tree related commits.
With this patch we always have a corresponding jwt tree entry for every
ckch_store.

This patch can be backported to 3.4.

5 days agoBUG/MINOR: jwt: Do not keep ckch_store if jwt tree entry creation failed
Remi Tricot-Le Breton [Thu, 26 Nov 2026 10:11:54 +0000 (11:11 +0100)]
BUG/MINOR: jwt: Do not keep ckch_store if jwt tree entry creation failed

When a full certificate is provided directly as a second argument of the
"jwt_verify_cert" converter, we create the corresponding ckch_store and
insert it in the ckch_store tree so that it's treated as a regular
certificate. This helps in certificate management since that way the
certificate can be updated via the CLI.
With the latest changes in the JWT tree, we now always have a
corresponding JWT tree entry for every ckch_store, regardless of whether
they set the jwt flag or not. And in every other part of the ckch_store
building process apart the one modified in this patch, we were raising
an error and removing the new ckch_store if an error occurred during the
corresponding JWT tree entry creation.
This patch keeps this logic in the 'jwt_tree_load_cert' function as
well.

This patch can be backported to 3.4.

5 days agoBUG/MEDIUM: jwt: Add refcount to jwt tree entry
Remi Tricot-Le Breton [Thu, 26 Nov 2026 10:11:55 +0000 (11:11 +0100)]
BUG/MEDIUM: jwt: Add refcount to jwt tree entry

During the certificate update process via CLI commands, when calling
'ckch_store_replace', we were removing the previous ckch_store before
recreating a jwt tree entry and inserting the new ckch_store. During the
short time frame between the 'ckch_store_free' and the
'jwt_tree_create_entry_from_store' call we had no corresponding entry in
the jwt tree so a 'jwt_verify' call at this exact moment would fail.

Instead of rethinking the whole tree logic, a reference counter was
added to tree entry so that we can update the JWT tree entry with the
new ckch_store data (pubkey/privkey), increase the reference counter so
that the ckch_store_free call on the old ckch_store does not fully
remove the JWT tree entry.

This patch should be backported to 3.4.

5 days agoBUG/MINOR: jwt: Create jwt tree entry even for new empty certificates
Remi Tricot-Le Breton [Thu, 26 Nov 2026 10:11:53 +0000 (11:11 +0100)]
BUG/MINOR: jwt: Create jwt tree entry even for new empty certificates

A new empty certificate created by calling "new ssl cert" directly
followed by "commit ssl cert" would not have a corresponding JWT tree
entry created since only the data-loading code paths were covered in the
previous jwt tree related commits.
With this patch we always have a corresponding jwt tree entry for every
ckch_store.

This patch can be backported to 3.4.

5 days agoDOC: security: a few more clarifications on report processing
Willy Tarreau [Thu, 26 Nov 2026 10:59:49 +0000 (11:59 +0100)]
DOC: security: a few more clarifications on report processing

Let's clarify that only complete reports are considered and the
other ones are ignored. Also a single report first.

5 days agoMEDIUM: http: reject percent-encoded chars in the authority and Host
Christopher Faulet [Tue, 24 Nov 2026 14:21:04 +0000 (15:21 +0100)]
MEDIUM: http: reject percent-encoded chars in the authority and Host

While RFC3986 permits percent-encoded characters in the authority for a
general usage, it is safer to reject them in HTTP because it could be used
to abuse ACLs based on the host header value. In fact, because it could be
used as a vector of attacks, it seems commonly rejected/not-supported by
servers. So it is safer to do so.

The http_authority_has_forbidden_char() function already rejects a list of
ambiguous characters in the authority and the Host header value for H1, H2
and H3, so percent ('%') is simply added to this list, covering all three
protocol versions at once.

This patch must not be backported.

5 days agoBUG/MEDIUM: http-htx: normalize Host header carrying the scheme's default port
Christopher Faulet [Tue, 24 Nov 2026 10:19:45 +0000 (11:19 +0100)]
BUG/MEDIUM: http-htx: normalize Host header carrying the scheme's default port

An HTTP/1 absolute-form request-target whose authority carries no port may
be sent with a Host header value carrying the scheme's default port (or an
empty one). h1_validate_mismatch_authority() deliberately accepts both
spellings as equivalent, but http_scheme_based_normalize() only removed the
port when it was found in the URI authority, so the raw ":443" remained in
the Host header value.

As a result the ACLs, the routing rules and the cache key were evaluated on
different values and this could be confusing.

Now the Host header value is also normalized when it carries the scheme's
default port and matches the authority, so the analyser, the rules, the
cache and the forwarded request all see the same canonical host value.

Thanks to Christos Papakonstantinou for the report.

This patch could be backported to stable versions. But it could be good to
wait for a period of observation first.

5 days ago[RELEASE] Released version 3.5-dev14 v3.5-dev14
Willy Tarreau [Wed, 25 Nov 2026 20:54:46 +0000 (21:54 +0100)]
[RELEASE] Released version 3.5-dev14

Released version 3.5-dev14 with the following main changes :
    - BUG/MINOR: mux-quic: fix QMux Rx buffer leak on MUX init failure
    - BUG/MEDIUM: quic: never advertise more streams than configured
    - BUG/MEDIUM: mux-quic: cap elastic MAX_STREAMS to stream.max-total
    - MINOR: reg-tests: add --extra to run tests needing optional tools
    - REGTESTS: quic: add a Python QUIC client
    - REGTESTS: quic: backend must drop packets with an unsupported version
    - REGTESTS: quic: NEW_CONNECTION_ID must not reference a retired CID
    - REGTESTS: quic: undecryptable 0-RTT packets must not exhaust the Rx buffer
    - BUG/MEDIUM: payload: reject out-of-range payload and payload_lv arguments
    - BUG/MINOR: payload: also encode an absolute payload_lv offset2
    - BUG/MINOR: sample: do not parse compressed gRPC messages in ungrpc
    - REGTESTS: protobuf: cover the gRPC message compression flag
    - DOC: config: ungrpc does not support compressed messages
    - BUG/MEDIUM: http-ana: restore the purge of backend analyzers on applets
    - BUG/MINOR: quic: do not reject CRYPTO data exactly fitting in buffer
    - CLEANUP/MINOR: ncbuf: avoid noop memcpy when data ends on wrapping
    - CLEANUP/MINOR: ncbmbuf: avoid noop memcpy when data ends on wrapping
    - BUG/MINOR: ncbuf/test: remove list dependency for standalone tests
    - BUG/MINOR: ncbuf/test: remove unnecessary delay in random insert
    - MINOR: ncbuf/test: extract random insert test in a dedicated function
    - MINOR: ncbuf/test: define max iteration to random insert test
    - MINOR: ncbuf/test: define seed for random insert test
    - BUG/MEDIUM: hlua: make coroutine.create() safe under haproxy (new attempt)
    - MINOR: hlua: add our own safe coroutine.wrap() wrapper
    - BUG/MINOR: hlua: wait for the request in HTTP applets
    - BUG/MINOR: hlua: reject interim responses in HTTP applets
    - BUG/MINOR: h3: reject interim responses ending the stream
    - BUG/MEDIUM: quic: refuse handshakes completed after the listener unbind
    - BUG/MEDIUM: quic: do not spin on the accept tasklet of a blocked listener
    - BUG/MEDIUM: xprt_qmux: apply the configured bidi streams limit on FE
    - BUG/MEDIUM: log/tools: fix cbor binary integer encoding regression with x86_64 systems
    - MINOR: jwt: Add rwlock to jwt_cert_tree
    - BUG/MEDIUM: jwt: Use only JWT cert tree for jwt_verify
    - BUG/MEDIUM: jwt: Use JWT cert tree for jwt_decrypt
    - BUG/MINOR: ech: keep CLI success messages alive until printed
    - BUG/MINOR: ssl/cli: use the right list member in "add ssl crt-list" release
    - MINOR: ssl: allow prefix lookup for alpn_remove_token()
    - MINOR: ssl/quic: mark hq-interop QUIC ALPN as experimental
    - BUG/MINOR: httpclient/cli: fix NULL dereference when the response has no header
    - BUG/MINOR: ocsp: fix NULL dereference when the OCSP responder sends no header
    - BUG/MINOR: net_helper: check the TCP option length before reading its value
    - BUG/MINOR: net_helper: accept an Ethernet header ending with the protocol
    - BUG/MINOR: resolvers: reject DNS messages without the QR bit
    - BUG/MINOR: intops: reject varints that do not fit in 64 bits in decode_varint()
    - BUG/MINOR: mux-spop: match the AGENT-HELLO and AGENT-DISCONNECT keys exactly
    - BUG/MINOR: mqtt: reject invalid CONNECT flags and MQTT 3.1.1 CONNACK return codes
    - BUG/MINOR: mux-h2: reject non-numeric values in the tune.h2 keywords
    - MINOR: tools: add some of the missing null-terminated integer parsers
    - REORG: tools/intops: move the integer-specific functions from tools to intops
    - REORG: tools/intops: move the int-to-str conversion functions to intops as well
    - CLEANUP: tree-wide: remove unneeded dependencies on tools.h
    - BUG/MEDIUM: stick-tables: update the bucket's next_exp before releasing its lock
    - REGTEST: spoe: fix the SPOP varint encoding in the mock agent
    - REGTEST: spoe: add large-frame tests for the applet and the mux
    - BUG/MINOR: tcpcheck: fix out-of-bounds reads on truncated LDAP bind responses
    - BUG/MINOR: tcpcheck: fix out-of-bounds reads on truncated SPOP hello frames
    - MINOR: jwt: New jwt_verify_secret converter
    - MINOR: jwt: Deprecate jwt_verify converter
    - CLEANUP: mux-h2: get rid of the redundant h2_parse_int() function
    - MINOR: init: automatically turn "set-dumpable" on when using "-d"
    - MINOR: http: use fuzzy-match for the "return" action keywords
    - BUG/MEDIUM: mux-h2: don't stall on a failed rxbuf alloc without stream
    - BUG/MEDIUM: mux-fcgi: let the buffer callback allocate despite the queue
    - BUG/MEDIUM: mux-spop: let the buffer callback allocate despite the queue
    - BUG/MINOR: tcpcheck: fix out-of-bounds read on the MySQL server version
    - BUG/MINOR: vars: fix missing string termination in get var on too long values
    - BUG/MINOR: lua: channel: append() must insert data at the end, not at the start
    - BUG/MINOR: quic: fix uninitialized read of pkt->rs.delivered in ACK processing (BBR)
    - BUG/MINOR: payload: distcc_body must not sample unreceived buffer bytes
    - MEDIUM: config: emit warnings when changing bufsize after other sections
    - BUG/MEDIUM: pattern: check for non-empty string before matching regexes
    - CLEANUP: pattern: don't even run string-based matches on empty strings
    - REGTESTS: mysql: Close server s6 declaration
    - BUG/MEDIUM: acme: take the resolvers lock when linking/unlinking DNS requesters
    - BUG/MEDIUM: mux-fcgi: avoid out-of-bounds path decoding
    - MINOR: filters: Register a dedicated trace source for the filters
    - MINOR: htx: Add a noop block to carry the EOM flag on an empty message
    - DOC: htx: add the NOOP block to the HTX API documentation
    - BUG/MEDIUM: stconn: Do not install an applet on a busy stream connector
    - BUG/MEDIUM: applets: do not wake up applets before the end of the request analysis
    - BUG/MEDIUM: stconn: Only forward kip hint on streams committed to forward data
    - BUG/MEDIUM: mux-h1: never forward more data than announced in a chunk
    - MEDIUM: stconn: Forward kip hint right before the endpoint callback
    - MINOR: tcpcheck: add TCPCHK_EXPT_FL_ALLOW_EMPTY flag on expect rules
    - MINOR: tcpcheck: evaluate custom expect rules on empty response when allowed
    - MEDIUM: tcpcheck: handle MySQL AuthSwitchRequest in mysql-check post-80 modes
    - DOC: config: update mysql-check doc for the auth switch support
    - REGTESTS: mysql-check: refresh the regtest for the auth switch support
    - CLEANUP: tcpcheck: Stop to export most of custom expect functions
    - BUG/MINOR: qmux: prevent pacing BUG_ON() on send syscall zero return
    - MINOR: server: report incorrect usage of "from" keyword
    - MINOR: server: lookup defaults section on "from srv:"
    - MINOR: server: lookup defaults section on "from be:"
    - BUG/MEDIUM: mux-h2: reject non-101 2xx responses to Extended CONNECT
    - MINOR: mux-quic: remove error trace on transport failure
    - DEV: phash: improve the output to permit an easier copy-paste
    - MINOR: http: Add support for HTTP 411 status code
    - MEDIUM: http_ana: control acceptance of 1xx status on HTTP/1.0
    - MINOR: http_ana: always drop the Expect header in HTTP/1.0
    - MEDIUM: http/hardening: delete untrusted headers/trailers with underscore
    - MEDIUM: http/hardening: default to rejecting untrusted duplicate C-L
    - MEDIUM: http/hardening: reject forbidden payload on 1xx/204 responses
    - MEDIUM: http/hardening: filter out-of-range status codes from untrusted servers
    - MINOR: http: add a new violation rule "trace-with-content" for TRACE methods
    - BUG/MEDIUM: acme: match DNS challenges against all TXT records
    - IMPORT: slz: update slz to v1.4.0 (commit 197db002f1)
    - BUG/MINOR: h1: restrict a bit more the syntax of chunk extensions
    - REGTESTS: http-messaging: test the strict parsing of HTTP/1 chunk extensions
    - REORG: h1: move chunk extensions parsing to a dedicated inline function
    - MEDIUM: h1: make h1_parse_chunk_size() rely on h1_parse_chunk_ext()
    - REGTESTS: http-messaging: also test chunk extensions on chunks larger than the buffer
    - MINOR: tools: add memcpy_opt_small() for ultra-small copies
    - OPTIM: h1: use memcpy_opt_small() to copy chunks in the contiguous parser
    - BUG/MINOR: h3: reject reserved HTTP/2 frame types
    - BUG/MINOR: h3: support unknown frames of any length
    - MINOR: http: add -dH at boot to dump HTTP specific settings
    - BUILD: http: fix missing include in haproxy.c
    - BUG/MEDIUM: startup: revisit the default chroot behavior
    - BUG/MINOR: startup: also disable strict limits with -d
    - MINOR: stream: use regular TRACE_* macros for stream traces
    - BUG/MEDIUM: mux-h1: Don't shortcut h1_process() while a stream is attached
    - DOC: config: Properly align table at begining of 7.5
    - REGTESTS: tcp-check-ssl: tolerate an errno info in the SSL handshake failure
    - REGTESTS: tcp-check-ssl: also support errno reporting on second test
    - BUG/MINOR: h3: extend coverage for duplicate SETTINGS ids
    - BUG/MEDIUM: acme: distinguish wildcard CLI and Lua acknowledgements
    - BUG/MEDIUM: lua: handle apex and wildcard challenges in Gandi example
    - DOC: lua: document wildcard ACME authorization readiness
    - DOC: management: document ACME challenge readiness acknowledgements
    - EXAMPLES: acme: add a Lua Gandi DNS-01 configuration
    - BUG/MINOR: ssl: append OCSP base64 newline to the output buffer
    - BUG/MINOR: mux-h1: properly handle NOOP blocks and track EOM emission
    - MINOR: tools: add read_line_to_mem() to read a line into a growing buffer
    - BUG/MINOR: pattern: don't rely on the trash size to read pattern files
    - BUG/MINOR: pattern: do not index too large strings using the tree
    - BUG/MEDIUM: ssl: trim dropped kTLS records from the end of the buffer
    - BUG/MEDIUM: rawsock: don't take a short kTLS read for the end of data
    - BUG/MINOR: resolvers: display the template name instead of "server '(null)'"
    - MEDIUM: server: add a global setting "unresolvable-server-fqdn"
    - BUG/MEDIUM: mjson: stop the lookup when the matched element ends
    - BUG/MEDIUM: mjson: decode the escaped slash in strings
    - DOC: config: mention the nesting limit of the json_query() converter
    - BUG/MEDIUM: ssl/cli: reset the transaction on interrupted CA/CRL commits
    - CI: github: enable slow regression tests for OpenSSL master
    - BUG/MEDIUM: ssl/cli: restore the store conf on "add ssl crt-list" error
    - BUG/MINOR: ssl/ckch: copy the origin of the conf in ckchs_dup()
    - BUG/MEDIUM: ssl/cli: keep the crt-store conf on "add ssl crt-list"
    - BUG/MINOR: ssl/cli: don't clear the jwt flag on "add ssl crt-list"
    - BUG/MINOR: ssl/cli: fix ckch_conf leaks in "add ssl crt-list"
    - BUG/MINOR: cache: free the blocks of aborted stores at once
    - BUG/MEDIUM: cache: build the secondary key on an unusable first entry
    - MINOR: github: disable blank issues
    - MINOR: github: add documentation suggestion template
    - MINOR: http/hardening: implement "reject-advanced-methods"
    - REGTESTS: http-messaging: test reject-advanced-methods
    - MINOR: http/hardening: implement "reject-unexpected-request-payload"
    - REGTESTS: http-messaging: test reject-unexpected-request-payload
    - MINOR: http/hardening: implement "reject-unexpected-request-upgrade"
    - REGTESTS: http-messaging: test reject-unexpected-request-upgrade
    - MINOR: http/hardening: add a new more protective "basic-web" profile
    - REGTESTS: http-messaging: test the "basic-web" profile in http_hardening_profiles

6 days agoREGTESTS: http-messaging: test the "basic-web" profile in http_hardening_profiles
Willy Tarreau [Wed, 25 Nov 2026 18:07:51 +0000 (18:07 +0000)]
REGTESTS: http-messaging: test the "basic-web" profile in http_hardening_profiles

The implicit "basic-web" profile is now verified: its default settings
are displayed, it may be used on a bind line without being declared
(deleting unregistered and underscored headers, and rejecting TRACE and
GET with a body), and it may serve as a source for "from". The expected
listing of the "untrusted" profile was completed with the three new
checks, which are off there.

6 days agoMINOR: http/hardening: add a new more protective "basic-web" profile
Willy Tarreau [Wed, 25 Nov 2026 17:32:57 +0000 (18:32 +0100)]
MINOR: http/hardening: add a new more protective "basic-web" profile

This profile enables all the protections that are sufficient for basic
web serving to browsers, i.e. no payload with methods not meant to
support one, no tunnels, no unknown upgrade tokens, no transfer-encoding
in requests, no unregistered headers, no trailers. It should be sufficient
for the vast majority of web sites and can trivially be enabled like this
on public-facing connections:

    http-hardening untrusted from basic-web

http_hardening_profiles.vtc was updated accordingly since "basic-web" now
appears in the "show http-hardening" listings, as implicit when not
declared.

6 days agoREGTESTS: http-messaging: test reject-unexpected-request-upgrade
Willy Tarreau [Wed, 25 Nov 2026 18:07:51 +0000 (18:07 +0000)]
REGTESTS: http-messaging: test reject-unexpected-request-upgrade

This adds the "reject-unexpected-request-upgrade" check to the HTTP/1
and H2 tests, in its own profile on its own bind line, and an upgrade
to an unknown protocol to the reference connection which has everything
off. Only "websocket" and "webtransport" are kept in the Upgrade header,
which is removed along with "connection: upgrade" once empty, and the
request is not rejected. The frontend now also reports the Upgrade
header in "x-upg". For H2, this is done via extended CONNECT, which is
accepted for "websocket" and "webtransport" and rejected for other
protocols. For websocket, the server is a frontend of the same instance
which computes the Sec-WebSocket-Accept header that haproxy verifies,
as done in websocket.vtc.

6 days agoMINOR: http/hardening: implement "reject-unexpected-request-upgrade"
Willy Tarreau [Wed, 25 Nov 2026 17:12:49 +0000 (18:12 +0100)]
MINOR: http/hardening: implement "reject-unexpected-request-upgrade"

Rejects Upgrade and RFC8441 Extended CONNECT for protocols other than
"websocket" and "webtransport". For Upgrade, all offending tokens are
removed and the header will be removed if empty, so that it remains
harmless to clients sending tentative upgrades. Upgrade and CONNECT are
commonly abused to try to establish a tunnel with an application and
bypass the reverse-proxy layer, and most applications and browsers do
not implement other protocols, so there is no reason for letting them
pass through with common web applications. It is generally safe for
static web serving and simple internet-facing applications. This is
disabled by default. Note that tunnels established via standard CONNECT
are NOT blocked with this rule, see 'reject-advanced-methods' for this.

6 days agoREGTESTS: http-messaging: test reject-unexpected-request-payload
Willy Tarreau [Wed, 25 Nov 2026 18:07:51 +0000 (18:07 +0000)]
REGTESTS: http-messaging: test reject-unexpected-request-payload

This adds the "reject-unexpected-request-payload" check to the HTTP/1
and H2 tests, in its own profile on its own bind line, and a GET with a
body and a chunked POST to the reference connection which has everything
off. A payload is accepted with POST, PUT and PATCH, an empty one with
GET, but a non-empty one gets a 400 or STREAM_ERROR with GET, HEAD,
DELETE, OPTIONS and TRACE, as does any chunked request.

6 days agoMINOR: http/hardening: implement "reject-unexpected-request-payload"
Willy Tarreau [Wed, 25 Nov 2026 16:30:26 +0000 (17:30 +0100)]
MINOR: http/hardening: implement "reject-unexpected-request-payload"

Rejects requests which contain a payload on methods which have no
defined semantics with it (HEAD, GET, DELETE, OPTIONS, CONNECT, TRACE),
as well as any HTTP/1.1 request using the chunked Transfer-Encoding.
This protects backend servers having imperfect implementation against a
wide list of attacks that try to abuse their limited parsing to bypass
their inspection or desynchronize them with haproxy. The vast majority
of applications aimed at browsers will not experience any issue with
this setting, but some in-house or proprietary components might rely on
passing a payload to some of these methods, or uploading streamed data
using Transfer-Encoding. Note that other methods are assumed to support
payloads, and unknown methods might be handled similarly to GET by some
servers. As such, when using this to protect an application, it is wise
to also use 'reject-advanced-methods'. This is generally safe for
static web serving and simple internet-facing applications. It is
disabled by default.

http_hardening_report.vtc was updated accordingly since the new flag
appears (0x20000).

6 days agoREGTESTS: http-messaging: test reject-advanced-methods
Willy Tarreau [Wed, 25 Nov 2026 18:07:51 +0000 (18:07 +0000)]
REGTESTS: http-messaging: test reject-advanced-methods

This adds the "reject-advanced-methods" check to the HTTP/1 and H2 test, in
its own profile on its own bind line, and TRACE and an unknown method to the
reference connection which has everything off. Only GET, HEAD, POST, PUT,
DELETE, OPTIONS, PATCH and QUERY are accepted, while TRACE, CONNECT (there
is no extended CONNECT in HTTP/1), unknown methods and methods differing
from PATCH or QUERY by their length get a 405 or a stream error.

6 days agoMINOR: http/hardening: implement "reject-advanced-methods"
Willy Tarreau [Wed, 25 Nov 2026 15:59:49 +0000 (16:59 +0100)]
MINOR: http/hardening: implement "reject-advanced-methods"

Rejects requests whose method is not one of: HEAD, GET, POST, PUT,
DELETE, OPTIONS, PATCH, QUERY, or extended CONNECT (RFC8441). This
is amply sufficient for the vast majority of regular web sites and
applications accessed by browsers, but may not always be compatible
with API aimed at being joined directly by other applications. This can
block by default a significant number of backend vulnerabilities that
are not yet discovered and that are only triggered by less common
methods. Use only after verifying applications compatibility, though
this is safe for static web serving and simple internet-facing
applications. It is disabled by default.

http_hardening_profiles.vtc was updated accordingly: its "base" profile is
built with "all on", which now also rejects the "get" method used there
to check "reject-lowercase-method", so the new check is turned off there.

6 days agoMINOR: github: add documentation suggestion template
William Lallemand [Wed, 25 Nov 2026 18:21:17 +0000 (18:21 +0000)]
MINOR: github: add documentation suggestion template

Add a Doc suggestions issue form with a single required text area for
documentation suggestions. Apply the type: doc label automatically.

6 days agoMINOR: github: disable blank issues
William Lallemand [Wed, 25 Nov 2026 18:16:18 +0000 (18:16 +0000)]
MINOR: github: disable blank issues

People with LLMs are creating blank issues instead of using the issue
templates. This makes issues harder for maintainers to triage because the
expected information is missing.

Disable blank issues so reporters are directed to the existing templates.

6 days agoBUG/MEDIUM: cache: build the secondary key on an unusable first entry
Olivier Houchard [Wed, 25 Nov 2026 17:57:22 +0000 (18:57 +0100)]
BUG/MEDIUM: cache: build the secondary key on an unusable first entry

With "process-vary on", http_action_req_cache_use() returns without
building the secondary key when the first entry found for the primary
key cannot be used, because it is expired, stripped to its early hints
or still being stored. The response is then not stored if it has a Vary
header, since the transaction has no secondary key, and the expired
entry is not removed either. So once the first variant of a resource has
expired, this resource is not cached anymore, until that entry gets
evicted.

Let's build the secondary key in this case too, as was done before
commit 25fcee5b0 ("MEDIUM: cache: emit early hints if configured to do
so"), where an expired first entry was not returned by get_entry(). This
was introduced in 3.5-dev3, no backport is needed.

6 days agoBUG/MINOR: cache: free the blocks of aborted stores at once
Olivier Houchard [Wed, 25 Nov 2026 17:18:23 +0000 (18:18 +0100)]
BUG/MINOR: cache: free the blocks of aborted stores at once

When a store is aborted, because the object turns out to be larger than
max-object-size or because the stream ends before the end of the
response, its row is reattached to the avail list still holding its
data, but it is in no LRU. With "early-hints on", once such a row
reaches the head of the list, cache_make_room() evicts a valid entry
instead, and the row stays there. These rows pile up and the cache
shrinks until no valid entry is left. Any client can cause this by
requesting such objects or by aborting.

Let's truncate these rows when they are reattached, so that their
blocks are free again immediately. This was introduced by commit
77c4de1ec ("MEDIUM: cache: early hints-aware eviction code") in
3.5-dev3, no backport is needed.

6 days agoBUG/MINOR: ssl/cli: fix ckch_conf leaks in "add ssl crt-list"
Olivier Houchard [Wed, 25 Nov 2026 17:04:37 +0000 (18:04 +0100)]
BUG/MINOR: ssl/cli: fix ckch_conf leaks in "add ssl crt-list"

On success, cli_parse_add_crtlist() leaks the strings of a ckch_conf in
two cases: when the store takes the conf parsed from the line, its
previous conf is overwritten without being freed, and when the store
already has instances, the parsed conf is only compared to the one of
the store and never freed.

Let's free the conf which is not used by the store. This was introduced
by commit 1bc6e990f ("MEDIUM: ssl/cli: handle crt-store keywords in
crt-list over the CLI") in 3.0-dev12, so this should be backported to
3.0, after commit 29225103f ("BUG/MEDIUM: ssl/cli: restore the store
conf on "add ssl crt-list" error").

6 days agoBUG/MINOR: ssl/cli: don't clear the jwt flag on "add ssl crt-list"
Olivier Houchard [Wed, 25 Nov 2026 17:04:36 +0000 (18:04 +0100)]
BUG/MINOR: ssl/cli: don't clear the jwt flag on "add ssl crt-list"

When a store without any instance takes the conf parsed from an "add ssl
crt-list" line, its "jwt" flag is overwritten too, while the certificate
is still in the JWT tree. After "add ssl jwt" followed by "add ssl
crt-list", the certificate is no longer listed by "show ssl jwt", it can
be deleted while in use for JWT validation, and the JWT tree is no
longer updated when the certificate is.

Let's keep the flag when it was set. This was introduced by commit
18ff130e9 ("MINOR: jwt: Add new "jwt" certificate option") in 3.3-dev10,
so this should be backported to 3.3.

6 days agoBUG/MEDIUM: ssl/cli: keep the crt-store conf on "add ssl crt-list"
Olivier Houchard [Wed, 25 Nov 2026 17:04:35 +0000 (18:04 +0100)]
BUG/MEDIUM: ssl/cli: keep the crt-store conf on "add ssl crt-list"

In cli_parse_add_crtlist(), a store without any instance takes the conf
parsed from the line, even when it was declared in a crt-store section.
So adding such a certificate to a crt-list over the CLI silently drops
the settings of its "load" line: the file names are no longer reported
by "show ssl cert", and above all "ocsp-update on" is lost, so no OCSP
update is scheduled for it. A line with other keywords also replaces the
ones of the crt-store, while this is refused in a crt-list file.

Let's only replace the conf when the store doesn't come from a
crt-store, and compare the confs otherwise, as is done at boot. This
relies on the previous patch to work on an updated certificate. This was
introduced by commit 1bc6e990f ("MEDIUM: ssl/cli: handle crt-store
keywords in crt-list over the CLI") in 3.0-dev12, so this should be
backported to 3.0.

6 days agoBUG/MINOR: ssl/ckch: copy the origin of the conf in ckchs_dup()
Olivier Houchard [Wed, 25 Nov 2026 17:04:34 +0000 (18:04 +0100)]
BUG/MINOR: ssl/ckch: copy the origin of the conf in ckchs_dup()

ckchs_dup() copies the content of the ckch_conf, but not its "used"
field, which tells if the conf comes from a crt-store, from a crt-list,
or is empty. So once a certificate was updated, with "set ssl cert" and
"commit ssl cert" for example, its store looks like it was loaded
without any keyword, and ckch_conf_cmp() applies the wrong rules: adding
a crt-store certificate to a crt-list over the CLI with the very
keywords of its crt-store is refused.

Let's copy that field too. The conf is copied since commit 5b85b81d8
("MINOR: ssl/ckch: handle ckch_conf in ckchs_dup() and
ckch_conf_clean()") in 3.2-dev11, so this should be backported to 3.2.

6 days agoBUG/MEDIUM: ssl/cli: restore the store conf on "add ssl crt-list" error
Olivier Houchard [Wed, 25 Nov 2026 16:47:42 +0000 (17:47 +0100)]
BUG/MEDIUM: ssl/cli: restore the store conf on "add ssl crt-list" error

In cli_parse_add_crtlist(), a store without any instance adopts the
ckch_conf parsed from the line, but if the line is rejected afterwards,
the error path frees the content of that conf, and the store keeps
pointers to freed strings. They are then printed by "show ssl cert" and
freed again by "del ssl cert". It can be triggered by adding a
certificate created with "new ssl cert" to a crt-list which is a
directory, using crt-store keywords such as "key" or "issuer".

Let's save the previous conf of the store and restore it on error, so
that a rejected line doesn't change the store. This was introduced by
commit 1bc6e990f ("MEDIUM: ssl/cli: handle crt-store keywords in crt-list
over the CLI") in 3.0-dev12, so this should be backported to 3.0.

6 days agoCI: github: enable slow regression tests for OpenSSL master
William Lallemand [Wed, 25 Nov 2026 14:42:03 +0000 (14:42 +0000)]
CI: github: enable slow regression tests for OpenSSL master

Include the slow regression tests in the nightly OpenSSL master job by
adding slow to REGTESTS_TYPES. Keep the other workflows unchanged.

6 days agoBUG/MEDIUM: ssl/cli: reset the transaction on interrupted CA/CRL commits
Olivier Houchard [Wed, 25 Nov 2026 16:35:16 +0000 (17:35 +0100)]
BUG/MEDIUM: ssl/cli: reset the transaction on interrupted CA/CRL commits

As was fixed for certificates in commit ca42c37bc ("BUG/MEDIUM: ssl/cli:
reset the ongoing transaction when "commit ssl cert" is interrupted"),
when a "commit ssl ca-file" or "commit ssl crl-file" applet is released
before the end, e.g. because the CLI client left while it was yielding,
the release function frees the new entry but the transaction still
references it, or the old entry, already freed once the new one is
inserted. The next "show", "set", "commit" or "abort" on that file then
uses freed memory, which crashes the process.

Let's reset the transaction in the release functions when the applet did
not reach CACRL_ST_FIN. This was introduced in 2.5 with the commands, by
commits a32a68bd3 ("MEDIUM: ssl: Add "set+commit ssl ca-file" CLI
commands") and a51b339d9 ("MEDIUM: ssl: Add "set+commit ssl crl-file" CLI
commands"), so this should be backported to all stable branches.

6 days agoDOC: config: mention the nesting limit of the json_query() converter
Olivier Houchard [Wed, 25 Nov 2026 16:17:13 +0000 (17:17 +0100)]
DOC: config: mention the nesting limit of the json_query() converter

The JSON parser does not process documents nested deeper than 20 levels
(MJSON_MAX_DEPTH), so json_query() and the converters relying on it
find nothing located after an element nested deeper than that. Let's
mention it next to the other known limitations of this converter.

This may be backported to all supported versions.

6 days agoBUG/MEDIUM: mjson: decode the escaped slash in strings
Olivier Houchard [Wed, 25 Nov 2026 15:28:48 +0000 (16:28 +0100)]
BUG/MEDIUM: mjson: decode the escaped slash in strings

RFC 8259 allows the slash to be escaped in JSON strings as "\/", and
some encoders emit it by default (e.g. PHP's json_encode()). But
mjson_unescape() does not know this escape and fails, so no value is
returned for such strings by json_query(), jwt_header_query() and
jwt_payload_query(), nor to the ACME client which extracts strings the
same way. This can be reproduced with req.body,json_query('$.url') on
{"url":"\/a\/b"}.

Let's add the slash to the escapes known by mjson_esc().

This exists since the library was imported in 2.4-dev17 by commit
41007a683 ("MINOR: sample: converter: Add mjson library."). It must be
backported to all supported versions.

6 days agoBUG/MEDIUM: mjson: stop the lookup when the matched element ends
Olivier Houchard [Wed, 25 Nov 2026 14:53:23 +0000 (15:53 +0100)]
BUG/MEDIUM: mjson: stop the lookup when the matched element ends

When a JSON path component matches, mjson_find() does not detect that
the matching element ends without containing the rest of the path, and
keeps matching the remaining components against what follows. A value
may then be returned for a path which does not exist:

  $.a[0].b on {"a":[{"x":1},{"b":"other"}]}     returns "other"
  $.a[0]   on {"a":[],"b":["other"]}            returns "other"
  $.a.b.c  on {"a":{"b":1},"x":[{"c":"evil"}]}  returns "evil"

This affects json_query(), jwt_header_query() and jwt_payload_query(),
and can be reproduced with req.body,json_query('$.a[0].b') and the first
document above.

Let's stop the lookup when a scalar matches a component while the path
is not finished, when a comma follows the matching element, and when
the container holding it is closed. Commas are also only counted as
array separators when an index is expected. The library fixed part of
this after it was imported, in its commit d2d9e4658 ("Fix #32 - fail
search if value not found in the requested array elem").

This exists since the library was imported in 2.4-dev17 by commit
41007a683 ("MINOR: sample: converter: Add mjson library."). It must be
backported to all supported versions.

6 days agoMEDIUM: server: add a global setting "unresolvable-server-fqdn"
Willy Tarreau [Sat, 21 Nov 2026 22:09:38 +0000 (23:09 +0100)]
MEDIUM: server: add a global setting "unresolvable-server-fqdn"

Recent fix 612b87e75 ("BUG/MEDIUM: resolvers: reject too long labels
when encoding a name") revealed deployment bugs where users are relying
on DNS labels longer than 63 chars, which have obviously never worked.

The problem is that before they would fail silently and now the config
refuses to start. When configs are orchestrated, often users have long
lost any control on what happens and only have to endure what their
orchestrator decides for them, so it can take ages before they figure
how to fix that.

This patch adds a global option to detect the situation at server
registration time, and to emit a warning and force the server to
maintenance instead of hard-failing. It is only meant to be used as a
workaround for the time it takes to fix the configuration, and must
never be left enabled since it will silently let broken configs start.

It will help to backport this patch where the commit above was backported,
i.e. 2.6, with a change to warn by default and indicating that this will
change in 3.5.

6 days agoBUG/MINOR: resolvers: display the template name instead of "server '(null)'"
Willy Tarreau [Wed, 25 Nov 2026 14:09:21 +0000 (15:09 +0100)]
BUG/MINOR: resolvers: display the template name instead of "server '(null)'"

When resolvers fail to create a resolution, the server name is printed,
but for templates, the server is not yet assigned so "server '(null)'"
is printed, which is ugly and not really helpful. Let's just fall back
to the template name and indicate it.

This can be backported to all versions.

6 days agoBUG/MEDIUM: rawsock: don't take a short kTLS read for the end of data
Olivier Houchard [Tue, 24 Nov 2026 17:33:04 +0000 (18:33 +0100)]
BUG/MEDIUM: rawsock: don't take a short kTLS read for the end of data

When a read returns less than requested, raw_sock_to_buf() considers
the socket buffer empty, and reports a shutdown if the poller already
saw one. But on a kTLS socket recvmsg() returns at most one record, so
the following records are never read when the peer's FIN is already
there. With "ktls on" on a server closing without a close_notify right
after its response, the response is lost and a 502 is returned.

Let's not do this for reads using a control message buffer, which are
only used for kTLS.

This was introduced in 3.3-dev7 by commit 3d685fcb7 ("MINOR: xprt: Add
recvmsg() and sendmsg() parameters to rcv_buf() and snd_buf()."). It
must be backported to 3.3.

6 days agoBUG/MEDIUM: ssl: trim dropped kTLS records from the end of the buffer
Olivier Houchard [Tue, 24 Nov 2026 17:33:04 +0000 (18:33 +0100)]
BUG/MEDIUM: ssl: trim dropped kTLS records from the end of the buffer

With AWS-LC and kTLS, ssl_sock_to_buf() reads the records itself, and
drops the NewSessionTicket and close_notify ones it has just received
using b_del(). But this removes data from the head of the buffer, while
the record was appended at its tail. When the buffer already contains
data, their beginning is lost and the record stays in the buffer,
resulting in a corrupted stream, typically an invalid HTTP response
when a server sends a close_notify right after its response. This
rarely shows up for now, because a kTLS read is almost always the last
one of a call.

Let's use b_sub() to remove the record from the tail.

This was introduced in 3.3-dev7 by commit 5da354098 ("MEDIUM: ssl:
Handle non-Application data record with AWS-LC"). It must be backported
to 3.3.

6 days agoBUG/MINOR: pattern: do not index too large strings using the tree
Willy Tarreau [Wed, 25 Nov 2026 10:20:55 +0000 (11:20 +0100)]
BUG/MINOR: pattern: do not index too large strings using the tree

In pat_idx_tree_str(), we have to fall back to the list also when
trying to index strings that are larger than the encoded bit depth,
i.e. 4095 bytes including the trailing zero. Anyway at such lengths
there cannot be that many strings (due to memory usage) and lists
will probably not be much more expensive than trees.

This needs to be backported to all versions.

6 days agoBUG/MINOR: pattern: don't rely on the trash size to read pattern files
Dongwon Jang [Tue, 17 Nov 2026 01:47:22 +0000 (10:47 +0900)]
BUG/MINOR: pattern: don't rely on the trash size to read pattern files

Since commit 3ef263987 ("MEDIUM: chunks: Realloc trash buffers only after
the config is parsed and checked") in 1.8, the trash keeps its early
default size (BUFSIZE) until init_trash_buffers() is called after
check_config_validity(). Pattern files (maps, ACL "-f" files and
set-vars-from-map files) are loaded before that point, and their lines are
read with fgets() into the trash. As a result, a line longer than BUFSIZE-1
(16383 by default) is silently split regardless of tune.bufsize: the first
part is loaded with a truncated value and the remainder is loaded as one or
more extra entries, without any warning. For ACLs, this also means that the
16383-char prefix of a long pattern matches while the full pattern does
not. The only workarounds are to shorten such lines or to set the entries
again from the CLI after each reload.

Let's read pattern file lines with read_line_to_mem() instead, which uses
a dedicated heap buffer that grows as needed. Resizing the trash earlier
was not an option since ACL files are loaded while parsing. Values remain
bounded at runtime by tune.bufsize since pattern_exec_match() copies the
matched sample into a trash chunk, which is consistent with what can be
set from the CLI.

A reg-test was added which checks that a map file and an ACL file holding
a single 20000-char line are each loaded as a single entry, and that the
map value is returned in full.

This fixes GitHub issue #3537.

This should be backported to all stable versions, along with the previous
commit "MINOR: tools: add read_line_to_mem() to read a line into a growing
buffer" which it depends on. Before 3.0, the two pat_ref_read_from_file*()
functions take the file name as an argument, which only changes the patch
context.

6 days agoMINOR: tools: add read_line_to_mem() to read a line into a growing buffer
Dongwon Jang [Tue, 17 Nov 2026 01:33:04 +0000 (10:33 +0900)]
MINOR: tools: add read_line_to_mem() to read a line into a growing buffer

read_line_to_trash() reads the first line of a file into the trash, so
longer lines are truncated to the trash size. Some callers need to read
lines of any length from an already opened file instead, such as the
pattern file readers, which run before the trash is resized to
tune.bufsize.

read_line_to_mem() reads the next line of a file into a caller-provided
heap buffer that grows as needed, as parse_cfg() does for configuration
lines. Unlike read_line_to_trash(), the trailing LF is kept. A full buffer
is detected by checking whether fgets() overwrote its last byte rather
than from the string length, so that lines containing NUL bytes are read
entirely as well. getline() is not used since it was removed for
portability reasons by commit fbc3d46b9 ("BUILD: stats: remove non
portable getline() usage").

It will be used by the next commit to fix the pattern file readers, and
will have to be backported along with it.