Hard-Coded Secrets in the Application Package

The application package contains secrets such as API keys, credentials or private keys that anyone who downloads the app can extract.

SeverityHigh
CVSS 3.17.5 CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N Open in the calculator
CVSS 4.08.7 CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:N/VA:N/SC:N/SI:N/SA:N Open in the calculator
CWECWE-798: Use of Hard-coded Credentials
OWASP Top 10A07:2025 Authentication Failures
MITRE ATT&CKT1552.001 Credentials In Files
CategoryInformation Disclosure

Description

The application includes secrets in its code or resources, such as API keys for backend or third-party services, cloud access keys, client secrets, passwords or private keys. Secrets are found in source code, string resources, configuration files, native libraries and the JavaScript bundles of cross-platform frameworks. Mobile application packages are distributed to anyone who installs the app and can be unpacked and decompiled with freely available tools, such as apktool and jadx for Android apps or a disassembler for iOS apps, so any value shipped in the package should be treated as public.

Obfuscation and string encryption slow the search but do not prevent it, because the app must recover the value at runtime, where it can be read with dynamic instrumentation tools such as Frida. An attacker who extracts a secret can use it directly against the service it belongs to, from anywhere, with whatever permissions it carries: depending on the secret, this can expose other users' data, allow messages or payments to be sent at the organisation's expense, give access to cloud resources, or allow forging of tokens the backend trusts. Because the same secret ships in every copy of the app, revoking it breaks existing installations, which often leaves it valid for a long time.

Testing identifies candidate secrets with automated scanners and manual review, and then checks what each one grants. Not every key in an app is a secret: some identifiers are designed to be public, such as Firebase configuration values, whose security depends on server-side rules, and keys that the provider restricts to the app's package and signing certificate. The finding concerns values that grant access on their own.

Remediation

  • Remove secrets from the app. Calls that need a secret should go through the organisation's backend, which authenticates the user and holds the secret itself.
  • Where the app must call a service directly, use per-user or per-device credentials issued by the backend after authentication, with short lifetimes and narrow scopes, instead of a shared static key.
  • Restrict any key that must remain in the app to the minimum permissions, and to the app's package name and signing certificate or bundle identifier where the provider supports it.
  • Revoke and replace every secret found in released versions, since they must be considered compromised, and check the services' logs for misuse.
  • Add secret scanning to the build pipeline so that new secrets are caught before release.

Platform attestation services, such as Play Integrity and App Attest, can help a backend recognise requests from genuine installations, but they do not make embedded secrets safe. Confirm the fix by decompiling the new release and searching it for the removed secrets, and by checking that the old values have been revoked.

References


Add This Finding to Your Library

In Pental this write-up is in Settings, Library. Add to my library copies it into your own, rated in your firm's CVSS version, ready to put in your own words.

Free trial  ·  No card required

Only need the reporting? Our reporting tool is free and open source, with the same library.


More Mobile Applications Findings

Every Mobile Applications finding