CWE-297: Improper Validation of Certificate with Host Mismatch
The product communicates with a host that provides a certificate, but the product does not properly ensure that the certificate is actually associated with that host.
Last updated
The product communicates with a host that provides a certificate, but the product does not properly ensure that the certificate is actually associated with that host.
Last updated
Even if a certificate is well-formed, signed, and follows the chain of trust, it may simply be a valid certificate for a different site than the site that the product is interacting with.
94 recorded CVEs are caused by CWE-297 (Improper Validation of Certificate with Host Mismatch). The highest-severity and most recent are shown first. 52 new CWE-297 CVEs have been recorded so far in 2026 (11 in 2025).
JSSE hostname verifier CN-fallback enabled by default despite documented opt-in
Improper validation of certificate with host mismatch in AWS IoT Device SDK for Python
Improper TLS Hostname Verification in Snowflake Connector for Python
ssl_verify_fun: partial-label wildcard certificate matches hostnames across a label boundary
Apache CXF: The Netty HTTP client transport does not perform TLS hostname verification.
Apache Thrift: c_glib TLS Client Missing Hostname Verification
Xiaomi Galaxy FDS Android SDK <= 3.0.8 TLS Hostname Verification Disabled Enables MITM
Apache Uniffle: Insecure SSL Configuration in Uniffle HTTP Client
Improper Validation of Certificate with Host Mismatch in Java-WebSocket
Showing 12 of 94 recorded CWE-297 CVEs. Get an alert for each new one, with AI-written analysis and fixes.
Monitor these CVEsWhat can happen when CWE-297 is exploited.
Gain Privileges or Assume Identity
Affects: Access Control
The data read from the system vouched for by the certificate may not be from the expected system.
Other
Affects: Authentication, Other
Trust afforded to the system in question - based on the malicious certificate - may allow for spoofing or redirection attacks.
Gain Privileges or Assume Identity, Other
Affects: Access Control, Other
If the certificate's host-specific data is not properly checked - such as the Common Name (CN) in the Subject or the Subject Alternative Name (SAN) extension of an X.509 certificate - it may be possible for a redirection or spoofing attack to allow a malicious host with a valid certificate to provide data, impersonating a trusted host.
Typically introduced during these phases of the software lifecycle.
Technologies
Practical mitigations for CWE-297, grouped by where in the lifecycle they apply.
In order to ensure data integrity, the certificate must be valid, and it must pertain to the site that is being accessed.Fully check the hostname of the certificate and provide the user with adequate information about the nature of the problem and how to proceed.
If certificate pinning is being used, ensure that all relevant properties of the certificate are fully validated before the certificate is pinned, including the hostname.
Be careful of other weaknesses in the code that checks the hostname, since it is still possible to incorrectly check the hostname. For example, attackers could create a certificate with a name that begins with a trusted name followed by a NUL byte, which could cause some string-based comparisons to only examine the portion that contains the trusted name.
Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)
Effectiveness: High
Set up an untrusted endpoint (e.g. a server) with which the product will connect. Create a test certificate that uses an invalid hostname but is signed by a trusted CA and provide this certificate from the untrusted endpoint. If the product performs any operations instead of disconnecting and reporting an error, then this indicates that the hostname is not being checked and the test certificate has been accepted.
When Certificate Pinning is being used in a mobile application, consider using a tool such as Spinner [7]. This methodology might be extensible to other technologies.
MITRE examples of the weakness in code.
The following OpenSSL code obtains a certificate and verifies it.
Vulnerable example
cert = SSL_get_peer_certificate(ssl);
if (cert && (SSL_get_verify_result(ssl)==X509_V_OK)) {
// do secret things
}Even though the "verify" step returns X509_V_OK, this step does not include checking the Common Name against the name of the host. That is, there is no guarantee that the certificate is for the desired host. The SSL connection could have been established with a malicious host that provided a valid certificate.
Real CVEs that MITRE cites as examples of this weakness.
Common questions about CWE-297.
Weakness data is sourced from the MITRE CWE catalog (v4.21). CVE associations are aggregated and kept current by RadicalNotion.AI.
Get an alert when a new CWE-297 CVE affects your products, with AI-written analysis and remediation steps.