• Sounthiraraj, et al. [5] statically analyzed 23,418 apps from the Google Play Store to
similarly search for TrustManager and HostnameVerifier issues, finding 1,453
potentially vulnerable apps. They applied dynamic analysis to those apps and confirmed
726 to be vulnerable to MITM attacks.
• FireEye [6] reviewed “the 1,000 most-downloaded free apps in the Google Play Store as
of July 17, 2014.” They found that of the 614 apps that use SSL/TLS to communicate
with a remote server, 448 use TrustManagers that do not properly check certificates,
and 50 use HostnameVerifiers that do not properly check hostnames.
• Montelibano and Dormann [7] dynamically analyzed 1,000,500 Android apps using the
CERT Tapioca tool, finding TLS-related vulnerabilities in 23,667 of the apps.
Additionally, as described by Grace et al. [8], network communications are in some cases used
by apps to dynamically download new code for the app to execute. Grace et al., found this
behavior in advertising libraries embedded into mobile apps, meaning that the app developer
may not even be aware of the functionality and its potential security impact. Successful MITM
attacks could provide remote code execution ability, as demonstrated by Ryan Welton of
NowSecure against a keyboard app running with system-level privileges on many Samsung
devices [9].
Android’s standard TLS library uses implementations of the X509TrustManager Java class
to perform certificate validation. By default, an OS-provided X509TrustManager class is
used, but apps have the ability to define and use their own X509TrustManager.
For example, app developers commonly, and legitimately, provide their own
X509TrustManager to implement certificate pinning. Certificate pinning is the practice of
defining a restricted list of trusted certificate authorities (CAs) for the app’s network connections
rather than trusting all of the CAs in the default Android trust store. While this can prevent
MITM attacks due to malicious certificates issued by rogue or compromised CAs, the risk of
implementation mistakes increases when developers provide their own X509TrustManager
instead of using the platform default implementation.
Similarly, Android’s standard TLS library uses implementations of the HostnameVerifier
Java class to ensure that the hostname asserted by the other endpoint’s X.509 certificate matches
the expected value. By default, an OS-provided HostnameVerifier is used, but apps have
the ability to define and use their own HostnameVerifier. Just as with
X509TrustManager, the risk of implementation mistakes increases when developers provide
their own HostnameVerifier implementation rather than use the platform default
To guard against the use of X509TrustManager and HostnameVerifier
implementations that bypass the desired security checks, we wrote 4 lint checks targeting trust
management functionality. We wrote a lint check that identifies insecure X509TrustManager
implementations whose checkServerTrusted or checkClientTrusted methods do
nothing, thus causing any presented certificate chain to be trusted [10]. Acting on the suggestion
of a Google engineer who reviewed our lint checks, we additionally also wrote a lint check for
use of SSLCertificateSocketFactory.getInsecure(), which returns an
SSLSocketFactory with certificate checks disabled [11]. We wrote a lint check that
identifies insecure HostnameVerifier implementations whose verify method always returns
true, thus trusting any hostname and making the connection susceptible to MITM attacks [12].