SSL Pinning and Bypass
To audit a mobile app you need to see its traffic with the backend: that’s where the API, tokens, and real logic live. The usual approach is to put a proxy (Burp) between the app and the server. But many apps implement SSL/certificate pinning: they trust only a specific certificate or public key, rejecting your proxy’s even if you install its CA. Bypassing pinning is an almost-mandatory step in mobile pentesting to intercept and manipulate traffic.
sequenceDiagram
participant App
participant Proxy as Burp (MITM)
participant API as Backend
App->>Proxy: TLS ClientHello
Proxy-->>App: Proxy certificate
Note over App: Compares against the pinned value
alt Pin does not match
App--xProxy: Drops the connection
else Pinning bypassed (Frida)
App->>Proxy: Continues the handshake
Proxy->>API: Forwards (traffic visible)
end
Threat model
Section titled “Threat model”Pinning defends against a network MITM (open WiFi, malicious carrier, compromised CA). But in pentesting the attacker controls the device, and there pinning is just an obstacle, not a barrier:
- Network MITM (defends well): without the pin’s private key, a network attacker can’t intercept.
- Controlled device (no defence): with root/jailbreak or a gadget, the validation is rewritten at runtime and the pin stops mattering.
The goal of the bypass is to turn the app into just another client of its API so you can audit the backend, where the real security lives.
Intercepting traffic (the basics, no pinning)
Section titled “Intercepting traffic (the basics, no pinning)”# 1. Configure Burp/ZAP as a proxy (host IP, port 8080)# 2. On the device: WiFi -> manual proxy pointing to Burp# 3. Install Burp's CA as trusted# Android 7+: apps do NOT trust user CAs by default# -> system CA (root) or the app's networkSecurityConfig# iOS: install the CA profile and enable "Full trust" in SettingsOn Android 7+, even if you install the CA as a user cert, apps trust only system CAs by default → you need root (install the CA in the system store) or modify the app’s network_security_config.xml via repackaging.
What pinning is and why it blocks
Section titled “What pinning is and why it blocks”Pinning “fixes” in the app the server’s certificate, its public key (SPKI), or its hash. On connect, the app compares what the server presents against the pin; if it doesn’t match (like your proxy’s certificate), it drops. Typical libraries: OkHttp CertificatePinner, TrustKit, a custom X509TrustManager, or native pinning inside a .so.
Bypassing SSL pinning
Section titled “Bypassing SSL pinning”Objection / Frida (the fastest)
Section titled “Objection / Frida (the fastest)”# Objection: disable pinning with one commandobjection -g com.target.app exploreandroid sslpinning disable # (or: ios sslpinning disable)# Frida: universal bypass scripts on app spawnfrida -U -f com.target.app -l frida-multiple-unpinning.js --no-pauseThe frida-interception-and-unpinning pack (httptoolkit) and the classic universal unpinning cover the most common pinning libraries (OkHttp, TrustKit, Conscrypt, etc.) in one go.
Repackaging (no root / no runtime Frida)
Section titled “Repackaging (no root / no runtime Frida)”# Android: decompile, trust user CAs, and recompileapktool d app.apk -o out/# edit out/res/xml/network_security_config.xml to add user <trust-anchors>apktool b out/ -o patched.apk# sign the modified APKapksigner sign --ks my.keystore patched.apkAlternative: inject the Frida gadget with objection patchapk --source app.apk.
Native pinning (in .so)
Section titled “Native pinning (in .so)”When the validation lives in native code, you hook the SSL library function with Frida (e.g. SSL_CTX_set_custom_verify/SSL_get_verify_result from BoringSSL in OkHttp) to force verification to pass:
// force BoringSSL's certificate verification to return OK (0)const f = Module.getExportByName("libssl.so", "SSL_get_verify_result");Interceptor.replace(f, new NativeCallback(() => 0, "int", ["pointer"]));After bypassing pinning
Section titled “After bypassing pinning”With the traffic visible in Burp, the app becomes just another client of its API → the whole Web section applies: authentication (Authentication), IDOR/BOLA (IDOR), injection, business logic, and the API Top 10 (API Security). The backend is the real target. For the TLS fundamentals, see TLS.
Red Team
Section titled “Red Team”# full interception flow# 1) proxy + CA ready; 2) check for pinning (connection fails)# 3) bypass via Objection or a Frida scriptobjection -g com.target.app explore -s "android sslpinning disable"# 4) if Frida isn't viable -> repackaging# 5) traffic visible -> audit the API like a web appBlue Team
Section titled “Blue Team”- Pinning is defence in depth, not absolute: a device-equipped attacker bypasses it with Frida. Useful against network MITM, not against an analyst with the handset in hand.
- Real security lives in the backend: server-side authentication, authorization, and validation; don’t trust the client.
- Combine with MASVS-RESILIENCE (Frida/instrumentation detection, code integrity) to raise the bypass cost.
- Pin the public key (SPKI) rather than a specific certificate, so rotations don’t break; set a backup pin and plan the update before expiry.
Checklist
Section titled “Checklist”- Configure proxy (Burp) + CA on the device
- Android 7+: system CA (root) or
network_security_config - Does the app pin? (connection fails with the proxy)
- Bypass with Objection (
sslpinning disable) - Bypass with a universal Frida script (multiple-unpinning)
- Repackaging if Frida isn’t viable
- Native pinning (
.so): hook the SSL library - Traffic visible → audit the API (API Security)