To protect against Man-in-the-Middle (MitM) attacks in mobile, you need robust end-to-end security that includes certificate pinning as part of a broader solution which eliminates on-device threats and allows fast and easy pin rotation. See this blog for a short overview of the MitM issue in mobile.
There are however some myths out there about how to best address MitM so this blog addresses those directly and lays out the steps to achieving the “best” protection for your apps.
Developers often say “We use HTTPS for all API traffic, so we’re safe from MitM attacks.”
Unfortunately, that’s a myth: TLS can be bypassed:
MITM on mobile is still a top attack vector, whether or not you use TLS —just ask any security tester.
Many developers believe pinning should be avoided because “Google and Apple don’t recommend it.” But this is a misunderstanding—what they caution against is static certificate pinning implemented poorly.
It is true that Google’s Android documentation highlights risks with hardcoded pins:
“Pinning can cause apps to break when certificates are rotated or reissued.”
(Source: Android Network Security Config) and Apple also notes: “Pinning can interfere with your ability to update server certificates.” (Source: Apple Security Best Practices)
However these warnings are not against pinning itself, but against:
So it is important not to be confused. Pinning is highly effective, if done properly. The OWASP Mobile Security Testing Guide (MSTG) explicitly recommends certificate pinning as part of defense-in-depth: “Certificate pinning protects mobile apps against MitM attacks in cases where the attacker can compromise a root CA or install their own CA certificate on a device.” See also this OWASP Cheatsheet on pinning.
The issue isn’t pinning—it’s static pinning and the operational headaches that come with it when cert and pin rotation requires app updates.
Since installing tools like Burp Suite or mitmproxy is only possible if you have access to that individual device, the impact is limited? Right? Wrong! This is also a myth: On-Device MitM Enables API Abuse at Scale:
This extends far beyond the single device. Your API is always the final target for attackers, not an individual user or device.
So that brings us to the Good, Better, Best of MitM protection. Except we also added a “Terrible” which we discussed briefly first!
MitM Protection Level |
Pins in App? |
Cert Rotation Friendly? |
Stops Rooted Device MitM? |
Stops API Bots? |
Terrible |
None |
✅ Yes |
❌ No |
❌ No |
Good |
❌ Yes |
❌ No |
❌ No |
❌ No |
Better |
✅ No |
✅ Yes |
✅ Yes |
⚠️ Partial |
Best |
✅ No |
✅ Yes |
✅ Yes |
✅ Yes |
We already discussed the “HTTPS is enough” myth. TLS uses the OS trust store. If a malicious or user-installed CA exists, forged certs will validate. Also, attackers can intercept traffic on compromised devices, and common tools like Burp Suite make this trivial.
“TLS alone is like locking your door but leaving the key under the mat.”
For this, you employ certificate pinning but you hardcode your API server’s public key or cert fingerprint in the app. You can even use Approov’ s free pin generation tool to immediately create pins for your domain.
Unlike static pinning, where the server's certificate or public key is hard-coded into the app during development, dynamic pinning allows the app to fetch and update these trust anchors at runtime:
This does requires a library or SDK (eg Approov SDK) on the device to receive the pins and a secure (cloud) API that provides the latest certificates in a secure format.
This approach combines dynamic pinning with runtime app and device integrity checks. MitM tools running on the device are identified and blocked. In addition, pins and certificates, as well as API secrets (keys, tokens) are only delivered to untampered apps on uncompromised devices thus eliminating the threat of on-device MitM attacks.
Approov, for example, does this in two ways:
For a detailed breakdown of how these options work: consult this Approov Knowledge Base article.
This is defense-in-depth MitM protection for mobile APIs.
Mobile app developers must aim for a solution which implements dynamic pinning integrated with attestation and trust enforcement. This will eliminate the threat of any kind of MitM attack:
This solution is:
And a final thought: Pinning is still essential for mobile API security—just avoid static implementations. With modern dynamic pinning solutions, you get all the benefits of pinning without the operational risks.
Approov are experts in mobile app and API security. We would be happy to discuss this on a call.