]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MINOR: ssl: reject server certificate names containing a NUL byte
authorWilliam Lallemand <wlallemand@haproxy.com>
Thu, 6 Aug 2026 07:44:59 +0000 (09:44 +0200)
committerWilliam Lallemand <wlallemand@haproxy.com>
Fri, 7 Aug 2026 10:03:01 +0000 (10:03 +0000)
commit6c85fb11bfe77ca5e20cb5ff378aa67a01bccb5f
tree486b6e0287c8a0582b935920af612d7aac8895a3
parentb5e77960c42864c98548cb4a882720b625bcf727
BUG/MINOR: ssl: reject server certificate names containing a NUL byte

ssl_sock_srv_verifycbk() decodes each SAN dNSName and each CN of the
server certificate with ASN1_STRING_to_UTF8(), which returns the decoded
length, then passes the result to the hostname matcher as a plain
NUL-terminated C string and throws the length away. A name encoded as
"victim.com\0.attacker.com" is therefore compared as "victim.com" and
matches.

This defeats the point of "verify required" together with "verifyhost" or
SNI on a server line: an attacker holding a certificate with such a name,
and able to intercept the connection to the backend, passes the name check
and can read and alter all the proxied traffic. This is the CVE-2009-2408
class of bug. It requires a CA to issue such a certificate, which modern
CAs refuse to do, so the practical risk is low, but the check is cheap.

Let's compare the decoded length with strlen() and ignore any name that
does not match.

This has been there since "verifyhost" was introduced in 1.5 by commit
be55431f9 ("MINOR: ssl: Add statement 'verifyhost' to "server"
statements"). It may be backported to all stable versions.

Reported-by: Claude (ANT-2026-SNXPSVKX)
src/ssl_sock.c