Ten minutes. That is how long it took us to pull a payment-adjacent API key, a third-party AI provider key and a fully permissive backend URL out of a client's release APK, with no exploit and no special tooling beyond what ships in any security-minded developer's toolbox. The app was a Flutter build, release mode, with obfuscation switched on. The point of this post is simple: secrets in a Flutter binary are not secrets, and obfuscation does not change that. What changes it is where you put the trust boundary.

The ten-minute extraction

We were brought in for a code audit on an existing Flutter app. Before reading a single line of Dart, we did what any curious attacker with a laptop would do: downloaded the release APK from the store, and started poking.

Minutes 0 to 3: unpack and grep

An APK is a zip file. apktool d app-release.apk decodes the manifest and resources; plain unzip gives you the raw payload. Two places matter for a Flutter app:

  • res/values/strings.xml, where the Google Services plugin has written the Firebase config: project ID, API key, app ID, storage bucket. Every one of these is readable, by design.
  • lib/arm64-v8a/libapp.so, the AOT-compiled Dart snapshot. People assume this is opaque machine code. It is not opaque in the way that matters: string literals live in the snapshot's object pool, and they are stored as data.

Running strings -n 12 libapp.so | grep -iE "key|token|secret|https://" was enough. Out came an endpoint list, a bearer-style token with an obvious provider prefix, and an LLM provider key sitting next to the prompt template that used it. The developers had used --obfuscate --split-debug-info, which is correct practice, and which did nothing to the strings. Obfuscation in Flutter renames symbols (class and function names in stack traces and reflection). It does not encrypt your literals.

Minutes 3 to 8: let the app tell you the rest

Static analysis finds what is compiled in. A proxy finds what the app actually does. We installed the APK on a test device, put mitmproxy in the path and installed its CA. Flutter ignores the system proxy setting and ships its own certificate store, so you either patch the engine's trust check with Frida or use a reFlutter-style repackaged build. Neither is exotic; both are documented in public. Certificate pinning, if present, raises the bar by an hour or so, not by an order of magnitude.

The traffic confirmed the strings and added more: the AI provider key was sent directly from the phone to the provider, the backend accepted requests with no per-user auth beyond a static header, and responses included fields the UI never rendered. Replaying a request with the token and a different ID returned another user's record. That last one is not a binary secret problem. It is the consequence of one.

Minutes 8 to 10: assess the blast radius

The Firebase config turned out to be the least dangerous item, which surprises people. A Firebase API key identifies a project; it does not authorize anything on its own. What protects the data is Security Rules and App Check. In this case the Firestore rules were permissive in two collections, so the "harmless" key became a map to an open door. The LLM key was the worst: it was unrestricted, billed per token, and usable from anywhere. Anyone who extracted it could run their own workloads on the client's account until someone noticed the invoice.

Why you cannot fix this inside the app

The usual remedies each fail for a specific reason:

  • Obfuscation hides symbol names, not data. It slows reading of control flow slightly.
  • Splitting the key into pieces or XOR-ing it only moves the work to runtime. The assembled value must exist in memory to be sent over the wire, and a proxy sees the wire.
  • Loading from --dart-define or a .env asset changes where the string comes from at build time, not whether it ends up in the shipped artifact. Same result.
  • Pinning and root detection are speed bumps. Useful for raising cost, useless as a security boundary, because the attacker controls the device.

The principle that actually holds: anything the client needs in order to call a service, the client's owner can extract. So the client should never hold anything worth extracting.

The server-mediated design that makes extraction harmless

The fix we recommended, and the shape we use in our own shipped apps, is boring on purpose.

  1. Third-party keys live only on the backend. The app calls your API; your API calls the provider. For AI integration this also gives you one place to enforce prompt templates, output filtering, rate limits and per-user quotas. An LLM key in the app means your prompt, your cost control and your abuse policy are all in the attacker's hands.
  2. Authenticate the user, not the app. Short-lived tokens issued after sign-in, scoped to that user's data. Every endpoint authorizes against the token's subject, which kills the replay-with-another-ID problem at the source.
  3. Treat the Firebase config as public, and make the rules do the work. Write Security Rules as if the config is on a billboard, because it is. Add App Check (Play Integrity on Android, App Attest on iOS) as a second signal that requests come from a genuine build, understanding it reduces abuse rather than eliminating it.
  4. Meter and cap at the server. Per-user and per-day limits on any endpoint that spends money. If a token is stolen, the loss is bounded by policy rather than by the provider's credit limit.
  5. Make rotation cheap. If a server-side secret leaks, you rotate it in one deployment, not through an app-store review cycle.

The test we apply is the same one we ran on the client's APK: extract everything you can from the binary and the traffic, then ask what an attacker can do with it. If the honest answer is "make requests as themselves, within their own quota", the design is sound. If the answer involves someone else's data or your invoice, it is not, regardless of how many obfuscation flags are set.

What this costs

Moving secrets behind a backend adds a hop and a service to operate. Latency for AI features goes up slightly, and you now own an API that needs its own monitoring. We think that is the correct trade: the cost is predictable engineering work, while the alternative is an unbounded exposure you discover from a bill or a breach report. Streaming responses through your backend keeps the user experience intact, and a thin proxy layer is a small amount of code compared with the audit findings it removes.

If you are shipping a Flutter app today, run the ten-minute test on your own release build before anyone else does. orithLabs does this kind of audit for existing codebases and builds new apps with the server-mediated shape from the first commit, and you would talk directly to the engineers either way. If you want a second pair of eyes on what your APK gives away, we are happy to have that conversation.