HostnameVerifier Accepts All
This HostnameVerifier unconditionally returns true, so the certificate's hostname is never checked and a valid certificate for any host is accepted (CWE-295).
Standards mapping
- OWASP ASVS
- V9.2.1 (L2)
Vulnerable vs. safe
public boolean verify(String hostname, SSLSession session) { return true; }public boolean verify(String hostname, SSLSession session) { return defaultHv.verify(hostname, session); }Why it matters & how to fix it
This HostnameVerifier unconditionally returns true, so the certificate's hostname is never checked and a valid certificate for any host is accepted (CWE-295). Combined with TLS this permits man-in-the-middle. Remove the override and rely on the default hostname verification, or implement a check that actually compares the requested host to the certificate.
References
Rule ID integsec-java-hostnameverifier-accepts-all - engine: Opengrep - license: MIT - Copyright (c) IntegSec Inc.
TurboPentest runs this check automatically
Connect a GitHub repo and this check runs on every white-box pentest - AI-validated and reported with proof, from $99 per target.
Start a pentestRelated checks
- JavaScript / TypeScript - Other Security ChecksChild Process Shell True
- JavaScript / TypeScript - Other Security ChecksOpen Redirect Tainted Input
- Python - Other Security ChecksDjango Mark Safe
- Python - Other Security ChecksFlask Debug Enabled
- Python - Other Security ChecksFlask Render Template String
- Python - Other Security ChecksInsecure Tempfile Mktemp