Skip to content
Crypto Write-up Intermediate

Finding Insecure TrustManagers and Disabled Hostname Verification with CodeQL

Java applications used insecure TrustManager implementations that accepted any certificate and HostnameVerifier implementations that always returned true, so TLS connections would succeed even when the certificate was not signed by a trusted CA or did not match the server hostname. An attacker able to intercept traffic could therefore present a forged certificate and read or modify the connection without the client noticing.

intrigus Follow

Published on intrigus.org

In this post, I want to show how I found five vulnerabilities in usage of the Java TrustManager and HostnameVerifier classes.

intrigus (@intrigus_), on intrigus.org

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the application code deliberately or accidentally replaced the default certificate and hostname checks with implementations that never reject anything, often for testing convenience.

Impact

An attacker who can intercept the connection could impersonate the server with a forged certificate and read or alter the traffic, because the client accepts any certificate and any hostname.

What the attacker needed

Attacker can intercept network traffic; app uses a custom insecure TrustManager; app uses an all-accepting HostnameVerifier

The fix

Applications should use the platform's default TrustManager and HostnameVerifier, or any custom implementation must actually reject certificates that are not signed by a trusted CA or that do not match the hostname.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

When your browser or app connects to a website over HTTPS, it checks two things: that the site's certificate was signed by someone it trusts, and that the certificate actually belongs to the site's name. If an app is written to skip those checks, anyone who can sit between the app and the server can pretend to be the server. This post describes a tool that scans Java code for that mistake and found five real cases.

What is Crypto?

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.

Similar reports

View all

Same bug class and techniques, clearest first.

Cryptographic weaknesses

The lesson behind this report.

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.