Home / Insights / Mobile App Development
Mobile App Development
Mobile App Security in Practice: Secure Storage, Certificate Pinning, Jailbreak Detection and OWASP MASVS
Most mobile security problems are not exotic attacks but ordinary design choices: tokens in plain storage, pinning that breaks the app on certificate renewal, or root checks that annoy users and stop nobody. This guide explains what each control really protects, how to choose a security level with OWASP MASVS, and how to implement it without hurting reliability.
Key takeaways
- Use OWASP MASVS as the shared vocabulary between product, engineering and testers, and agree up front which control groups and depth of resilience your app needs.
- Store secrets only in the platform keystores (iOS Keychain, Android Keystore) with the strictest accessibility settings that still let the app work; never in plain preferences, files or logs.
- Certificate pinning is a trade-off, not a default: pin public keys, always ship a backup pin, and have a rotation plan, or a routine certificate change can take your app offline.
- Jailbreak and root detection on the device can always be bypassed; treat it as one signal and move real trust decisions to the server, supported by attestation such as Play Integrity.
- Build verification into delivery: MASVS-mapped test cases, dependency scanning and a release checklist are cheaper than a penetration test finding the same issues later.
On this page
- Start with the threat model and MASVS, not a list of features
- Secure storage: keeping secrets out of reach
- Certificate pinning: when it helps and how to avoid outages
- Jailbreak and root detection versus server-side attestation
- How to choose the right security level for your app
- Implementing and testing it within normal delivery
- Common mistakes, costs and a release checklist
- Frequently asked questions
- Sources and methodology
Product owners usually meet mobile security at one of two moments: when an enterprise customer sends a security questionnaire, or when a penetration test report arrives a week before launch with a list of findings. Both are expensive times to start thinking about it. The decisions that determine whether an app passes those reviews, such as where tokens are stored, how the app trusts the server and what it assumes about the device, are made in the first sprints of development.
This article is for CTOs, product managers and founders responsible for iOS, Android or cross-platform apps that handle personal data, payments, health information or business records. It explains the main controls in plain terms, where each one helps and where it is overrated, and how to use the OWASP Mobile Application Security Verification Standard (MASVS) to agree a sensible security level. I write as an architect who has to balance security with reliability: a control that locks out legitimate users or breaks the app on a routine certificate change is a defect too.
Our Mobile Development team builds native iOS and Android apps and cross-platform apps in React Native and Flutter, together with the back ends and admin panels behind them, and we review security requirements when scoping. The guidance below reflects that end-to-end view, because most mobile security depends on the server as much as the app.
Start with the threat model and MASVS, not a list of features
Mobile apps run on devices you do not control. A determined user can install your app on a rooted phone, intercept its traffic with a proxy, decompile it and modify it. The useful question is therefore not “can the app be attacked?” but “what would an attacker gain, and what should stop them?”
Three questions to answer first
- What sensitive assets does the app hold or reach? Session tokens, personal data, health records, payment methods, API keys, proprietary content.
- Who might attack it, and why? Fraudsters abusing promotions, people sharing paid content, attackers targeting a lost or stolen device, competitors scraping your API.
- What is the consequence of compromise? A leaked session token in a note-taking app is different from one in a banking or clinical app.
What MASVS gives you
MASVS is maintained by OWASP’s Mobile Application Security project and organises requirements into eight control groups. It sits alongside a weakness catalogue (MASWE) and a testing guide (MASTG), so requirements, weaknesses and test cases share the same identifiers.
| Control group | What it covers | Typical product question |
|---|---|---|
| MASVS-STORAGE | Sensitive data at rest, including logs and backups | Where do tokens and personal data live on the device? |
| MASVS-CRYPTO | Correct use of cryptography and key management | Are we using platform keystores and standard algorithms? |
| MASVS-AUTH | Authentication, authorisation and sessions | How do biometrics, step-up and logout really work? |
| MASVS-NETWORK | Data in transit, certificate validation, pinning | Can traffic be intercepted or downgraded? |
| MASVS-PLATFORM | Deep links, WebViews, clipboard, screenshots, IPC | Can other apps or the OS leak our data? |
| MASVS-CODE | Dependencies, updates, input handling, build settings | Do we ship vulnerable libraries or debug code? |
| MASVS-RESILIENCE | Tampering, reverse engineering, rooted devices | How much effort should it take to modify our app? |
| MASVS-PRIVACY | Permissions, tracking, consent, data minimisation | Do we collect only what we need, and say so? |
For most business apps, the first six groups plus privacy are the baseline. Resilience controls are added when the app protects something valuable on the device itself, such as paid content, game economies, high-value transactions or proprietary algorithms. Write the agreed scope into the requirements so testers and vendors work to the same standard.
Secure storage: keeping secrets out of reach
Insecure local storage remains one of the most common findings in mobile assessments. Developers store a refresh token in shared preferences or a plain file because it is easy, and it works perfectly until someone examines a backup or a rooted device.
What to store, and where
- Session and refresh tokens, encryption keys, credentials: only in the platform keystore. On iOS that is the Keychain; on Android, the Android Keystore system for keys, with encrypted storage for small secrets.
- Personal or sensitive records cached for offline use: encrypted at rest with a key held in the keystore, and kept to the minimum needed.
- Non-sensitive preferences: ordinary app storage is fine.
- Never: API secrets that grant broad back-end access. Anything shipped in the binary can be extracted; design the back end so the app does not need such secrets.
iOS Keychain settings that matter
Apple’s Platform Security guide explains that keychain items are encrypted with keys protected by the Secure Enclave and that each item has an accessibility class. The choice matters: items marked available “when unlocked” cannot be read while the device is locked, while “after first unlock” items remain available to background tasks once the user has unlocked the device after a restart. “This device only” variants are not synchronised to iCloud Keychain and cannot be restored to another device. For refresh tokens, a “this device only” class that fits your background needs is usually the right default. Access control can additionally require Face ID, Touch ID or the passcode before an item is released.
Android Keystore settings that matter
According to the Android Keystore documentation, key material never enters the app process and can be bound to secure hardware such as the Trusted Execution Environment or, on supported devices, StrongBox. Restrictions such as allowed purposes and user-authentication requirements are set when a key is created and cannot be changed afterwards. Keys can require recent biometric or lock-screen authentication, and biometric-bound keys are invalidated by default when new biometrics are enrolled, which is useful for high-risk actions.
Cross-platform frameworks
React Native and Flutter apps should use well-maintained secure-storage libraries that wrap Keychain and Keystore, and you should check their default accessibility settings rather than assume them. Also check what the framework writes to logs, caches and crash reports, and whether sensitive screens are excluded from backups and app-switcher snapshots.
Certificate pinning: when it helps and how to avoid outages
Standard TLS validation trusts any certificate issued by a certificate authority the device trusts. Pinning narrows that to specific keys you control, which defends against interception using a mis-issued certificate or a user-installed root certificate. It also makes casual traffic inspection of your API harder.
The cost of pinning
The risk is self-inflicted outage. If the server’s key changes and the app does not recognise the new one, every installed copy stops working until users update. Android’s network security configuration documentation is explicit: always include a backup key, because without one a key or certificate-authority change means pushing an app update to restore connectivity. It also notes that setting an expiry on pins avoids bricking apps that are not updated, but weakens protection once the expiry passes.
Options compared
| Approach | Protection | Operational risk | Suits |
|---|---|---|---|
| No pinning, standard TLS | Good against most network attackers | Lowest | Most consumer and business apps with modest sensitivity |
| Pin intermediate or CA public key | Moderate; limits trusted issuers | Medium; breaks if you change CA | Apps wanting extra assurance with simple operations |
| Pin your own leaf public keys with backups | Strongest | Highest; requires disciplined key rotation | Banking, health, high-value transactions |
| Dynamic pin updates delivered from a trusted channel | Strong, with flexibility | Complex to build and secure | Large apps with dedicated security teams |
If you pin, do it properly
- Pin the public key (SubjectPublicKeyInfo hash), not the whole certificate, so renewals that keep the key do not break the app.
- Ship at least one backup pin for a key you hold offline.
- Document the rotation procedure and put the certificate expiry dates in the operations calendar.
- Use Android’s declarative configuration or a well-tested library rather than hand-written trust logic, and make sure debug overrides are never active in release builds.
- Monitor connection failures after each certificate change.
Remember that pinning protects the channel, not the app. On a device the user controls, pinning can be removed by modifying the app. It raises the bar; it does not make your API private.
Jailbreak and root detection versus server-side attestation
Jailbreak and root detection checks look for signs that the operating system’s protections have been removed: unexpected files, writable system partitions, hooking frameworks or debuggers. They are popular because they are easy to list in a requirements document. They are also easy to bypass, because the checks run inside the very environment the attacker controls.
What on-device checks are good for
- Warning users that their device is less safe for sensitive data.
- Adding friction for casual tampering and for automated tools that are not configured to hide.
- Feeding a risk signal to the server, alongside other signals.
What they are not good for
- Being the only thing standing between an attacker and a valuable action.
- Blocking users outright, unless your regulator or risk appetite demands it. False positives on customised but legitimate devices produce support tickets and lost customers.
Attestation moves the decision to the server
Platform attestation services let your back end ask the platform whether a request comes from your genuine app on a genuine device. On Android, Google’s Play Integrity API, which replaces the deprecated SafetyNet Attestation, returns verdicts on app integrity (whether the binary is recognised by Google Play), device integrity and account licensing. Google recommends checking a request hash or nonce on the server to prevent replay, applying tiered trust rather than a simple allow or deny, and not relying on Play Integrity as the sole anti-abuse mechanism. The documented default quota of 10,000 requests per day also means you should call it for important actions rather than every screen. On iOS, Apple’s App Attest service in the DeviceCheck framework plays a similar role.
A layered resilience design
- Server-side authorisation and rate limits on every sensitive endpoint, regardless of client signals.
- Attestation on high-value actions such as sign-up, payout, redemption or high-value purchase.
- On-device root, jailbreak, debugger and hooking signals reported to the server as risk inputs.
- Code obfuscation and integrity checks where reverse engineering would cause real loss.
- Graduated responses: allow, allow with limits, require step-up verification, or deny.
For example, a loyalty app might let a rooted device browse offers but require attestation and a step-up check before redeeming points worth real money. That keeps legitimate users while putting cost on fraud.
How to choose the right security level for your app
Not every app needs every control. Over-engineering resilience in a low-risk app wastes budget and increases the chance of false positives; under-engineering a financial or health app invites real harm. The tiers below are a practical starting point, similar in spirit to OWASP’s MAS testing profiles.
| Tier | Examples | Controls |
|---|---|---|
| Baseline | Content, productivity and internal business apps without sensitive personal data | MASVS storage, crypto, auth, network, platform, code and privacy groups; keystore for tokens; standard TLS |
| Sensitive | Apps holding personal, health or business-confidential data | Baseline plus strict keystore accessibility, biometric-bound keys for sensitive actions, screenshot and backup controls, consider public-key pinning, independent security testing before launch |
| High value | Payments, wallets, loyalty with cash value, paid content, regulated finance and health | Sensitive plus attestation on key actions, resilience controls, obfuscation, server-side fraud signals, periodic penetration testing |
Questions to settle with stakeholders
- Which customer, regulator or contract requirements apply, and do they reference MASVS or another standard?
- What is the worst realistic outcome if one device is compromised? If many accounts are abused?
- What false-positive rate is acceptable for device checks?
- Who owns certificate rotation and attestation configuration in operations?
Record the answers as non-functional requirements. They will drive estimates, test plans and vendor selection.
Implementing and testing it within normal delivery
Security is cheapest when it is part of every sprint rather than a phase before launch. The pattern we follow is to translate the agreed MASVS scope into user stories, acceptance criteria and test cases, then verify continuously.
Step-by-step
- Requirements. Map each in-scope MASVS control to a story or acceptance criterion, for example “refresh token stored in Keychain with this-device-only accessibility”.
- Architecture review. Check token lifecycle, back-end authorisation, data cached offline and third-party SDKs before coding starts.
- Secure defaults in the codebase. Shared wrappers for storage, networking and logging so individual features cannot bypass them.
- Automated checks. Dependency and SDK scanning, static analysis and secret scanning in the pipeline, which also makes enterprise security questionnaires easier to answer, as covered in our guide to SOC 2 readiness and security questionnaires.
- Manual verification. Testers use MASTG test cases on real devices, including inspecting storage, backups and traffic through a proxy. The API behind the app needs the same rigour; see performance testing for mobile backends.
- Independent testing for sensitive and high-value tiers before launch and after major changes.
- Operations. Monitor crash and connection failures after certificate changes, track attestation failure rates and patch dependencies promptly.
Authentication deserves its own attention
Many storage and session risks disappear when you reduce reliance on passwords and long-lived tokens. Passkeys and short-lived tokens with server-side revocation are worth evaluating; see our guide to Sign in with Apple, passkeys and account deletion on iOS.
Common mistakes, costs and a release checklist
Mistakes we see repeatedly
- Tokens or personal data in shared preferences, plain files, logs or analytics events.
- Pinning a single certificate with no backup and no rotation plan.
- Hard-blocking rooted or jailbroken devices with checks that are trivially bypassed, while the API trusts the client.
- Secrets or privileged API keys embedded in the app binary.
- WebViews with JavaScript bridges exposed to untrusted content.
- Third-party SDKs collecting more data than the privacy policy states.
- Debug flags, test endpoints or verbose logging left in release builds.
Where the cost sits
Baseline controls add little cost when designed in from the start; they are mostly decisions and shared code. Costs rise with resilience requirements, attestation integration, independent testing and the operational work of certificate rotation. Retro-fitting secure storage or token handling after launch is usually far more expensive than doing it in the first sprints, because it touches login, offline data and migrations for existing users.
Release checklist
- MASVS scope agreed and mapped to stories and test cases.
- Tokens and keys only in Keychain or Keystore, with accessibility settings reviewed.
- No sensitive data in logs, analytics, crash reports, backups or app-switcher snapshots.
- TLS enforced everywhere; cleartext traffic disabled; pinning (if used) has backup pins and a documented rotation plan.
- Server enforces authorisation and rate limits independently of client checks.
- Attestation integrated on high-value actions, with graduated responses and outage handling.
- Dependencies and SDKs scanned and up to date; no secrets in the binary.
- Release build has debugging disabled and obfuscation configured where required.
- Privacy declarations and permissions match actual data collection.
- Independent security test completed for sensitive and high-value tiers.
Frequently asked questions
Is OWASP MASVS a certification?
MASVS is a verification standard, not a certificate you buy. Companies use it to define requirements, guide testing and communicate security posture to customers. Some organisations ask vendors to show MASVS-mapped test results or an independent assessment against it.
Do we need certificate pinning?
Not always. Standard TLS with proper validation protects most apps well. Pinning is worth considering for apps handling sensitive or high-value data, but only with backup pins, public-key pinning and a tested rotation process, because a mistake can take the app offline.
Should we block rooted and jailbroken devices?
Usually not outright. On-device detection can be bypassed and can produce false positives. A better approach is to treat it as a risk signal, combine it with server-side attestation and apply stricter controls only to high-value actions.
Are React Native and Flutter apps less secure than native apps?
Not inherently. Both can use the platform keystores and network security features through native modules or libraries. The risks are in library choice, default settings and what the framework writes to logs or caches, so they need the same review as native code.
How much does a mobile penetration test cost and when should we do one?
Cost depends on app size, platforms and depth, so get quotes against a defined MASVS scope. For sensitive and high-value apps, test before first launch and after major changes to authentication, payments or data storage; earlier internal MASTG-based testing reduces findings and retest cost.
Sources and methodology
Guidance reflects PoliteTech delivery experience. The external references below informed specific points in this article.
- OWASP Mobile Application Security: MASVS — accessed 9 November 2026. The eight MASVS control groups, including PRIVACY, and their relationship to the MASWE weakness catalogue and the MASTG testing guide.
- Apple Platform Security: Keychain data protection — accessed 9 November 2026. Secure Enclave protection of keychain items, accessibility classes and the behaviour of this-device-only items for sync and backup.
- Android Developers: Android Keystore system — accessed 9 November 2026. Non-exportable keys, hardware binding (TEE, StrongBox), immutable key authorisations and biometric-bound key invalidation.
- Android Developers: Network security configuration — accessed 9 November 2026. Public-key pinning with pin-set, the advice to always include a backup key, and the trade-off of pin expiration.
- Android Developers: Play Integrity API overview — accessed 9 November 2026. App, device and licensing verdicts, server-side nonce or request-hash checks, tiered trust, the default 10,000 requests per day quota and the advice not to rely on it alone.
Related reading
Continue your research
Would your app pass a MASVS-based security review today?
We can review your mobile app and back end against the MASVS controls that matter for your risk level and give you a prioritised list of fixes.
