An app runs on a phone the developer does not control, and whoever holds that phone can unpack the binary and read its traffic. With the right tools they can also change what the app does while it runs. Most mobile app security best practices follow from that single fact, and the controls that carry the most weight are the ones that keep failing in shipped apps: hardcoded keys and cleartext traffic mainly, with unvetted SDKs not far behind.
Hardcoded keys are not a rare mistake. Quokka’s 2026 analysis of more than 150,000 apps, scanned throughout 2025, found hardcoded cryptographic keys in 47.8% of Android apps and 17.6% of iOS apps.
Any key compiled into the app can be pulled out by whoever downloads it. So server-issued tokens and platform keystores come first, and obfuscation comes after.
How do OWASP MASVS and the Mobile Top 10 organize mobile app security?

OWASP’s MASVS sorts the controls into 8 control groups and 24 controls, all aimed at protecting an app’s code, stored data, network traffic and backend APIs on a device the developer does not control.
The MASVS says what to verify, while the MASTG covers how to test each control. Separately, the MASWE catalogs the weaknesses that cause failures.
- STORAGE has 2 controls and covers sensitive data at rest on the device.
- CRYPTO, also 2, is about correct cryptography and key handling.
- AUTH has 3 controls for identity checks and access control.
- NETWORK (2) deals with data in transit.
- PLATFORM has 3, about how the app interacts safely with the OS and other apps.
- CODE has 4 controls, for code quality and dependencies.
- RESILIENCE has 4 as well, and covers resistance to reverse engineering and tampering.
- PRIVACY rounds it out with 4 controls that protect personal data.
The Mobile Top 10 sits beside the standard as a risk list. In the 2024 release, improper credential usage ranks first and inadequate supply chain security second.
Both documents start from the assumption that the client is hostile. Users can root or jailbreak the phone, and they can decompile the binary and read its traffic whenever they like.
Android’s developer documentation says reverse engineering tools recover a hardcoded secret very easily. That one fact drives most of the threats that mobile apps face, and it sets the order of the sections below. Credentials come first, then storage and network, and code protection last.
How should a mobile app handle authentication, tokens and credentials?

Credentials stay out of the app, and authentication happens on the server. Biometrics unlock a key and do not count as a login by themselves. This lines up with the MASVS authentication group and with improper credential usage, the top entry in the 2024 Mobile Top 10.
Credentials and secrets in the code
Plenty of iOS developers assume App Store review catches embedded keys. It does not evaluate app code for hardcoded secrets, so nobody catches them before release.
Cybernews (2025) analyzed more than 156,000 iOS apps and found that 71% leaked at least one hardcoded secret, with 5.2 secrets per app on average.
API keys and signing secrets belong on the backend. What the app gets from the server is a short-lived token scoped to one user, and the build should fail whenever a scanner finds a key pattern.
Run that scanner on every commit in continuous integration. A key that reaches a release build is already public.
Login, MFA and biometrics

For OAuth 2.0, RFC 8252 requires public native app clients to implement PKCE, which stops another app from redeeming an intercepted authorization code. The same RFC sends authorization requests through an external user-agent instead of a webview, since an embedded one exposes credentials and session cookies to the host app. If the app also needs to know who signed in, OpenID Connect adds the identity layer on top of OAuth 2.0.
Multi-factor authentication has to be enforced by the server. A client-side check can be skipped.
On Android, declare BIOMETRIC_STRONG, which means a Class 3 biometric, in BiometricPrompt. Then pass a CryptoObject so the user must authenticate each time before the app accesses the key.
On iOS, LocalAuthentication triggers Face ID or Touch ID, and a Keychain item with an access-control flag ties the unlock to a key.
A success callback alone proves little, because the code that reads it runs on the user’s device. A key that only releases after the prompt cannot be faked the same way.
Session and token lifetime

Sessions in a mobile app work best as token-based authentication, where the server decides what each token can still do.
Access tokens should expire quickly so a stolen copy only works for a short window. Refresh tokens live longer, sit in the Keychain or Keystore and never in plain preferences, and the server invalidates them on logout or password change.
Set an idle session timeout that fits the app’s risk. A banking app needs a tighter one than a recipe app.
Where should a mobile app store sensitive data and keys?

