From: Frederic Lecaille Date: Mon, 14 Sep 2026 08:25:43 +0000 (+0200) Subject: WIP: BUG/MINOR: connection: fix the type of the PROXY protocol TLV fetches X-Git-Url: https://git.kaiwu.me/?a=commitdiff_plain;h=b4591f045a1a5ba26d772c085508c663390bfd11;p=haproxy.git WIP: BUG/MINOR: connection: fix the type of the PROXY protocol TLV fetches A string sample cannot contain a \0 byte, but fc_pp_tlv() returned the raw TLV value as a string, so a sender could put a \0 in it. Such a value was then matched by "-m str" on its prefix: "public\0x" matched "public". This also affected fc_pp_authority and fc_pp_unique_id which rely on it. A TLV value is a raw byte sequence, so fc_pp_tlv now returns a binary sample: its bytes are kept, \0 included, for hex, bytes or relaying with set-proxy-v2-tlv-fmt, and the usual binary to string cast applies for text consumers. fc_pp_authority and fc_pp_unique_id are text by nature and still return a string, but fail when the value holds a \0. Note that an ACL on fc_pp_tlv now needs an explicit matching method ("-m str") since a binary sample has no default one. Such a rule prevents haproxy from starting: http-request deny if { fc_pp_tlv(ALPN) h2 } must now be written http-request deny if { fc_pp_tlv(ALPN) -m str h2 } The documentation of these three fetches is updated accordingly, and a reg-test is added: it checks the three fetches with a raw PROXY v2 header holding "public\0x" values and a binary SSL TLV full of \0 bytes. A second reg-test, only run when OpenSSL is available, checks that the SSL TLV sent by send-proxy-v2-ssl is returned as is. This must be backported to all stable branches. --- diff --git a/doc/configuration.txt b/doc/configuration.txt index b5615ba49..bc6361bff 100644 --- a/doc/configuration.txt +++ b/doc/configuration.txt @@ -19906,7 +19906,7 @@ set-proxy-v2-tlv-fmt() Example: server srv1 192.168.1.1:80 send-proxy-v2 set-proxy-v2-tlv-fmt(0x20) %[fc_pp_tlv(0x20)] - In this case, we fetch the TLV with the type 0x20 as a string and set as the value + In this case, we fetch the raw TLV with the type 0x20 and set it as the value of a newly created TLV that also has the type 0x20. proxy-v2-options