Scala Ssl Hostname Verification Bypass
Description
Detects attempts to bypass SSL hostname verification in Scala applications. This vulnerability occurs when applications disable or weaken the verification of SSL certificate hostnames, which could allow attackers to perform man-in-the-middle attacks using invalid certificates.
Detection Strategy
• Check if code imports SSL-related libraries/packages
• Look for method calls that set default hostname verifiers with weak/no validation
• Detect creation of SSL socket factories or hostname verifiers that skip proper certificate validation
• Report vulnerabilities when hostname verification is disabled or uses permissive validation logic
Vulnerable code example
import javax.net.ssl._
import org.apache.http.conn.ssl.NoopHostnameVerifier
class SSLBypass {
def createInsecureConnection() {
// Vulnerable: Disables hostname verification completely
val insecureVerifier = new HostnameVerifier {
override def verify(hostname: String, session: SSLSession): Boolean = true...✅ Secure code example
import javax.net.ssl._
import java.net.URL
class SSLSecure {
def createSecureConnection() {
// Secure: Verify hostnames against allowlist of trusted domains
val allowedHosts = Set("api.example.com", "auth.example.com")
val secureVerifier = new HostnameVerifier {...Search for vulnerabilities in your apps for free with Fluid Attacks' automated security testing! Start your 21-day free trial and discover the benefits of the Continuous Hacking Essential plan. If you prefer the Advanced plan, which includes the expertise of Fluid Attacks' hacking team, fill out this contact form.