Ssl Pinning
AI Generated Summary
AI Generated Content Disclaimer
Note: This summary is AI-generated and may contain inaccuracies, errors, or omissions. If you spot any issues, please contact the site owner for corrections. Errors or omissions are unintended.
The presentation on SSL Pinning and Bypasses for Android and iOS argues that PKI is broken, positions certificate pinning as another layer to achieve secure communication with special protection against man-in-the-middle attacks, demonstrates pinning implementations on both platforms, and then shows how to bypass them, using the Xposed Framework with JustTrustMe on Android and ssl-kill-switch2 on iOS.
Summary
The deck opens by explaining how MITM interception works: add the root CA of an interception proxy to the browser, divert traffic through the proxy so it handles the SSL connection on both legs (client to proxy over HTTPS, proxy to server over HTTPS), and the browser validates that the certificate is issued by a trusted CA and allows the connection. The case for pinning rests on six claims about broken PKI: the system trusts every CA in the trust store, including the PortSwigger CA; the system trusts root CAs rather than the certification chain; any CA can issue a certificate for any website, as Diginotar, Trustwave, and NIC incidents showed; a stolen certificate leads to revocation hell and the CRL nightmare; OCSP attempts a rescue but runs over port 80; and there are many more.
The recommended fix is to pin trust on your own certification chain and validate it at the client side. The catch is real: new certificates from a different service provider, changed certificate chains, revocation, theft, or malicious clients all raise questions, and the answer is that you need to update the code every time the certificate changes, which the deck waves off as easy, push an update. The value proposition splits by audience: for developers, pinning hinders attackers from intercepting traffic and adds another layer for them to look for, and without rooting devices it is nearly impossible to bypass so far; for pentesters, it hinders application inspection, with a bypasses section coming.
On Android, pinning can be implemented multiple ways: store the certificate in SQLite and use it directly, store SHA1 hashes and compare, or store the SHA1 hash of one element in the chain and compare. The demo uses the OkHttp helper library by Square, which pins SHA1 hashes of the entire chain or a set of elements in it. The bypass demo follows, and the explanation is that the Xposed Framework hooks into all function calls, and whenever a request is made for the check function inside the com.squareup.okhttp.CertificatePinner class, it returns true, referencing the JustTrustMe pull request that implements it.
On iOS, pinning is done through third-party helpers like SwiftHTTP or TrustKit, or directly via SecTrustEvaluate through NSURLConnectionDelegate, with the helpers being wrappers around that approach. The bypass tools are the original ios-ssl-kill-switch by iSEC Partners and its successor ssl-kill-switch2 by nabla-c0d3, which supersedes the original, works on iOS 9.0.2, and does not affect iTunes or the App Store by default. The mechanism leverages Cydia Substrate, uses MobileSubstrate to inject into processes, and hooks the Secure Transport API instead of SecTrustEvaluate or NSURL, because the Secure Transport API is the lowest-level TLS implementation on iOS. Three patches are applied: SSLCreateContext is patched to disable the built-in certificate validation in all SSL contexts, SSLSetSessionOption is patched to remove the ability to re-enable that validation, and SSLHandshake is patched to force a trust-all custom certificate validation.
Key Themes
- MITM mechanics: an interception proxy with its root CA in the trust store terminates both HTTPS legs and passes browser validation because the CA is trusted.
- Broken PKI: indiscriminate trust-store trust, root-only validation, CA mis-issuance (Diginotar, Trustwave, NIC), and the revocation and CRL mess after certificate theft.
- OCSP’s weakness: the rescue protocol runs over port 80, undermining the guarantee it is meant to provide.
- Pinning as a defense: pin trust on your own certification chain and validate client-side instead of deferring to the device trust store.
- Android implementations: SQLite-stored certificates, SHA1 hash comparison, or pinning a single chain element, demonstrated with OkHttp by Square.
- Android bypass: Xposed hooks force the CertificatePinner check function to return true, implemented by JustTrustMe.
- iOS implementations: SwiftHTTP and TrustKit helpers, or SecTrustEvaluate via NSURLConnectionDelegate underneath.
- iOS bypass: ssl-kill-switch2 injects via MobileSubstrate and patches the Secure Transport API at its lowest level, disabling validation and forcing trust-all handshakes.
- Trade-offs: every certificate change forces a code update, but mobile update channels make that tolerable.
Notable Points
- MITM setup: add the interception proxy’s root CA, then route traffic as client HTTPS to proxy and proxy HTTPS to server.
- The system trusts all CAs in the trust store, including PortSwigger CA, and validates root CAs rather than the certification chain.
- CA mis-issuance examples: Diginotar, Trustwave, and NIC, showing any CA can issue a certificate to any website.
- Android pinning options: certificate in SQLite, SHA1 hashes compared, or SHA1 of one element in the chain compared.
- The Android demo pins with okhttp by Square, covering SHA1 hashes of the entire chain or a set of elements in it.
- The Android bypass hooks
com.squareup.okhttp.CertificatePinner’s check function to return true, via Xposed and JustTrustMe (referenced pull: Fuzion24/JustTrustMe #12). - iOS pinning helpers: SwiftHTTP and TrustKit, both wrappers over SecTrustEvaluate through NSURLConnectionDelegate.
- iOS bypass tools: iSECPartners/ios-ssl-kill-switch and nabla-c0d3/ssl-kill-switch2, which works on iOS 9.0.2 but not against iTunes/App Store by default.
- The iOS bypass hooks Secure Transport API because it is the lowest-level TLS implementation on iOS.
- Three iOS patches: SSLCreateContext disables built-in certificate validation, SSLSetSessionOption removes re-enabling of validation, SSLHandshake forces trust-all custom validation.
- Any certificate change (new provider, chain change, revocation, theft) requires an application code update.
- References include the OWASP Certificate and Public Key Pinning page, square/okhttp, Fuzion24/JustTrustMe, daltoniam/SwiftHTTP, and datatheorem/TrustKit.
Notable Quotes
“Another layer to achieve secure communication specially protection against MiTM”
“PKI IS BROKEN”
“Certificate Stolen: Welcome to Revocation hell and CRL Nightmare”
“OCSP to the rescue over port 80”
“Pin Trust on our own certification chain and validate it at Client Side”
“You need to update the code everytime certificate changes”
“ITS EASY PUSH AN UPDATE”
“Without Rooting devices its nearly imposible to bypass it so far.”

























