---
title: "CWE-297: Improper Validation of Certificate with Host Mismatch"
url: https://radicalnotion.ai/cwe/cwe-297
type: cwe
description: "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."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-297: Improper Validation of Certificate with Host Mismatch

- **Abstraction:** Variant
- **Structure:** Simple
- **Status:** Incomplete
- **Likelihood of exploit:** High
- **CVEs with this as primary weakness:** 94
- **Of those, in CISA KEV:** 0
- **New in 2026:** 52
- **CWE catalog version:** 4.21

## Description

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.

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.

## Modes of introduction

| Phase | Note |
| --- | --- |
| Implementation | When the product uses certificate pinning, the developer might not properly validate all relevant components of the certificate, such as verifying the hostname, before pinning the certificate. This can make it difficult or expensive to test after the pinning is complete. |
| Implementation | REALIZATION: This weakness is caused during implementation of an architectural security tactic. |

## Applicable platforms

**Technologies:** Mobile (Undetermined), Web Based (Undetermined)

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Access Control | Gain Privileges or Assume Identity | The data read from the system vouched for by the certificate may not be from the expected system. |
| Authentication, Other | Other | Trust afforded to the system in question - based on the malicious certificate - may allow for spoofing or redirection attacks. |
| Access Control, Other | Gain Privileges or Assume Identity, 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. |

## Potential mitigations

### Architecture and Design

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.

### Implementation

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.

### Implementation

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.

## Detection methods

### Automated Static Analysis

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

### Dynamic Analysis with Manual Results Interpretation

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.

### Black Box

When Certificate Pinning is being used in a mobile application, consider using a tool such as Spinner \[REF-955\]. This methodology might be extensible to other technologies.

## Demonstrative examples

### Example 1

The following OpenSSL code obtains a certificate and verifies it.

Bad code:

```c
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.

## Observed examples

| CVE | Description |
| --- | --- |
| CVE-2012-5810 | Mobile banking application does not verify hostname, leading to financial loss. |
| CVE-2012-5811 | Mobile application for printing documents does not verify hostname, allowing attackers to read sensitive documents. |
| CVE-2012-5807 | Software for electronic checking does not verify hostname, leading to financial loss. |
| CVE-2012-3446 | Cloud-support library written in Python uses incorrect regular expression when matching hostname. |
| CVE-2009-2408 | Web browser does not correctly handle '\\0' character (NUL) in Common Name, allowing spoofing of https sites. |
| CVE-2012-0867 | Database program truncates the Common Name during hostname verification, allowing spoofing. |
| CVE-2010-2074 | Incorrect handling of '\\0' character (NUL) in hostname verification allows spoofing. |
| CVE-2009-4565 | Mail server's incorrect handling of '\\0' character (NUL) in hostname verification allows spoofing. |
| CVE-2009-3767 | LDAP server's incorrect handling of '\\0' character (NUL) in hostname verification allows spoofing. |
| CVE-2012-5806 | Payment processing module does not verify hostname when connecting to PayPal using PHP fsockopen function. |
| CVE-2012-2993 | Smartphone device does not verify hostname, allowing spoofing of mail services. |
| CVE-2012-5804 | E-commerce module does not verify hostname when connecting to payment site. |
| CVE-2012-5824 | Chat application does not validate hostname, leading to loss of privacy. |
| CVE-2012-5822 | Application uses third-party library that does not validate hostname. |
| CVE-2012-5819 | Cloud storage management application does not validate hostname. |
| CVE-2012-5817 | Java library uses JSSE SSLSocket and SSLEngine classes, which do not verify the hostname. |
| CVE-2012-5784 | SOAP platform does not verify the hostname. |
| CVE-2012-5782 | PHP library for payments does not verify the hostname. |
| CVE-2012-5780 | Merchant SDK for payments does not verify the hostname. |
| CVE-2003-0355 | Web browser does not validate Common Name, allowing spoofing of https sites. |

## Real CVEs with this weakness (sample of 12 of 94)

| CVE | Title | Severity | CVSS | EPSS | CISA KEV | Published |
| --- | --- | --- | --- | --- | --- | --- |
| CVE-2025-46408 | - | critical | 9.8 | - | No | 2025-09-15 |
| CVE-2026-59638 | JSSE hostname verifier CN-fallback enabled by default despite documented opt-in | critical | 9.3 | - | No | 2026-08-03 |
| CVE-2026-92943 | Improper validation of certificate with host mismatch in AWS IoT Device SDK for Python | critical | 9.2 | - | No | 2026-09-17 |
| CVE-2026-15925 | Improper TLS Hostname Verification in Snowflake Connector for Python | critical | 9.2 | - | No | 2026-07-16 |
| CVE-2026-117666 | ssl\_verify\_fun: partial-label wildcard certificate matches hostnames across a label boundary | critical | 9.1 | - | No | 2026-10-30 |
| CVE-2026-107938 | Apache CXF: The Netty HTTP client transport does not perform TLS hostname verification. | critical | 9.1 | - | No | 2026-10-09 |
| CVE-2026-48144 | Apache Thrift: c\_glib TLS Client Missing Hostname Verification | critical | 9.1 | - | No | 2026-07-27 |
| CVE-2026-26214 | Xiaomi Galaxy FDS Android SDK \<= 3.0.8 TLS Hostname Verification Disabled Enables MITM | critical | 9.1 | - | No | 2026-02-12 |
| CVE-2025-68637 | Apache Uniffle: Insecure SSL Configuration in Uniffle HTTP Client | critical | 9.1 | - | No | 2026-01-07 |
| CVE-2021-33695 | - | critical | 9.1 | - | No | 2021-09-15 |
| CVE-2020-1887 | - | critical | 9.1 | - | No | 2020-03-12 |
| CVE-2020-11050 | Improper Validation of Certificate with Host Mismatch in Java-WebSocket | critical | 9.0 | - | No | 2020-05-07 |

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-295](https://radicalnotion.ai/cwe/cwe-295) | Improper Certificate Validation |
| Parent | [CWE-923](https://radicalnotion.ai/cwe/cwe-923) | Improper Restriction of Communication Channel to Intended Endpoints |
| Peer | [CWE-370](https://radicalnotion.ai/cwe/cwe-370) | Missing Check for Certificate Revocation after Initial Check |

## Taxonomy mappings

| Taxonomy | Entry | Id | Fit |
| --- | --- | --- | --- |
| CLASP | Failure to validate host-specific certificate data | - | - |

## Frequently asked questions

### What is CWE-297?

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.

### What CVEs are caused by CWE-297?

94 recorded CVEs are attributed to CWE-297, including CVE-2025-46408, CVE-2026-59638 and CVE-2026-92943.

### How do you prevent CWE-297?

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.

### How is CWE-297 detected?

Automated Static Analysis: 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.)

### What are the consequences of CWE-297?

Exploiting CWE-297 can lead to: Gain Privileges or Assume Identity, Other.

### Is CWE-297 actively exploited?

94 recorded CVEs are caused by CWE-297; none are currently in CISA's KEV catalog of actively exploited flaws.

Primary source: [MITRE CWE](https://cwe.mitre.org/data/definitions/297.html)

---

Source: [RadicalNotion.AI](https://radicalnotion.ai/cwe/cwe-297). Licensed CC BY-NC 4.0; attribute RadicalNotion.AI and link the source page when you reuse this data.
