MASTG-TEST-0242: Missing Certificate Pinning in Network Security Configuration
Overview¶
Apps can configure certificate pinning using the Network Security Configuration (NSC), see Certificate Pinning. For each domain, one or multiple digests can be pinned.
This test checks whether the app configures certificate pinning in the NSC for the relevant first-party domains it connects to. Relevant domains are remote endpoints under the developer's control that support the app's core or security-sensitive functionality. Third-party domains outside the developer's control should not be reported as missing pins only because they appear in app traffic. Note that the app may implement certificate pinning through other mechanisms covered in other tests.
Steps¶
- Use Reverse Engineering Android Apps to reverse engineer the app.
- Use Obtaining Information from the AndroidManifest to obtain the AndroidManifest.xml
- Use Analyzing the AndroidManifest to check if a
networkSecurityConfigis set in the<application>tag. - Use Analyzing the Network Security Configuration to extract all domains from
<domain-config>that have a pin set (<pin-set>) from the Network Security Configuration file. - Use Information Gathering - Network Communication to identify the first-party domains the app connects to.
Observation¶
The output should contain a list of domains that enable certificate pinning. The output should also identify any relevant first-party domains that were found in the app but do not have a pin set.
Evaluation¶
The test case fails if the app connects to relevant first-party domains but no networkSecurityConfig is set, or if networkSecurityConfig is set but does not enable certificate pinning for those domains.
The test case should not fail only because unrelated third-party domains are not pinned.
If another certificate pinning implementation is identified for the same domains, such as a custom TrustManager or a third-party library, the result should be treated as not covered by NSC pinning rather than as a confirmed absence of certificate pinning.
Further Validation Required:
Before reporting a missing pin, confirm that the app actually establishes connections to the relevant first-party domains:
- Statically, follow the data references from the hardcoded URLs to the code that initiates the network connections ( Reviewing Decompiled Java Code).
- Dynamically, capture and analyze the network traffic ( Setting Up an Interception Proxy) or hook the relevant network APIs at runtime to log the domains the app connects to.
Determining which domains are first-party and security-relevant typically requires information that is not present in the app binary and may require contact with the developers.