Blog

Hardcoded API Keys in Android Apps: How to Triage a Finding

Finding a key in an APK is easy. Deciding whether it matters takes a few specific questions.

Everything in the APK is readable

An Android package can be unpacked and decompiled by anyone who has it. Strings in code, resources and bundled configuration files are visible with standard tools such as jadx or apktool. Obfuscation renames classes and methods; it does not hide a string constant in any meaningful way.

So the question is not whether a key can be extracted. It can. The question is what the key allows the holder to do.

Client identifiers versus secrets

Designed to ship in the app

Some keys identify the app to a service and are expected in client code. Firebase documents that its API keys are not secret; access is controlled by Security Rules and App Check. A Google Maps key is also expected in the app, but should be restricted to the app's package name and signing certificate, and to the APIs it needs.

Never meant for a client

Cloud provider access keys, payment provider secret keys, private signing keys, admin tokens and database credentials grant server-side power. If one of these is in the package, treat it as compromised, whether or not anyone has used it.

Between those two groups is a grey zone: third-party SDK keys whose permissions you have to look up. When in doubt, check the provider's documentation for what the key can do and whether it can be restricted.

Questions to ask about every key

  • What service does it belong to? Prefix patterns and surrounding code usually identify the provider.
  • What can it do? Read-only analytics ingestion and full account administration are very different findings.
  • Is it restricted? Package and certificate restrictions, API scopes and quotas reduce impact.
  • Is it in the current release? Record the build. A key removed from the next version still exists in every version already installed.
  • Does the app use it? A key in an unused SDK configuration still needs fixing, but the context belongs in the report.

Many of these questions can be answered from documentation and the key owner, without calling the service. Use a key against a live service only within the approved scope, with the owner's agreement, and never against systems you are not authorized to test.

Severity follows privilege, not presence

A scanner that reports every high-entropy string as critical creates noise that teams learn to ignore. A restricted Maps key and an unrestricted cloud access key may both appear as "hardcoded key", but they deserve different severities and different deadlines.

A good report states what was found, where, what the key is believed to allow and how that was established. If the privileges were inferred from documentation rather than confirmed, say so. That is the same separation between signal, candidate and confirmed finding described in our report evidence guide.

Fixing it properly

For a real secret, rotation is the fix. Revoke the exposed key, issue a new one and move the privileged operation behind your own backend, where the secret never reaches the device. Removing the string from the next build without revoking it leaves the old key valid in every copy already shipped.

For a client identifier, apply the provider's restrictions and make sure the real access control, such as database rules, is in place. Key management is commonly reviewed under MASVS-CRYPTO; the MASVS checklist shows where it fits in a full assessment.

AppBreach's static analysis reports secret-like strings as candidates with their location, so they can be triaged with the questions above. Read what static and dynamic analysis each cover, or request access to discuss an assessment of your Android app.

Related reading