--- title: "Flutter" section: "Mobile" sectionSlug: "mobile-pentesting" sourcePath: "src/mobile-pentesting/android-app-pentesting/flutter.md" sourceUrl: "https://github.com/HackTricks-wiki/hacktricks/blob/188de82beb54e70956b2952367a0af91d26758b8/src/mobile-pentesting/android-app-pentesting/flutter.md" sha: "188de82beb54e70956b2952367a0af91d26758b8" isIndex: false modified: true license: "CC-BY-NC-4.0" --- # Flutter Flutter is **Google’s cross-platform UI toolkit** that lets developers write a single Dart code-base which the **Engine** (native C/C++) turns into platform-specific machine code for Android & iOS. The Engine bundles a **Dart VM**, **BoringSSL**, Skia, etc., and ships as the shared library **libflutter.so** (Android) or **Flutter.framework** (iOS). All actual networking (DNS, sockets, TLS) happens **inside this library**, *not* in the usual Java/Kotlin Swift/Obj-C layers. That siloed design is why the usual Java-level Frida hooks fail on Flutter apps. ## Intercepting HTTPS traffic in Flutter This is a summary of this [blog post](https://sensepost.com/blog/2025/intercepting-https-communication-in-flutter-going-full-hardcore-mode-with-frida/).[[1]](#references) ### Why HTTPS interception is tricky in Flutter * **SSL/TLS verification lives two layers down** in BoringSSL, so Java SSL‐pinning bypasses don’t touch it. * **BoringSSL uses its *own* CA store** inside libflutter.so; importing your Burp/ZAP CA into Android’s system store changes nothing. * Symbols in libflutter.so are **stripped & mangled**, hiding the certificate-verification function from dynamic tools. ### Fingerprint the exact Flutter stack When **reFlutter** cannot auto-patch the APK (unsupported engine hash, debug engine, missing `libapp.so`, newer release), avoid guessing offsets and derive the exact Flutter/BoringSSL pair first.[[2]](#references) Step | Command / File | Outcome ----|----|---- Check packaging | `unzip -l app.apk | grep -E "libapp.so|libflutter.so"` | Confirm the target ABI and that both Flutter libraries are really present Get snapshot hash | `python3 get_snapshot_hash.py libapp.so` | Engine snapshot hash (**use `libapp.so`, not `libflutter.so`**) Map hash → Engine | `curl -s https://raw.githubusercontent.com/Impact-I/reFlutter/refs/heads/main/enginehash.csv \| grep <hash>` | Flutter version + engine commit If hash is missing | `python3 gen_enginehash.py` in reFlutter `scripts/` | Fresh local hash table for newer/debug builds Pull dependent commits | Flutter release `DEPS` file | Exact `dart_boringssl_rev` / BoringSSL commit Find [get_snapshot_hash.py here](https://github.com/Impact-I/reFlutter/blob/main/scripts/get_snapshot_hash.py). A bogus hash such as repeated `4` values usually means the script was run against `libflutter.so` instead of `libapp.so`.[[2]](#references)[[3]](#references) ### Target: `ssl_crypto_x509_session_verify_cert_chain()` * Located in **`ssl_x509.cc`** inside BoringSSL. * **Returns `bool`** – a single `true` is enough to bypass the whole certificate chain check. * Same function exists on every CPU arch; only the opcodes differ.[[7]](#references) ### Option A – Binary patching with **reFlutter** 1. **Clone** the exact Engine & Dart sources for the app’s Flutter version. 2. **Regex-patch** two hotspots: * In `ssl_x509.cc`, force `return 1;` * (Optional) In `socket_android.cc`, hard-code a proxy (`"10.0.2.2:8080"`). 3. **Re-compile** libflutter.so, drop it back into the APK/IPA, sign, install. 4. **Pre-patched builds** for common versions are shipped in the reFlutter GitHub releases to save hours of build time.[[3]](#references) ### Option B – Live hooking with **Frida** (the “hard-core” path) Because the symbol is stripped, you pattern-scan the loaded module for its first bytes, then change the return value on the fly. ```javascript // attach & locate libflutter.so var flutter = Process.getModuleByName("libflutter.so"); // x86-64 pattern of the first 16 bytes of ssl_crypto_x509_session_verify_cert_chain var sig = "55 41 57 41 56 41 55 41 54 53 48 83 EC 38 C6 02"; Memory.scan(flutter.base, flutter.size, sig, { onMatch: function (addr) { console.log("[+] found verifier at " + addr); Interceptor.attach(addr, { onLeave: function (retval) { retval.replace(0x1); } // always 'true' }); }, onComplete: function () { console.log("scan done"); } }); ``` Run it: ```bash frida -U -f com.example.app -l bypass.js ``` *Porting tips* * For **arm64-v8a** or **armv7**, grab the first ~32 bytes of the function from Ghidra, convert to a space-separated hex string, and replace `sig`. * Keep **one pattern per Flutter release**, store them in a cheat-sheet for fast reuse. ### Forcing traffic through your proxy Flutter itself **ignores device proxy settings**. Easiest options: * **Android Studio emulator:** Settings ▶ Proxy → manual. * **Physical device:** evil Wi-Fi AP + DNS spoofing, or Magisk module editing `/etc/hosts`. ### Quick Flutter TLS bypass workflow (Frida Codeshare + system CA) When you only need to observe a pinned Flutter API, combining a rooted/writable AVD, a system-trusted proxy CA, and a drop-in Frida script is often faster than reverse-engineering libflutter.so: 1. **Install your proxy CA in the system store.** Follow [Install Burp Certificate](/hacktricks/mobile-pentesting/android-app-pentesting/install-burp-certificate) to hash/rename Burp's DER certificate and push it into `/system/etc/security/cacerts/` (writable `/system` required).[[8]](#references) 2. **Drop a matching `frida-server` binary and run it as root** so it can attach to the Flutter process:[[8]](#references) ```bash adb push frida-server-17.0.5-android-x86_64 /data/local/tmp/frida-server adb shell "su -c 'chmod 755 /data/local/tmp/frida-server && /data/local/tmp/frida-server &'" ``` 3. **Install the host-side tooling and enumerate the target package.**[[8]](#references) ```bash pip3 install frida-tools --break-system-packages adb shell pm list packages -f | grep target ``` 4. **Spawn the Flutter app with the Codeshare hook that neuters BoringSSL pin checks.**[[8]](#references) ```bash frida -U -f com.example.target --codeshare TheDauntless/disable-flutter-tls-v1 --no-pause ``` The Codeshare script overrides the Flutter TLS verifier so every certificate (including Burp's dynamically generated ones) is accepted, side-stepping public-key pin comparisons. 5. **Route traffic through your proxy.** Configure the emulator Wi-Fi proxy GUI or enforce it via `adb shell settings put global http_proxy 10.0.2.2:8080`; if direct routing fails, fall back to `adb reverse tcp:8080 tcp:8080` or a host-only VPN. 6. **If the app ignores OS proxy settings, redirect sockets with a Frida shim.** Tools like **frida4burp** hook `dart:io`/BoringSSL socket creation to force outbound TCP sessions to your proxy, even with hardcoded `HttpClient.findProxyFromEnvironment` or Wi‑Fi bypasses. Set the proxy host/port in the script and run it alongside the TLS bypass:[[9]](#references) ```bash frida -U -f com.example.target --no-pause \ --codeshare TheDauntless/disable-flutter-tls-v1 \ -l frida4burp.js ``` Works on iOS via a Frida gadget or USB frida-server; chaining the socket redirect with the TLS bypass restores both routing and certificate acceptance for Burp/mitmproxy. Once the CA is trusted at the OS layer and Frida quashes Flutter's pinning logic (plus socket redirection if needed), Burp/mitmproxy regains full visibility for API fuzzing (BOLA, token tampering, etc.) without repacking the APK. ### Offset-based hook of BoringSSL verification (no signature scan) When pattern-based scripts fail across architectures (e.g., x86_64 vs ARM), directly hook the BoringSSL chain verifier by absolute address within `libflutter.so`. A reliable workflow is:[[2]](#references) - Extract the right-ABI library from the APK: `unzip -j app.apk "lib/*/libflutter.so" -d libs/` and pick the one matching the device. - Resolve the exact BoringSSL revision from the matching Flutter `DEPS`, fetch `ssl/ssl_x509.cc`, and identify `ssl_crypto_x509_session_verify_cert_chain`. - Use the line number of the `OPENSSL_PUT_ERROR(...)` inside that exact source revision as a **scalar search anchor** in Ghidra. The line number is compiled into the error path, so searching for that constant (for example `239`) is often faster than guessing patterns in a stripped binary. - If the scalar search is noisy, fall back to **Search → For Strings → `ssl_client` → XREFs** and keep only candidates that decompile into a 3-argument function matching `SSL_SESSION *`, `SSL_HANDSHAKE *`, `uint8_t *` semantics.[[4]](#references)[[5]](#references)[[6]](#references) - Compute the runtime offset: `function_address - image_base`. Example: `0x00840950 - 0x00100000 = 0x00740950`. - Hook at runtime by base + offset and force success: ```javascript const module = Process.findModuleByName('libflutter.so'); const addr = module.base.add(ptr('0x00740950')); // recompute per build/arch Interceptor.attach(addr, { onLeave(retval) { retval.replace(0x1); } }); ``` Notes - Signature scans can succeed on ARM but miss on x86_64 because the opcode layout changes; this offset method is architecture-agnostic as long as you recalc the RVA. - If `libflutter.so` is not loaded yet, install the hook after the Android linker resolves it (commonly by watching `linker64` symbols such as `do_dlopen` / `call_constructor` and calling your attach routine once `libflutter.so` appears). - This bypass causes BoringSSL to accept any chain, enabling HTTPS MITM regardless of pins/CA trust inside Flutter. - If you force-route traffic during debugging to confirm TLS blocking, e.g.: ```bash iptables -t nat -A OUTPUT -p tcp -j DNAT --to-destination : ``` …you will still need the hook above, since verification happens inside `libflutter.so`, not Android’s system trust store. ## Reversing the Dart payload (`libapp.so`) ### Quick static triage Before rebuilding `libflutter.so`, spend two minutes identifying what is actually packaged inside the APK: ```bash unzip -l target.apk | grep -E "(libflutter|libapp|flutter_assets|kernel_blob)" unzip -j target.apk "lib/arm64-v8a/libapp.so" "lib/arm64-v8a/libflutter.so" -d extracted_libs/ strings extracted_libs/libflutter.so | grep -E "^[0-9]+\.[0-9]+\.[0-9]+" | head ``` - `libapp.so` is the AOT-compiled Dart payload. - `assets/flutter_assets/` usually contains manifests, JSON/config files, and sometimes secrets or hidden feature flags. - `kernel_blob.bin` is a high-value indicator of a debug/non-release build; if present, prioritize it before spending time on AOT reversing. A quick first pass that regularly pays off: ```bash apktool d target.apk -o apktool-out rg -n -a "(https?://|api[_-]?key|token|secret|BEGIN (RSA|EC|PRIVATE)|supabase|stripe|aws)" \ apktool-out/assets/flutter_assets extracted_libs -S ``` ### Recovering symbols, strings and hook points with **blutter** For ARM64 targets, **blutter** is currently the most practical first step because it parses the Dart AOT snapshot, labels functions, dumps the object pool, and generates Frida hook stubs.[[10]](#references) For generic ELF work after that, check [Reversing Native Libraries](/hacktricks/mobile-pentesting/android-app-pentesting/reversing-native-libraries). ```bash python3 blutter.py extracted_libs/ blutter-out rg -n -a "(https?://|api[_-]?key|token|secret|BEGIN (RSA|EC|PRIVATE)|supabase|stripe|aws)" \ blutter-out/pp.txt blutter-out/asm -S gitleaks detect -s blutter-out/pp.txt --no-git ``` Useful outputs: - `asm/`: annotated assembly with recovered Dart/library names - `pp.txt`: object-pool dump; often the fastest place to find endpoints, JWTs, keys, IVs, feature flags, and C2 paths - `blutter_frida.js`: starter hooks you can adapt to print arguments or return values from recovered functions If you want a **fully static** workflow or a fast diff between two releases, newer tools like `unflutter` and `flutterdec` are worth trying, but `blutter` remains the quickest route from APK → named functions → Frida hook points. ### Platform / MethodChannel reconnaissance A lot of Flutter-specific attack surface is not in TLS at all but in the bridge between Dart and the Android host. The most valuable strings are often **MethodChannel / EventChannel names** because they point to privileged native actions (contacts, SMS, files, biometrics, device identifiers, push tokens, custom crypto helpers, etc.). ```bash jadx -r target.apk -d jadx-out rg -n "MethodChannel|EventChannel|BasicMessageChannel|plugins\\.flutter\\.io|setMethodCallHandler|invokeMethod" jadx-out -S ``` Frida can log channel creation names very early during startup: ```javascript Java.perform(function () { var MC = Java.use('io.flutter.plugin.common.MethodChannel'); MC.$init.overload('io.flutter.plugin.common.BinaryMessenger', 'java.lang.String') .implementation = function (messenger, name) { console.log('[+] MethodChannel: ' + name); return this.$init(messenger, name); }; }); ``` Once you know the channel name, pivot into the matching Java/Kotlin handler and the Dart caller in `blutter-out/asm/` to trace how sensitive data moves across the bridge. ### Obfuscation notes for pentesters Flutter obfuscation (`--obfuscate --split-debug-info`) only renames symbols and stores the symbol map externally so developers can later run `flutter symbolize`. It does **not** encrypt `flutter_assets`, prevent native disassembly of `libapp.so`, or stop runtime hooks.[[11]](#references) If your assessment includes CI/CD artifacts, crash-upload buckets, update infrastructure, or mobile build pipelines, search for accidentally exposed: - `app.*.symbols` - `SYMBOLS` - obfuscation-map JSON files - directories used as `--split-debug-info` output Those artifacts can turn a “hard to read” AOT binary back into a much friendlier target. ## References - [1] [Intercepting HTTPS Communication in Flutter: Going Full Hardcore Mode with Frida](https://sensepost.com/blog/2025/intercepting-https-communication-in-flutter-going-full-hardcore-mode-with-frida/) - [2] [Bypassing Flutter TLS/SSL Verification When reFlutter Fails](https://petruknisme.medium.com/bypassing-flutter-tls-ssl-verification-when-reflutter-fails-a4c41ff758a3) - [3] [Impact-I/reFlutter](https://github.com/Impact-I/reFlutter) - [4] [Flutter SSL Bypass: How to Intercept HTTPS Traffic When all other Frida Scripts Fail (vercel)](https://m4kr0.vercel.app/posts/flutter-ssl-bypass-how-to-intercept-https-traffic-when-all-other-frida-scripts-fail/) - [5] [Flutter SSL Bypass: How to Intercept HTTPS Traffic When all other Frida Scripts Fail (medium)](https://m4kr0x.medium.com/flutter-tls-bypass-how-to-intercept-https-traffic-when-all-other-frida-scripts-fail-bd3d04489088) - [6] [PoC Frida hook for Flutter SSL bypass](https://github.com/m4kr0x/flutter_ssl_bypass) - [7] [BoringSSL ssl_x509.cc (ssl_crypto_x509_session_verify_cert_chain)](https://github.com/google/boringssl/blob/main/ssl/ssl_x509.cc#L238) - [8] [SSL Pinning Bypass – Android](https://hardsoftsecurity.es/index.php/2025/11/26/ssl-pinning-bypass-android/) - [9] [Practical Mobile Traffic Interception](https://medium.com/@justmobilesec/practical-mobile-traffic-interception-1481e33d974e) - [10] [B(l)utter - Flutter Mobile Application Reverse Engineering Tool](https://github.com/worawit/blutter) - [11] [Flutter official docs - Obfuscate Dart code](https://docs.flutter.dev/deployment/obfuscate)