Overview

This test checks whether an Android app uses SSLSocket without a HostnameVerifier, allowing connections to servers presenting certificates with wrong or invalid hostnames.

By default, SSLSocket does not perform hostname verification. To enforce it, the app must explicitly invoke HostnameVerifier.verify() and implement proper checks.

Such unsafe implementations can allow an attacker to run a [MITM attack](../../../Document/0x04f-Testing-Network-Communication.md#intercepting-network-traffic-through-mitm) with a valid (or self-signed) certificate and intercept or tamper with the app's traffic.

Note: The connection succeeds even if the app has a fully secure Network Security Configuration (NSC) in place because SSLSocket is not affected by it.

Steps

  1. Use MASTG-TECH-0013 to reverse engineer the app.
  2. Use MASTG-TECH-0014 to look for the relevant APIs.

Observation

The output should contain a list of locations where SSLSocket and HostnameVerifier are used.

Evaluation

The test case fails if the app uses SSLSocket without a HostnameVerifier.

Note

If a HostnameVerifier is present, ensure it's not implemented in an unsafe manner. See MASTG-TEST-0283 for guidance.