]> git.kaiwu.me - haproxy.git/commit
BUG/MINOR: ssl: reject an embedded NUL in the ssl_*_dn(entry) fetches
authorWilliam Lallemand <wlallemand@haproxy.com>
Wed, 12 Aug 2026 09:19:54 +0000 (09:19 +0000)
committerWilliam Lallemand <wlallemand@haproxy.com>
Wed, 12 Aug 2026 12:51:25 +0000 (14:51 +0200)
commit449133cba139e27afb291f509e884d3cf2789f94
treec6865366eaed91b0c0d1188b44495e01b2dd2238
parenta8f5ed6fcb8a28d6332595732e2a3b9940d3db33
BUG/MINOR: ssl: reject an embedded NUL in the ssl_*_dn(entry) fetches

ssl_sock_get_dn_entry() copied the ASN.1-declared bytes of a DN entry
verbatim, keeping the exact length. pat_match_str()'s tree branch
(used by the default, exact-match "-m str" ACLs) then looks the value
up with ebst_lookup(), which treats it as a NUL-terminated C string.

A certificate with e.g. CN = "admin\0.attacker-owned.example" is
therefore matched and authorized as "admin": the producer keeps the
full value, but the ebtree consumer silently truncates at the first
NUL. ACLs using "-i" are unaffected since they take the length-correct
list branch instead of the tree.

Reject such a value in the fetch itself, before it reaches the
pattern-matching layer: a NUL followed by any further non-NUL byte
now makes ssl_sock_get_dn_entry() fail as if the entry did not exist,
so ssl_c_s_dn(CN)/ssl_c_i_dn(CN)/ssl_r_dn(CN) and any map/ACL relying
on it can't be bypassed this way. Trailing NUL byte(s) with nothing
after them aren't a truncation risk, so a single one is kept in the
returned length instead of the whole ASN.1 length, and any extra ones
are skipped.

The impact is low since it would need to be signed by the CA anyway.

This should be backported to every stable branch.

Reported-by: Vivek Parikh <vivek.parikh@breachx.ai>
doc/configuration.txt
src/ssl_utils.c