]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MINOR: ssl-gencert: validate SNI characters to prevent SAN certificate injection
authorWilliam Lallemand <wlallemand@haproxy.com>
Mon, 25 May 2026 12:55:18 +0000 (12:55 +0000)
committerWilliam Lallemand <wlallemand@haproxy.com>
Wed, 27 May 2026 08:20:55 +0000 (10:20 +0200)
commit85a833feba0e631eea225e768461a6e0880397a4
tree1f9575f6cf31d50447d75fc578b714f49500cc24
parent31cd3d13aaa760af27b7c2eba57da19274b51a61
BUG/MINOR: ssl-gencert: validate SNI characters to prevent SAN certificate injection

ssl_sock_add_san_ext() builds the Subject Alternative Name extension by
concatenating "DNS:" + servername and passing the result to
X509V3_EXT_nconf_nid(). OpenSSL's nconf parser splits the value string on
commas into multiple type:value SAN entries. The SNI comes from unauthenticated
TLS ClientHello data -- an attacker can embed commas and colons (e.g.,
"host,dns:internal.corp,ip:10.0.0.1") to inject arbitrary GENERAL_NAME entries
into certificates signed by HAProxy's configured CA.

This is a CA issuance-policy violation: the operator expects one certificate
per SNI hostname, but an attacker can obtain certificates containing additional
hostnames/IPs/emails without access to the CA private key.

Fix by adding ssl_sock_sni_is_valid() that validates the SNI contains only
DNS-label-legal characters (alphanumeric, hyphens, dots). The check is
performed at the start of ssl_sock_do_create_cert() before any allocation.
Commas, colons, spaces, and other special characters cause certificate
generation to fail, preventing SAN injection while allowing all valid
hostname values.

Must be backported in every maintained branches.
src/ssl_gencert.c