Keys and tokens go in the platform’s hardware-backed store. Anything bigger gets encrypted with a key from that store. Nothing secret belongs in a preferences file or a plain database, and bundled assets are no better.
| Store | Platform | Holds | Backing |
|---|---|---|---|
| Keychain | iOS | Passwords, tokens, small secrets | Encrypted by the OS |
| Secure Enclave | iOS | P-256 private keys; ML-KEM and ML-DSA keys from iOS 26 | Dedicated coprocessor |
| Android Keystore | Android | Non-exportable keys | TEE or secure element |
| StrongBox | Android 9+ | Limited algorithm set | Secure element |
Keychain items carry an accessibility attribute, and the ThisDeviceOnly variants stay out of backups and device migration.
The Android Keystore keeps key material non-exportable while apps still use the keys for cryptographic operations. If the app is compromised, an attacker can misuse the keys but cannot extract them.
For data encryption, Android’s documentation shows a 256-bit AES key in GCM mode, generated through the AndroidKeyStore provider, so the key material never appears in the app.
StrongBox is the stricter option, available from Android 9 (API level 28) when the device has it. It supports a limited algorithm set (RSA 2048, AES 128 and 256, ECDSA and ECDH P-256, HMAC-SHA256, Triple DES) and the documentation says that for most apps StrongBox is not necessary.
Skip it unless your threat model calls for it. If it does, request StrongBox, catch StrongBoxUnavailableException and fall back to the standard Keystore.
Hardware protection has limits too. It applies only when the hardware supports the key’s exact algorithm, block mode, padding and digest combination. And a Keystore key sitting beside ciphertext that a hardcoded fallback password also unlocks protects nothing.
How do you secure network traffic and API calls?

TLS on every connection is the baseline, and the MASVS network group covers it along with pinning. Pinning is only worth adding if you can ship an update fast. Transport security still leaves a gap, because it says nothing about whether the caller is your genuine app, so the server has to verify that separately.
Transport settings by platform

On Android, cleartext HTTP is disabled by default for apps targeting Android 9 (API 28) or higher, and the Network Security Configuration documentation says the global opt-in should be avoided whenever possible. If you need an exception, scope it to one domain.
On iOS, App Transport Security requires HTTPS by default. Add per-domain exceptions in Info.plist and never switch on NSAllowsArbitraryLoads for the whole app.
On the server, run TLS 1.3 where the stack supports it and keep TLS 1.2 as the floor.
Certificate pinning

Pinning is rare in practice. Pradeep et al. (IMC 2022) found runtime pinning in 0.9 to 8% of Android apps and 2.5 to 11% of iOS apps, depending on the set of apps studied.
Low adoption has a reason. On Android, a pin is a SHA-256 digest of the certificate’s SubjectPublicKeyInfo, and a chain validates only if it contains a pinned key. Rotate that key carelessly and the app stops connecting.
When it works, pinning blocks man-in-the-middle attacks that use certificates from a rogue or compromised CA, and it limits trust to the keys you choose. On Android it is declarative, so there is no custom code to write.
The downsides are real, though.
- Without a backup pin, a key or CA change cuts connectivity until an app update ships.
- A pin expiration date protects stale app versions, yet Android’s documentation warns it may let attackers bypass pinning.
- Pinning is skipped when the chain uses a debug-only trust anchor, so keep debug overrides out of release builds.
- On a rooted device, an attacker who hooks the pin check at runtime removes it entirely.
My rule is to pin the public key and ship a backup pin. If you cannot force an update when a certificate rotates, skip pinning entirely.
Protecting the API itself
The backend cannot trust the client, so it checks the client.
Firebase App Check does this with attestation. Apple platforms use DeviceCheck or App Attest, Android uses Play Integrity, and App Check issues a token that protected services require on each request. It also covers custom, non-Google backends such as self-hosted servers.
Validate the token at the API gateway before a request reaches business logic. Authorization and entitlement checks stay on the server, and so does price calculation, whatever the client claims.
How do code obfuscation, root detection and app attestation protect the app at runtime?

None of these stop a determined attacker. Obfuscation slows down anyone reading the code statically, and root or jailbreak detection flags a hostile device. Attestation is different, since it lets the server verify the app instance itself. Each one raises the attacker’s cost without removing it.
Obfuscation
Zimperium’s 2025 research found that 24% of Android apps and 60% of iOS apps have no protection from reverse engineering.
R8 is the default on Android. It renames classes, fields and methods to cut DEX size, turning com.example.MyActivity into something like a.b.a.
Android’s documentation frames that renaming as a size reduction, not as protection. Code obfuscation hides names and structure, and the logic underneath stays readable to a patient analyst.
R8 and ProGuard are free and built into Android release builds. Apps that need stronger hardening can look at DexGuard, Guardsquare’s commercial option.
Root and jailbreak detection
Checks usually look for a su binary or a root manager app, build tags that mark a test-keys image, and writable system partitions. On iOS they look for Cydia or similar package paths, and for sandbox escapes such as writing outside the app container.
What the app does after detection matters more than the check. Disable high-risk features or require step-up authentication, and report the signal to the server.
Crashing the app on detection punishes users with false positives and teaches attackers exactly which check to patch.
Attestation
On Android, the Play Integrity API checks that requests come from your unmodified app binary, installed by Google Play, running on a genuine Android device.
SafetyNet Attestation is gone. Google set a migration deadline of January 31, 2024 and began turning the API down gradually after it. Apps with an approved extension kept receiving responses until the full shutdown on January 31, 2025, and since then every call fails.
On iOS, App Attest creates a hardware-backed key per app install. Apple attests the key, and the server verifies signed assertions and a rising counter to catch replays.
Attestation proves the instance is genuine at that moment. It says nothing about whether the user is honest, or whether something hooks the app a second later.
When do client-side protections stop working?

