TLS Certificate Hostname Mismatch

The service presents a TLS certificate that is not valid for the name clients use to reach it, so clients warn or refuse, and users may learn to ignore certificate warnings.

SeverityMedium
CVSS 3.16.8 CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:N Open in the calculator
CVSS 4.07.4 CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:A/VC:H/VI:H/VA:N/SC:N/SI:N/SA:N Open in the calculator
CWECWE-297: Improper Validation of Certificate with Host Mismatch
OWASP Top 10A07:2025 Authentication Failures
MITRE ATT&CKT1557 Adversary-in-the-Middle
CategoryCryptographic Failures

Description

The certificate presented by the service is not valid for the host name clients use to connect. Clients compare the name they asked for with the DNS names in the certificate's Subject Alternative Name (SAN) extension, and current browsers no longer accept a name that appears only in the older Common Name (CN) field. A wildcard entry matches one label only: *.example.com covers www.example.com but not example.com or a.b.example.com.

When the name does not match, browsers warn, and users who meet the warning regularly learn to accept certificate errors, so an attacker able to intercept their traffic could present a certificate of their own, which raises a similar warning, and read or alter the session, including credentials. Non-browser clients either fail to connect or, often, have host name checking disabled to make them work, which leaves them open to interception by anyone holding any certificate their trust store accepts.

Common causes are a default or self-signed certificate naming a device's internal host name; a certificate for another site on the same address, because the server does not select certificates by Server Name Indication (SNI) or presents a default certificate for unrecognised names; a certificate issued for the internal name of a service that is also published externally; and services reached by IP address. Where the mismatch appears only when the service is reached by IP address, and clients always use the correct name, the practical risk is low.

The issue is shown by the browser warning, by testssl.sh and sslscan, and by vulnerability scanners. Scanners that connect by IP address, or without sending the expected SNI name, often report a mismatch for a correctly configured service, so the finding should be confirmed using the host name that clients actually use.

Remediation

Present a certificate that is valid for every name clients use to reach the service:

  • Issue a certificate whose SAN lists each fully qualified name in use, including the bare domain where that is used, rather than relying on the CN.
  • Where several sites share an address, configure each virtual host with its own certificate so that the server selects it by SNI, and configure the default site to present a suitable certificate or to reject unrecognised names (in nginx, ssl_reject_handshake on in the default server block).
  • Use separate certificates for internal and external names, as the OWASP TLS guidance recommends, rather than exposing internal names in public certificates.
  • Replace the default certificates on appliances and devices with certificates issued for the names used to manage them, and give clients a DNS name to use rather than an IP address.
  • Re-enable host name verification in any client where it was disabled.

Confirm the fix by connecting with each name in use while sending the matching SNI value, for example with openssl s_client and its -servername option, and checking that the certificate validates for that name.

References


Add This Finding to Your Library

In Pental this write-up is in Settings, Library. Add to my library copies it into your own, rated in your firm's CVSS version, ready to put in your own words.

Free trial  ·  No card required

Only need the reporting? Our reporting tool is free and open source, with the same library.


More TLS and Certificates Findings

Every TLS and Certificates finding