VulnWatch by ve1ve2
medium 4.3 EPSS 0.16%

GHSA-vvx9-73fr-5jjx / CVE-2026-91769: TLS Hostname Verification Falls Back to CN After SAN Mismatch

Source:
PHP releases (GitHub php/php-src tags)
Published:
Fetched:
Updated:
Affects:
php ext-openssl

https://github.com/php/php-src/security/advisories/GHSA-vvx9-73fr-5jjx ↗

repo-advisoryphpsecurityrepo:php/php-src

TLS Hostname Verification Falls Back to CN After SAN Mismatch ### Summary PHP's OpenSSL stream peer verification checks the certificate's subjectAltName entries first and, whenever no entry matches, falls back to the Common Name. RFC 6125 requires the CN to be ignored once the certificate presents any service identity, so a certificate carrying a non-matching DNS SAN was still accepted when its CN matched the requested `peer_name`. A certificate trusted by the client for one name can therefore be used to impersonate another. ### Details `php_openssl_apply_peer_verification_policy()` tries the SAN list and then unconditionally falls back to the CN: https://github.com/php/php-src/blob/php-8.5.10/ext/openssl/xp_ssl.c#L635-L641 In the tested build a certificate with `CN=victim.test` and `SAN=DNS:attacker.test` was accepted for `peer_name=victim.test`. A control certificate with `CN=other.test` and the same SAN was rejected, confirming that acceptance came from the CN and that a SAN mismatch did not suppress the fallback. The fix makes `php_openssl_matches_san_list()` report whether the certificate presented a service identity, meaning a DNS SAN, a URI SAN, or an SRV-ID `otherName` (OID 1.3.6.1.5.5.7.8.7). When one is present and none matched, verification now fails with `Peer certificate subjectAltName did not match expected name` instead of consulting the CN. Certificates with no service identity at all keep the CN fallback for backwards compatibility. ### PoC Certificate for the accepted case: ```ini [req] distinguished_name = dn prompt = no x509_extensions = v3_req [dn] CN = victim.test [v3_req] subjectAltName = @alt_names extendedKeyUsage = serverAuth [alt_names] DNS.1 = attacker.test ``` The rejected control uses the same file with `CN = other.test`. ```php [ 'verify_peer' => true, 'verify_peer_name' => true, 'allow_self_signed' => false, 'cafile' => $argv[2], 'peer_name' => $argv[3] ?? 'victim.test', ], 'http' => ['ignore_errors' => true, 'timeout' => 5], ]); $data = @file_get_contents($argv[1], false, $ctx); echo $data === false ? "FAIL\n" : "OK\n"; ``` Steps: 1. Create a local CA certificate. 2. Issue one server certificate with `CN=victim.test` and `SAN=DNS:attacker.test`. 3. Issue a control certificate with `CN=other.test` and the same SAN. 4. Serve each certificate in turn from a local TLS server. 5. Run the client with `peer_name=victim.test` and the CA certificate. The first certificate prints `OK` (accepted) and the control prints `FAIL`. ### Impact A certificate that a client trusts for one hostname can be used to impersonate a different hostname, as long as the attacker's certificate carries the target name in its Common Name. This matters where certificates come from a private PKI, an internal CA, or any environment where an attacker can obtain a certificate whose CN it does not control the SAN for. It affects eve Affected packages: php:ext-openssl Patched: ext-openssl 8.2.34, ext-openssl 8.3.35, ext-openssl 8.4.26, ext-openssl 8.5.11

Linked vulnerabilities (2)

CVE-2026-91769 medium 4.3 EPSS 0.16% (p5) NVDCVE.orgGHSA
CVSS:3.1/AV:A/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N

php8.2 - security update

Aliases: CVE-2025-1218, CVE-2025-14181, CVE-2026-6103, CVE-2026-91765, CVE-2026-91766, CVE-2026-91767, CVE-2026-91768, CVE-2026-92842, CVE-2026-93682, GHSA-vvx9-73fr-5jjx
CVSS:3.1/AV:A/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N

TLS Hostname Verification Falls Back to CN After SAN Mismatch

Aliases: CVE-2026-91769