CWE-297: Improper Validation of Certificate with Host Mismatch

What is CWE-297?

CWE-297 is Improper Validation of Certificate with Host Mismatch. The flaw arises when 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. The database currently holds 46 vulnerabilities mapped to CWE-297 and none of them are in the CISA Known Exploited Vulnerabilities catalog.

OWASP TOP 10:2025 RANK7 — A07:2025 — Authentication Failures
Related CVES (365 days)46
AbstractionVariant
Likelihood of exploitHigh

Vulnerabilities mapped to CWE-297

46 vulnerabilities1050% increase year over year

No data

No vulnerability data in CISA KEV for CWE-297

Official definition

ByMitre CWE

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.

Characteristics

Modes of introduction

  • 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.

Common consequences

ImpactScopeExplanation
Gain Privileges or Assume IdentityAccess ControlThe data read from the system vouched for by the certificate may not be from the expected system.
OtherAuthentication, OtherTrust afforded to the system in question - based on the malicious certificate - may allow for spoofing or redirection attacks.
Gain Privileges or Assume Identity, OtherAccess Control, OtherIf 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.

Risk mitigations

  1. Architecture and DesignIn 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.
  2. ImplementationIf certificate pinning is being used, ensure that all relevant properties of the certificate are fully validated before the certificate is pinned, including the hostname.
  3. ImplementationBe 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

MethodApproachEffectiveness
Automated Static AnalysisAutomated 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.)High
Dynamic Analysis with Manual Results InterpretationSet 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 BoxWhen 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.-

Representative vulnerabilities

Below are representative vulnerabilities related to this CWE, prioritized by severity.

Sources (2)

CWE™ Program, operated by The MITRE Corporation. Copyright © 2006–2026, The MITRE Corporation. The MITRE Corporation hereby grants you a non-exclusive, royalty-free license to use CWE for research, development, and commercial purposes. CWE Terms of Use.

Learn more

Run an in-depth assessment with complete web risk management

CyStack VulnScan continuously discovers assets, validates vulnerabilities, and helps security teams prioritize remediation across the organization.