The average cost of a mobile data breach in 2025 is $4.9M. Beyond financial loss, a breach destroys user trust in a way that no amount of marketing can repair. Yet most apps we audit are missing at least three of the seven fundamentals covered in this guide. Here's what every production mobile app must have.
1. Certificate Pinning
Without certificate pinning, an attacker on the same network can intercept your app's HTTPS traffic using a self-signed certificate. This is called a Man-in-the-Middle (MitM) attack and is trivially easy to execute on public Wi-Fi.
Pinning ensures your app only accepts the specific TLS certificate (or certificate chain) it was
compiled with. On iOS, use URLSession with a custom URLSessionDelegate
that validates the server's certificate against a pinned hash. On Android, use OkHttp's
CertificatePinner.
// Android — OkHttp
val client = OkHttpClient.Builder()
.certificatePinner(
CertificatePinner.Builder()
.add("api.yourapp.com", "sha256/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=")
.build()
)
.build()
Important: Pin to your intermediate CA certificate, not the leaf certificate, to avoid breaking your app when you renew TLS certificates.
2. Biometric Authentication
For any app handling sensitive data (financial, health, personal), biometric authentication should be the default second factor or app unlock mechanism. It's more secure than PIN/password re-entry and dramatically better UX.
On iOS, use LocalAuthentication's LAContext. On Android, use
BiometricPrompt from the Biometric library. Always specify
setAllowedAuthenticators(BIOMETRIC_STRONG) on Android — BIOMETRIC_WEAK
doesn't meet security standards for sensitive data.
Combine biometric unlock with a symmetric key stored in the Secure Enclave (iOS) or Android Keystore — the key is inaccessible without biometric authentication, so even a jailbroken/rooted device can't access it.
3. Encrypted Local Storage
Never store sensitive data (tokens, PII, payment info) in plain text — not in
UserDefaults, SharedPreferences, SQLite databases, or flat files. All of
these are readable on rooted/jailbroken devices or via backup extraction.
- Tokens & credentials — iOS Keychain (with
kSecAttrAccessibleWhenUnlockedThisDeviceOnly), Android Keystore - Sensitive database data — SQLCipher for SQLite encryption on both platforms
- Files — iOS Data Protection with
NSFileProtectionComplete, Android's EncryptedFile from Jetpack Security
"We audited an app that stored JWT tokens in UserDefaults. 10 minutes of ADB debugging on a rooted Android device gave us full account access for every user who'd installed it."
4. Jailbreak / Root Detection
A jailbroken iOS device or rooted Android device bypasses OS-level security sandboxing. For high-security apps (banking, healthcare, enterprise), detecting and responding to these environments is essential.
Detection signals to check:
- Presence of Cydia, Magisk, or known root management files
- Ability to write outside the app sandbox
- Suspicious environment variables
- Fork bomb / dynamic code loading detection
Use libraries like IOSSecuritySuite (iOS) or RootBeer (Android) as a
starting point, then layer in custom checks that are harder to bypass. When detection fires: deny
access to sensitive features, log the event server-side, and show a clear message to the user.
5. Code Obfuscation & Anti-Tampering
Attackers can reverse-engineer your app binary to extract API endpoints, business logic, or hardcoded secrets. While obfuscation isn't a silver bullet (a determined attacker will still succeed), it significantly raises the cost of an attack.
- Android — enable ProGuard/R8 in your release build. Add custom obfuscation rules for your most sensitive classes.
- iOS — Swift code is harder to reverse-engineer than Objective-C but not immune. Use LLVM obfuscation passes or commercial tools like iXGuard for high-security apps.
- All platforms — never hardcode secrets (API keys, encryption keys) in the binary. Use server-side key exchange or the platform Keychain/Keystore.
6. Secure Network Communication
Beyond certificate pinning, ensure your network layer follows these rules:
- TLS 1.2 minimum, TLS 1.3 preferred — disable older protocols server-side
- Enforce HTTPS everywhere — iOS App Transport Security (ATS) is on by default;
never add
NSAllowsArbitraryLoadsto production builds - Short-lived tokens — access tokens should expire in 15–60 minutes; use refresh tokens stored in Keychain/Keystore
- Validate all server responses — never blindly trust server data; validate types, ranges, and formats before using in UI or local storage
7. Data Minimisation & Retention Policy
The safest data is data you never collect. For every data point you collect from users, ask: do we actually need this? Under GDPR, CCPA, and Apple's App Privacy labels, you're accountable for every field.
Practical steps:
- Purge cached user data when a user signs out
- Delete temporary files created during sessions
- Implement a data deletion endpoint (required under GDPR, now required by Apple App Store)
- Avoid logging PII in crash reports — scrub names, emails, and IDs before they reach Sentry or Crashlytics
- Request permissions at the moment of use, not at app launch
Run a full security audit before every major release, and subscribe to the OWASP Mobile Security Testing Guide (MSTG) updates. OWASP's Mobile Top 10 is the industry benchmark — make sure your app passes all 10 categories before going to production.
Quick Wins You Can Implement Today
- Enable ATS (App Transport Security) fully — remove any exceptions
- Move all secrets from source code to environment variables / CI secrets
- Add certificate pinning to your networking layer
- Migrate token storage from
UserDefaults/SharedPreferencesto Keychain / Keystore - Enable ProGuard/R8 in your Android release builds