Detect Certificate Pinning in an iOS App
Certificate pinning decides which certificates the app accepts. A pinned app blocks an intercepting proxy. This page describes how to detect the pinning from the binary file alone, without a jailbroken device and without a man in the middle.
Run the scan
bash scripts/find-api-calls.sh app.ipa --pins
The pinning APIs
| Pattern | Meaning |
|---|---|
SecTrustEvaluate | A custom trust evaluation |
SecTrustSetAnchorCertificates | A custom anchor list |
SecCertificateCopyData | A certificate comparison in the code |
ServerTrustPolicy | The Alamofire server trust manager |
AFSecurityPolicy | The Alamofire security policy |
TrustKit | The TrustKit library |
pinnedCertificat | A custom pinning implementation |
sha256/ | A public key pin |
NSURLAuthenticationChallenge | A delegate that receives a challenge |
didReceive.*challenge | A delegate method for a challenge |
The pinned host list
A list of pinned hosts is a strong signal. The list names the first-party hosts of the app. The list also shows the environments, for example api.example.com and staging-api.example.com.
Read the string dump of the teardown and look for the host names next to the pin markers.
grep -rn 'sha256/\|pinned\|TrustKit' app-teardown/report/18-strings-main.txt
The absence of the evidence
The absence of a pattern does not prove the absence of the pinning. The pinning can live in a static framework. The app can use the system trust policy. The app can pin at the network layer with a custom URLProtocol.
Always report the posture honestly. Report what the binary shows, and report the limit of the method.
The App Transport Security posture
Pinning and the TLS policy are two different controls. Read both.
bash scripts/find-api-calls.sh app.ipa --ats
| Value | Meaning |
|---|---|
| The key is absent | The app uses the standard TLS policy |
NSAllowsArbitraryLoads is true | The app can use plain HTTP. This is a finding. |
NSExceptionDomains | The app allows plain HTTP for the listed domains |
The findings to report
- The pinning mechanism that the binary uses.
- The pinned host list, when the binary holds one.
- The domains that use clear text HTTP.
- The domains that the app calls without any pinning.
- The secrets that ship inside the binary.