A mobile app runs on a device you do not control, in the hands of anyone who downloads it, including people who will take it apart to see how it works. That changes how you must think about protection. Mobile app security is less about making the app itself impenetrable, which is impossible, and more about making sure that a compromised app or device cannot compromise your users' data or your backend. This guide covers the practices that matter most, in terms both managers and developers can use.
The core principle: never trust the client
Anything shipped inside an app can be inspected. Attackers can decompile app packages, read embedded strings, intercept network traffic on their own device and modify the app's behaviour. So:
- Every security decision, such as whether this user may view this invoice or whether this discount is valid, must be enforced on the server.
- Hiding a button in the app is a user interface choice, not access control.
- Prices, permissions and business rules sent from the app must be validated by the backend.
Most serious mobile breaches turn out to be backend weaknesses reached through the app's API, which is why mobile and API security cannot be separated.
Mobile app security for data on the device
Store as little as possible
Data that is never stored on the phone cannot leak from it. Keep only what the app needs to function, and clear it when it is no longer needed, including on logout.
Use the platform's secure storage for secrets
Authentication tokens, encryption keys and similar secrets belong in the iOS Keychain or the Android Keystore system, not in plain preference files or local databases. These platform facilities are designed to protect secrets, using hardware-backed protection on many devices.
Encrypt sensitive local data
If the app must cache sensitive business or personal data, for example for offline use, encrypt the local database with keys held in secure storage.
Watch for accidental leaks
- Do not write tokens, passwords or personal data to debug logs in release builds.
- Consider hiding sensitive screens in the app switcher's snapshot and, where appropriate, preventing screenshots of them.
- Exclude sensitive files from device backups where the platform allows.
- Be careful with the clipboard; other apps may read it.
Secrets: what must never be in the app
API keys for payment gateways, SMS providers, email services, cloud storage admin credentials and database passwords must never be embedded in an app. Obfuscation slows attackers down but does not stop them. Put those calls on your backend, where the secret stays on the server and the app authenticates as a user. Keys that must be in the app, such as some map or analytics keys, should be restricted in the provider's console to your app's identifiers and to the minimum permissions.
Protecting data in transit
- HTTPS for everything, with modern TLS configuration on the server. iOS's App Transport Security and Android's network security configuration both discourage or block plain HTTP by default; do not weaken them.
- Valid certificates with a complete chain. You can check yours with our SSL checker.
- Certificate pinning, where the app only accepts specific certificates or keys for your server, adds protection against interception, but makes certificate rotation riskier: a mistake can lock every installed app out of your API. Use it for high-risk apps, with backup pins and a tested rotation plan.
- Security headers and server configuration on your API domain matter too; our HTTP header checker shows what your server returns.
Authentication and sessions
- Use established standards, such as OAuth 2.0 and OpenID Connect, or your framework's proven token system, rather than inventing your own scheme.
- Use short-lived access tokens with refresh tokens that can be revoked server-side, for example when a device is reported lost.
- Offer biometric unlock (Face ID, fingerprint) as a convenient way to unlock a stored session, backed by secure storage, rather than as the only factor for high-value actions.
- Support multi-factor authentication for sensitive accounts, and rate-limit login attempts on the server.
- Invalidate sessions on the server at logout, not only on the device.
Code and platform hardening
- Obfuscation and minification (for example R8 on Android) make reverse engineering harder and shrink the app. Useful, but not a substitute for server-side security.
- App and device integrity checks. Google's Play Integrity API and Apple's App Attest let your backend gain some assurance that requests come from a genuine copy of your app. Use the results as risk signals on the server rather than absolute proof.
- Root and jailbreak detection can be bypassed by determined attackers, but can still be a reasonable signal for banking-grade apps.
- Validate deep links and intents. Treat data arriving through links, shared content or other apps as untrusted input.
- Be cautious with WebViews. Load only trusted content, avoid exposing native functions to web pages unless necessary, and never load arbitrary URLs into a privileged WebView.
Third-party SDKs and dependencies
Analytics, advertising, crash reporting and social login SDKs run with your app's permissions and may collect data on your behalf. Before adding one, check what it collects, who maintains it and how it affects your privacy declarations in the app stores. Keep dependencies updated and remove those you no longer use. Every dependency is code you are trusting.
Testing and standards
The OWASP Mobile Application Security project, including the MASVS standard and its testing guide, is the most widely used open reference for mobile security requirements. Use it to set the level of assurance appropriate to your app. In practice:
- Include security requirements in the specification, not just as a final check.
- Run automated static analysis and dependency scanning in the build pipeline.
- Test the API directly, as an attacker would, bypassing the app.
- Commission an independent penetration test for apps handling money, health or significant personal data.
Security is designed into every mobile app development project we take on, together with the backend that the app relies on.
Key takeaways
- Assume the app can be inspected and modified; enforce all security on the server.
- Keep secrets out of the app, and store tokens in the Keychain or Keystore.
- Use HTTPS everywhere; pin certificates only with a solid rotation plan.
- Vet SDKs, use OWASP's mobile standards and test your API directly.