Okay folks, let's talk about bypassing #SSLPinning in #Android applications.

It's going to be a bit long Twitter 🧵
First, let's talk about SSL Pinning.

It's "pinning" some content of your website's public SSL certificate to your Android app.

It can be hash from your leaf cert, intermediate CA or even root CA.
SSL Pinning makes sure that the your Android app is talking to your server over HTTPS.

If you pin the hash of leaf cert, it mitigates your app connecting to any other HTTPS server whose SSL cert is issued by a CA that the device trusts.
The SSL "pinned" Android app works fine, till the SSL certificate expires. 😱

That's the reason Android docs don't recommend to implement SSL pinning in your apps.

developer.android.com/training/artic…
But wait, at the same time MASVS recommends SSL pinning as an additional defense-in-depth measure.

(Check MSTG-NETWORK-4)

github.com/OWASP/owasp-ma…
So, if you are pentesting an Android app, which contains sensitive PII, payment info, etc you might come across SSL Pinning.

Bypassing it would be the first step to look at the HTTP calls being made to the target server.
Let's try to bypass it step by step.

Note: Don't think you have to follow all steps to bypass SSL pinning.

The steps are set in increasing order of difficulty (to setup tools & bypass) - first being the easiest and last being the most time consuming & difficult.
1. Using a Lower Version of Android

This is easiest way. Try running the app on Android M (API level 23) or below.

If the SSL pinning is implemented using Network Security Config file, the pinning will not work in lower version.

If this doesn't work go to 2nd step, so on.
2. Modification of Network Security Config (NSC) File

Some Android apps use NSC file to implement SSL pinning and don't allow the app to execute on lower Android versions (like API level >=23).

In such case decompile the apk, modify NSC file and rebuild the apk.
3. JustTrustMe Xposed Module

If recompiling didn't work (maybe because its an app bundle/has tamper protection,etc), then install app on Android emulator/device (with root permissions).

Install Xposed framework and JustTrustMe module. Activate it and start using target app.
4. Objection

Use objection tool to "patch" the Android app.

It also gives option to bypass SSL pinning (and a bunch of other useful stuff).

Note: Setting up Objection can be a bit tedious process. But it's one time task.
5. Frida Gadget

You can patch the app with Frida Gadget manually or using Objection.

Install the patched app and run frida-multiple-unpinning bypass script.

codeshare.frida.re/@akabe1/frida-…
6. Frida

If patching an apk is hard, you can try setting up Frida server on a rooted Android device/emulator.

Then use the above frida-multiple-unpinning script to bypass SSL pinning.

You might also have to bypass Android app's root detection in this method (if any).
7. Taint Analysis using Frida

If none of the above steps worked, then taint analysis is the only way forward.

Decompile app, manually check SSL pinning logic and create a custom Frida script to bypass SSL pinning.

This is a time consuming process & involves trial and error.
If you have made it this far, then checkout "Ultimate Guide To Android SSL Pinning Bypass"

It contains details on:
- what's SSL pinning
- what's not SSL pinning
- hows it implemented
- how to bypass it
- commands, screenshots and much more...

redhuntlabs.com/ultimate-guide…

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Chandrapal Badshah

Chandrapal Badshah Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @bnchandrapal

5 Oct 20
Wow ! @Cloudflare introduces API Shield to protect your APIs

blog.cloudflare.com/introducing-ap…

How does it do ?

By adding mTLS for the API endpoints and enforcing schema validation in JSON / gRPC payloads in API POST requests

Will it really secure / help secure APIs ?

[thread] 1/n
Reading the article, Cloudflare claims to "secure" your APIs with the help of mTLS.

To simply put, mTLS is when both entities (server and client) validate each other's SSL cert and make sure its signed by common trusted Root / Intermediate CA.

2/n
mTLS requires your own PKI and things get tricky when you want to revoke a issued cert, manage access to root CA, etc. But in this case Cloudflare manages for you.

3/n
Read 7 tweets
17 Apr 20
How we monitor secrets committed in our self hosted @gitlab instance in real time ?

(Twitter thread which summarises multiple experiments)

#ProductSecurity #gitlab #security
Use Pre-commit / Pre-receive / Post-receive git hooks ?

Pre-commit : scan for secrets before commit. Prevents committing secrets by devs

Problem: requires access to dev laptops (privacy issue?). Hard to manage regexes in their laptop. Harder in a company hiring lots of devs
Pre-receive : scan for secrets before commits are saved in Gitlab. If secrets found reject. Easy to manage server controls.

Problem: If a person commits secret to code, server rejects push. The person requires (advanced) git skills to remove secret from git history
Read 15 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!

Follow Us on Twitter!

:(