]> git.kaiwu.me - haproxy.git/commit
BUG/MEDIUM: ssl: prevent CN fallback when a SAN extension is present master
authorWilliam Lallemand <wlallemand@haproxy.com>
Thu, 26 Nov 2026 17:48:04 +0000 (17:48 +0000)
committerWilliam Lallemand <wlallemand@haproxy.com>
Thu, 26 Nov 2026 17:57:58 +0000 (18:57 +0100)
commit47521745280e2570f68b8a1ef1153a26acc5cb81
treef26a9774523fa6d77308699f8a40db06afb7bfd0
parent6117bf4bc64b7d443835f084a85459c1e55cefd5
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
src/ssl_sock.c