Against an attacker who owns the device and has time. Obfuscation, root detection and pinning all run on hardware the attacker controls.
Frida injects JavaScript into a running native app, where the script can hook functions and read or write process memory. It supports Android and iOS, among other platforms.
Root and jailbreak checks fall to a hook on the checking method that returns a clean result, and NowSecure’s tutorial bypasses three common root detection techniques this way. Pinning goes the same way, with a hook on the validation routine so traffic flows through an intercepting proxy. String and class encryption only delay things, since the app decrypts itself at runtime and the result can be read from memory.
A 2023 TU Wien thesis built scripts that bypass most of the string encryption, class encryption, pinning and root detection mechanisms it analyzed in three commercial protection tools.
The SANS Institute’s March 2026 white paper “Can Root Detection Be Trusted?” ranks the checks by how well they survive. File checks for a hidden su binary are easily defeated, while memory-based heuristics and hardware-backed attestation held up against every bypass attempt tried. The study used one Android 16 device, one test app and seven bypass scenarios, so it shows a ranking rather than proof that any check is unbreakable.
Read the two studies together and a pattern shows. Checks that live inside the app’s own process fall to hooking, and checks anchored in hardware or verified by a server the attacker does not control last longer.
So design for the bypass. Assume the check fails, then ask what the attacker gets, and if the answer is another user’s data, the fix belongs on the server.
An app with no sensitive data and no proprietary logic gains little from obfuscation or tamper detection in the first place. The other risk is false positives. Aggressive detection flags legitimate users on custom ROMs and modified OS builds, then locks them out of an app they paid for. Where the budget is thin, I’d spend it on server-side authorization before obfuscation licenses.
How much protection does your app need?
The baseline applies to every app. Apps that hold sensitive data go further with defense in depth, and apps with client-side assets worth stealing add resilience on top. The MASVS levels follow that split. L1 is the baseline and L2 adds defense in depth for apps handling sensitive data, while R sits on top as an extra layer for apps facing reverse-engineering risk.
MASVS v2.0.0 moved the levels out of the controls. OWASP put them into MASTG tests so the same control can be evaluated differently per situation.
| Profile | Applies to | What it adds |
|---|---|---|
| MAS-L1 | Every app | Baseline storage, network and authentication controls |
| MAS-L2 | Apps handling financial, health or identity data | Defense in depth, stricter rules per control |
| MAS-R | Apps with client-side assets worth attacking | Anti-tamper, obfuscation, anti-instrumentation |
Profile selection
NIST’s guidance on app vetting ties risk to data access. Apps that touch precise geolocation, personal health metrics or personally identifiable information are higher-risk than those that do not.
Score each app on a risk assessment matrix, with data sensitivity on one axis and attacker incentive on the other.
A utility app with no accounts sits at L1. Once there are accounts and personal data, L1 plus L2 applies. Add R only when the client holds something worth stealing, like licensed content, a game economy or fraud logic.
Do not start at MAS-R. Resilience controls on an app with unfinished L1 work are the most common misallocation, and the earlier section on bypasses shows why.
Compliance triggers
GDPR Article 32 requires security measures suited to the risk to people’s rights, weighed against the state of the art and implementation cost, and it names encryption and regular testing of those measures among its examples. The HIPAA Security Rule requires administrative, physical and technical safeguards for electronic protected health information.
PCI DSS v4.0.1 has a date attached. Of the 64 new requirements in v4.x, 51 were future-dated to 31 March 2025, and all are mandatory now.
None of these names a mobile control. GDPR asks for measures matched to risk, and the mapping from rule to control is yours to document.
Treat software compliance as an input to profile selection, then record which MASVS control satisfies which obligation, so an auditor can follow the trail.
How do third-party SDKs and dependencies affect mobile app security?

