CWE-297 — Improper Validation of Certificate with Host Mismatch
CWE-297: Improper Validation of Certificate with Host Mismatch
MITRE CWE weakness
| Kind | Weakness |
| Abstraction | Variant |
| Status | Incomplete |
| Likelihood of exploit | High |
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. In order to ensure data integrity, the certificate must be valid, and it must pertain to the site that is being accessed. Even if the product attempts to check the hostname, 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.
Common consequences
- Access Control: Gain Privileges or Assume Identity
- Authentication, Other: Other
- Access Control, Other: Gain Privileges or Assume Identity, Other
Mitigations
Architecture and Design — 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.
References
- CWE page: https://cwe.mitre.org/data/definitions/297.html
- CWE list: https://cwe.mitre.org/data/index.html