CWE Glossary
- CWE-22: Path Traversal
- CWE-78: OS Command Injection
- CWE-79: Cross-Site Scripting
- CWE-89: SQL Injection
- CWE-90: LDAP Injection
- CWE-91: XML Injection
- CWE-94: Code Injection
- CWE-98: PHP File Inclusion
- CWE-113: HTTP Response Splitting
- CWE-119: Buffer Errors
- CWE-130: Improper Handling of Length Parameter Inconsistency
- CWE-193: Off-by-one Error
- CWE-200: Information Exposure
- CWE-211: Information Exposure Through Externally-Generated Error Message
- CWE-236: Improper Handling of Undefined Parameters
- CWE-276: Incorrect Default Permissions
- CWE-284: Improper Access Control
- CWE-285: Improper Authorization
- CWE-287: Improper Authentication
- CWE-297: Improper Validation of Certificate with Host Mismatch
- CWE-306: Missing Authentication for Critical Function
- CWE-312: Cleartext Storage of Sensitive Information
- CWE-345: Insufficient Verification of Data Authenticity
- CWE-352: Cross-Site Request Forgery
- CWE-384: Session Fixation
- CWE-427: Uncontrolled Search Path Element
- CWE-434: Unrestricted Upload of File with Dangerous Type
- CWE-476: NULL Pointer Dereference
- CWE-521: Weak Password Requirements
- CWE-601: Open Redirect
- CWE-611: Improper Restriction of XML External Entity Reference ('XXE')
- CWE-613: Insufficient Session Expiration
- CWE-618: Exposed Unsafe ActiveX Method
- CWE-671: Lack of Administrator Control over Security
- CWE-798: Use of Hard-coded Credentials
- CWE-799: Improper Control of Interaction Frequency
- CWE-822: Untrusted Pointer Dereference
- CWE-835: Infinite Loop
- CWE-918: Server-Side Request Forgery (SSRF)
- CWE-942: Overly Permissive Cross-domain Whitelist
CWE is a trademark of the MITRE Corporation.
Improper Validation of Certificate with Host Mismatch [CWE-297]
This weakness describes Improper Validation of Certificate with Host Mismatch.
Created: June 11, 2018
Latest Update: December 28, 2020
Table of Content
Want to have an in-depth understanding of all modern aspects of Improper Validation of Certificate with Host Mismatch [CWE-297]? Read carefully this article and bookmark it to get back later, we regularly update this page.
1. Description
The primary concept of SSL/TLS security is a trust built between the two parties of intercommunication process: the client and the server, where each party has proven its identity. Inability to establish trust relationship due to skipping all necessary verification steps jeopardizes security of entire client-server communication and introduces an opportunity for the attacker to perform a Man-in-the-Middle (MitM) attack. As a result, the attacker is able to decrypt and modify all data, transferred via supposedly encrypted channel.
Improper verification of certificate with host mismatch is a weakness, related to how software treats digital certificate, issued for another domain. E.g. the application is trying to establish secure communication with www.example.com website, however the web server returns a certificated issued for www.example.net domain. This certificated can be valid and signed with a trusted CA, but it still should be rejected by the client application.
This vulnerability is common for mobile applications. Developers often disable certificate verification for testing purposes and do not activate it for production deployment.
Below is an example of code that creates HostnameVerifier and disables hostname verification:
- final static HostnameVerifier NO_VERIFY = new HostnameVerifier() {
- public boolean verify(String hostname, SSLSession session) {
- return true;
- }
- };
- ...
- HostnameVerifier NO_VERIFY = org.apache.http.conn.ssl.SSLSocketFactory
- .ALLOW_ALL_HOSTNAME_VERIFIER;
2. Potential impact
The attacker can perform MitM attack and intercept all communication between your application and the server. Which means that all data transferred via this connection can be decrypted and modified. In case of a banking app, for example, the attacker might be able to gain full access to victim’s banking account.
3. Attack patterns
There are no CAPEC patterns relate to this weakness.
4. Affected software
Any software that acts as SSL/TLS client and handles SSL certificates is a potential subject to this issue. Before deploying the software make sure that your SSL/TLS communication settings are not compromised.
5. Mitigations
To resolve this vulnerability it is enough to turn back on hostname verification. When developing application intended for SSL communication try not to use self-signed or untrusted certificates as it may introduce security-related issues in production version of your application.
6. References
- CWE-297: Improper Validation of Certificate with Host Mismatch [cwe.mitre.org]
- Android Network APIs [github.com]
Copyright Disclaimer: Any above-mentioned content can be copied and used for non-commercial purposes only if proper credit to ImmuniWeb is given.
↑ Back to Top