A third-party SDK runs inside your app, so its flaws and its behavior become yours. Users blame the app, not the library.
McAfee Labs (2023) found the Goldoson library in more than 60 Android apps with over 100 million Google Play downloads, among them L.POINT with L.PAY. The app developers did not write that malicious library. Someone else did.
Google Play’s SDK Index shows an SDK’s reliability and safety signals, version adoption and requested permissions before you add it. If a version has critical issues, you can still release temporarily, but you must update the SDK within 90 days or lose the ability to ship further versions.
On Apple’s side, since May 1, 2024, a newly added SDK from Apple’s list of commonly used SDKs requires required-reason API declarations, a privacy manifest and, when it is a binary dependency, a valid signature. Xcode validates that a new SDK version was signed by the same developer, which protects the supply chain.
MASVS-CODE-3 is the control that covers this, and it reads simply: the app only uses software components without known vulnerabilities.
That control has a blind spot. A scanner matches known vulnerabilities, so it says nothing about an SDK that misbehaves by design.
A few habits help here. Pin dependency versions and remove SDKs the app no longer calls. For each addition, review its permissions, endpoints and update cadence, and watch its network traffic during dynamic testing.
Route every SDK addition through the code review process, and make the reviewer sign off on what the SDK requests, not only on the diff.
How to test a mobile app’s security before release

Static analysis runs automatically on every build. Dynamic analysis happens on a real device before each release, and manual penetration testing is for the major ones. NowSecure recommends manual testing for an initial release and for each major update, as well as for any app that handles sensitive data or falls under regulation. Retest after significant changes to authentication, payments, sensitive data handling or third-party SDKs.
- Pick the MAS profile for the app and list the MASVS groups in scope.
- Run static analysis on every build. MobSF performs static and dynamic analysis for Android and iOS apps, and Jadx decompiles the APK so a reviewer can read what ships.
- Scan dependencies and fail the build on known vulnerabilities.
- Test dynamically on a device: proxy the traffic with Burp Suite, hook the app with Frida and watch what it stores and sends.
- Repeat the dynamic pass behind the login, with a real test account.
- Run the MASTG test cases for the in-scope controls manually before major releases.
- Map each finding to a MASVS group, fix it, retest it, then sign off the release.
A repeatable routine for mobile app security testing pays off most at step 5. NowSecure’s analysis of about 105,000 assessments found authenticated testing surfaces 78% more sensitive data exposure per scan (7.23 findings against 4.07), because most of an app’s data handling sits behind the login.
Teams also tend to overrate their own programs. NowSecure’s 2026 Mobile App Risk Management Survey found that 81% of finance security leaders rated their mobile security program as advanced, yet 44% of them reported a major security incident.
Choose the tools for mobile penetration testing by what each step needs. MobSF covers breadth, while Frida and Burp Suite handle runtime and traffic.
Automated scans still miss business logic flaws and broken authorization. Only a person reading the app’s flows will catch those.
Mobile App Security Best Practices FAQ
Is HTTPS alone enough to protect a mobile app’s traffic?
No. HTTPS encrypts the connection, but it accepts any certificate that chains to a trusted CA, and it does not prove to the server that the caller is your genuine app.
Add certificate pinning where you can ship updates fast, plus server-side attestation checks. Quokka (2026) found plain HTTP URLs in 94.3% of the Android apps it scanned.
Do React Native and Flutter apps need different security controls?
The controls stay the same, because the app still runs on Android and iOS. What changes is what ships inside the package.
Apps built with cross-platform app development frameworks bundle code and assets an attacker can unpack, so a secret in the bundle is as exposed as one in native code. Keep tokens in the platform Keychain or Keystore through a plugin.
How do iOS and Android security models differ?
Android’s hardware protection varies by device, while iOS is more uniform. StrongBox needs Android 9 and a device that has the hardware, so Android apps check for it and fall back.
Neither store replaces your own scanning. Apple’s review process does not evaluate app code for hardcoded secrets, according to Cybernews (2025).
How can an app keep sensitive data out of backups, screenshots and logs?
On Android, disable backup for sensitive files and set FLAG_SECURE on sensitive screens, which blocks screenshots and the recents preview. On iOS, use ThisDeviceOnly Keychain attributes, exclude files from backup and hide content in the app switcher.
Strip logging from release builds. The MASWE catalog lists insertion of sensitive data into logs as a weakness at profiles L1 and L2.
Which Mobile App Security Fixes Should Ship First?
Of all the mobile app security best practices, the first ones to apply on a shipping app are the ones that take secrets out of the binary. Start with server-issued, short-lived tokens held in the Keychain or Keystore.
After tokens and credential cleanup, enforce TLS and add server-side attestation checks. Obfuscation and runtime detection come last.
Attestation outranks obfuscation because the server can reject a tampered client, while obfuscation only slows the person reading the code. The first two steps are mostly backend and configuration work, so they usually fit in one release.
The cost is operational. Short-lived tokens need a refresh flow, and obfuscated builds need mapping files uploaded to the crash reporter, otherwise stack traces become unreadable.
- Is Notepad++ Safe? Official Download, Updates, CVEs - November 29, 2026
- How to Evaluate an AI Code Reviewer on Your Own Pull Requests - November 29, 2026
- Outsourcing Medical Device Software Securely - November 28, 2026



