MASTG-DEMO-0148: Missing Certificate Pinning in ATS
Download MASTG-DEMO-0148 IPA Open MASTG-DEMO-0148 Folder Build MASTG-DEMO-0148 IPA
Sample¶
The sample below shows an app that makes HTTPS connections to three domains via URLSession.
sha256.badssl.comandrsa2048.badssl.com, which are pinned through ATSNSPinnedDomains.example.com, which is not pinned.
In this demo, example.com represents the app's own backend. In a real app, this would be the actual first-party domain used for core functionality, such as api.myapp.com.
This distinction is central to the evaluation. Certificate pinning should be assessed for domains that belong to the app and are controlled by its developer, such as first-party backend or server-side API domains. Domains outside the developer's control should not be pinned, because their certificates and key rotation are managed by someone else.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | |
Steps¶
- Extract the app ( Exploring the App Package) and locate the
Info.plistfile inside the app bundle (which we'll nameInfo_reversed.plist). - Convert the
Info.plistto a JSON format ( Convert Plist Files to JSON). - Extract the
NSPinnedDomainsconfiguration fromNSAppTransportSecurity. - Use rabin2 to extract HTTP URLs from the app binary and compare them against the pinned domains.
| run.sh | |
|---|---|
1 2 3 4 5 6 7 8 9 10 11 | |
Observation¶
The output shows the whole NSPinnedDomains configuration:
| ats_pinned_domains.json | |
|---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | |
The output from rabin2 shows that the app contains hardcoded URLs for all three domains:
| output.txt | |
|---|---|
1 2 3 | |
Evaluation¶
The test case fails because the app connects to its own backend, represented in this demo by example.com, but that domain has no entry under NSPinnedDomains.
Only sha256.badssl.com and rsa2048.badssl.com are pinned. As a result, connections to the app-controlled backend rely only on the system CA trust store and are not protected by ATS certificate pinning against a MITM attacker who can cause the device to trust a forged or misissued certificate.