Software Engineering & Digital Products for Global Enterprises since 2006
CMMi Level 3SOC 2ISO 27001
View all services
Staff Augmentation
Embed senior engineers in your team within weeks.
Dedicated Teams
A ring-fenced squad with PM, leads, and engineers.
Build-Operate-Transfer
We hire, run, and transfer the team to you.
Contract-to-Hire
Try the talent. Convert when you're ready.
ForceHQ
Skill testing, interviews and ranking — powered by AI.
RoboRingo
Build, deploy and monitor voice agents without code.
MailGovern
Policy, retention and compliance for enterprise email.
Vishing
Test and train staff against AI-driven voice attacks.
CyberForceHQ
Continuous, adaptive security training for every team.
IDS Load Balancer
Built for Multi Instance InDesign Server, to distribute jobs.
AutoVAPT.ai
AI agent for continuous, automated vulnerability and penetration testing.
Salesforce + InDesign Connector
Bridge Salesforce data into InDesign to design print catalogues at scale.
View all solutions
Banking, Financial Services & Insurance
Cloud, digital and legacy modernisation across financial entities.
Healthcare
Clinical platforms, patient engagement, and connected medical devices.
Pharma & Life Sciences
Trial systems, regulatory data, and field-force enablement.
Professional Services & Education
Workflow automation, learning platforms, and consulting tooling.
Media & Entertainment
AI video processing, OTT platforms, and content workflows.
Technology & SaaS
Product engineering, integrations, and scale for tech companies.
Retail & eCommerce
Shopify, print catalogues, web-to-print, and order automation.
View all industries
Blog
Engineering notes, opinions, and field reports.
Case Studies
How clients shipped — outcomes, stack, lessons.
White Papers
Deep-dives on AI, talent models, and platforms.
Portfolio
Selected work across industries.
View all resources
About Us
Who we are, our story, and what drives us.
Co-Innovation
How we partner to build new products together.
Careers
Open roles and what it's like to work here.
News
Press, announcements, and industry updates.
Leadership
The people steering MetaDesign.
Locations
Gurugram, Brisbane, Detroit and beyond.
Contact Us
Talk to sales, hiring, or partnerships.
Request TalentStart a Project
Mobile Development

Security Best Practices in React Native Development

GS
Girish Sagar
Technical Content Lead
December 29, 2024
16 min read
Security Best Practices in React Native Development — Mobile Development | MetaDesign Solutions

Introduction: The React Native Security Landscape

React Native apps face unique security challenges that traditional native apps don't — JavaScript bundles can be extracted and decompiled, the bridge between JS and native layers introduces attack surfaces, and the npm ecosystem exposes applications to supply chain risks. OWASP's Mobile Top 10 consistently ranks insecure data storage, insufficient transport layer security, and improper authentication as the most exploited vulnerabilities.

In 2024-2025, mobile application attacks increased by 45%, with React Native apps specifically targeted for JavaScript bundle extraction, API key harvesting from decompiled bundles, and man-in-the-middle attacks on unprotected network connections. This guide covers the security architecture that protects React Native apps from the application layer through to production monitoring.

Secure Data Storage: Keychain, Keystore, and Encryption

Never store sensitive data in AsyncStorage — it saves data as unencrypted JSON files on disk, accessible on rooted/jailbroken devices:

  • react-native-keychain: Stores credentials in iOS Keychain (hardware-encrypted Secure Enclave on devices with Face ID/Touch ID) and Android Keystore (hardware-backed cryptographic key storage). Data is encrypted at rest and inaccessible to other apps.
  • react-native-sensitive-info: Alternative secure storage using SharedPreferences with encryption on Android and Keychain on iOS — suitable for tokens, session IDs, and user preferences.
  • Encrypted AsyncStorage: For larger data sets that must persist locally, use react-native-encrypted-storage which wraps AsyncStorage with AES-256 encryption.
  • In-Memory Only: For highly sensitive data (private keys, biometric templates), never persist to storage — keep in memory only and clear on app backgrounding using AppState listener.
  • Secure Deletion: When users log out, explicitly clear all stored credentials, tokens, and cached data — Keychain.resetGenericPassword() and clearing all AsyncStorage keys.

OWASP M2 (Insecure Data Storage) is preventable with proper storage selection.

Network Security: SSL Pinning and Certificate Transparency

Transport layer security prevents man-in-the-middle (MITM) attacks:

  • Enforce HTTPS: Configure NSAppTransportSecurity (iOS) and networkSecurityConfig (Android) to block all HTTP connections. Never allow cleartext traffic in production builds.
  • SSL Certificate Pinning: Use react-native-ssl-pinning or TrustKit to pin your server's SSL certificate or public key — preventing MITM attacks even when attackers install rogue CA certificates on the device. Pin the public key hash (SPKI) rather than the certificate itself for easier rotation.
  • Certificate Transparency: Verify that your server's SSL certificate is logged in public Certificate Transparency logs — detecting rogue certificates issued by compromised CAs.
  • API Request Signing: Sign API requests with HMAC-SHA256 using a per-session key — preventing request tampering and replay attacks. Include timestamp and nonce in signed payloads.
  • Response Validation: Validate all API response schemas client-side using libraries like zod or yup — preventing injection of malicious data through compromised APIs.

Test with proxy tools like Charles Proxy or mitmproxy to verify SSL pinning blocks interception.

Authentication: OAuth 2.0, Biometric, and Token Management

Robust authentication prevents unauthorised access (OWASP M6):

  • OAuth 2.0 + PKCE: Use react-native-app-auth for OAuth 2.0 with PKCE (Proof Key for Code Exchange) — the industry standard for mobile authentication that prevents authorisation code interception. Never use the Implicit Grant flow in mobile apps.
  • JWT Best Practices: Use short-lived access tokens (15 minutes) with long-lived refresh tokens (30 days). Store refresh tokens in Keychain/Keystore. Validate JWT signatures client-side before trusting claims. Include aud, iss, and exp claims.
  • Biometric Authentication: Use react-native-biometrics or expo-local-authentication for Face ID/Touch ID/fingerprint — providing a second factor without password friction. Generate cryptographic key pairs in the Secure Enclave tied to biometric enrollment.
  • Token Rotation: Implement automatic refresh token rotation — each refresh request returns a new refresh token and invalidates the previous one, preventing token replay attacks.
  • Session Management: Implement server-side session invalidation for logout, device changes, and suspicious activity. Use AppState to detect app backgrounding and apply session timeout policies.

Code Obfuscation: Hermes, ProGuard, and Bundle Protection

React Native JavaScript bundles can be extracted and reverse-engineered — obfuscation makes this significantly harder:

  • Hermes Bytecode: Enable the Hermes engine (default in React Native 0.70+) — Hermes compiles JavaScript to bytecode at build time, making the bundle significantly harder to decompile compared to plain JavaScript. Hermes bytecode is not human-readable.
  • ProGuard (Android): Enable ProGuard/R8 in build.gradle — minifies, optimises, and obfuscates Java/Kotlin native module code. Configure proguard rules to keep essential React Native bridge classes.
  • Metro Bundle Minification: Ensure Metro bundler minification is enabled for production builds — react-native bundle --minify true removes whitespace, shortens variable names, and tree-shakes unused code.
  • Additional Obfuscation: Use javascript-obfuscator as a Metro plugin for advanced techniques — string encryption, control flow flattening, dead code injection, and self-defending transformations.
  • Anti-Tampering: Implement runtime integrity checks that detect modifications to the JavaScript bundle — compare bundle hash against a server-provided checksum at launch.

Obfuscation is defense-in-depth — it raises the cost of reverse engineering but doesn't prevent determined attackers. Combine with server-side security for comprehensive protection.

Transform Your Publishing Workflow

Our experts can help you build scalable, API-driven publishing systems tailored to your business.

Book a free consultation

Dependency and Supply Chain Security

npm's vast ecosystem introduces supply chain attack vectors:

  • Regular Auditing: Run npm audit in CI/CD pipelines — fail builds on high/critical severity vulnerabilities. Integrate Snyk or Socket.dev for continuous dependency monitoring with automatic PR creation for vulnerable packages.
  • Lockfile Enforcement: Use npm ci (not npm install) in CI — ensures builds use exactly the locked dependency versions, preventing supply chain attacks through malicious package updates.
  • Dependency Pinning: Pin exact dependency versions in package.json (no ^ or ~) — preventing automatic installation of compromised minor/patch releases.
  • Minimal Dependencies: Audit every new dependency for necessity — check download counts, maintenance activity, and contributor reputation. Prefer well-maintained packages from the React Native community over unknown authors.
  • Native Module Auditing: Review native module source code for iOS/Android — native bridges have full device access. Verify that native modules don't request unnecessary permissions or contain hidden functionality.
  • License Compliance: Use license-checker to verify all dependencies use compatible open-source licenses — GPL dependencies in commercial apps create legal exposure.

Runtime Protection: Jailbreak Detection and Integrity Checks

Runtime protection detects and responds to compromised execution environments:

  • Jailbreak/Root Detection: Use jail-monkey or react-native-device-info to detect jailbroken iOS devices and rooted Android devices — restricting sensitive functionality or displaying security warnings when detected.
  • Debugger Detection: Check for attached debuggers at runtime — __DEV__ flag should be false in production builds. Detect debugging tools like Frida, Xposed, and Substrate that attackers use for runtime manipulation.
  • Screen Capture Prevention: Use react-native-screen-capture to prevent screenshots and screen recording of sensitive screens (payment forms, account details) — required for PCI DSS compliance.
  • Deep Link Validation: Validate all incoming deep links against an allowlist — malicious deep links can trigger unintended actions or bypass authentication flows. Use Universal Links (iOS) and App Links (Android) for verified deep linking.
  • Secure Clipboard: Clear clipboard content after paste operations for sensitive fields — preventing clipboard sniffing by other apps on the device.
  • Logging Hygiene: Strip all console.log statements from production builds using babel-plugin-transform-remove-console — preventing sensitive data from appearing in device logs accessible via adb logcat.

Compliance: GDPR, HIPAA, and Security Auditing

Enterprise React Native apps must meet regulatory compliance standards:

  • GDPR Compliance: Implement data minimisation (collect only necessary data), provide data export/deletion APIs, display cookie/tracking consent dialogs, and maintain a Record of Processing Activities (ROPA). Use react-native-tracking-transparency for iOS ATT framework compliance.
  • HIPAA Compliance: For healthcare apps — encrypt all Protected Health Information (PHI) at rest and in transit, implement audit logging for all PHI access, enforce session timeouts, and ensure BAA (Business Associate Agreement) coverage with all third-party services.
  • PCI DSS: For payment processing — never store card numbers client-side, use tokenisation via Stripe/Braintree SDKs, prevent screen capture on payment screens, and implement certificate pinning for payment API connections.
  • Penetration Testing: Conduct annual penetration tests using OWASP Mobile Testing Guide (MSTG) methodology — covering static analysis (decompilation, code review), dynamic analysis (runtime manipulation, API testing), and network analysis (MITM, certificate validation).
  • Security Monitoring: Integrate Sentry or Bugsnag for crash reporting with PII redaction — monitor for unusual patterns that indicate attack attempts (repeated auth failures, unusual API patterns, jailbreak detection triggers).

MDS provides comprehensive security audits aligned with OWASP MASVS (Mobile Application Security Verification Standard) — ensuring React Native apps meet enterprise security and compliance requirements from development through deployment.

FAQ

Frequently Asked Questions

Common questions about this topic, answered by our engineering team.

Key practices include using react-native-keychain for secure credential storage (never AsyncStorage for sensitive data), enforcing HTTPS with SSL certificate pinning, implementing OAuth 2.0 with PKCE for authentication, enabling Hermes bytecode compilation and ProGuard obfuscation, auditing npm dependencies with Snyk, implementing jailbreak/root detection, and stripping console.log from production builds.

Enable Hermes engine to compile JavaScript to bytecode (significantly harder to decompile than plain JS), use ProGuard/R8 for Android native code obfuscation, apply javascript-obfuscator for advanced techniques like string encryption and control flow flattening, implement runtime integrity checks with bundle hash verification, and use anti-tampering measures to detect bundle modifications.

Use OAuth 2.0 with PKCE flow via react-native-app-auth (never Implicit Grant). Store tokens in Keychain/Keystore, use short-lived access tokens (15min) with rotated refresh tokens (30 days), implement biometric authentication as a second factor, and apply server-side session invalidation on logout, device changes, and suspicious activity.

GDPR requires data minimisation, export/deletion APIs, and consent dialogs. HIPAA mandates PHI encryption, audit logging, and BAAs with third parties. PCI DSS requires tokenised payments and screen capture prevention. Annual penetration testing using OWASP MSTG methodology covers static, dynamic, and network analysis.

Run npm audit in CI/CD pipelines (fail on high/critical vulnerabilities), use npm ci for deterministic installs from lockfile, pin exact dependency versions (no ^ or ~ prefixes), audit native module source code for hidden functionality, integrate Snyk or Socket.dev for continuous monitoring, and verify open-source license compliance with license-checker.

Discussion

Join the Conversation

Ready when you are

Let's build something great together.

A 30-minute call with a principal engineer. We'll listen, sketch, and tell you whether we're the right partner — even if the answer is no.

Talk to a strategist
Need help with your project? Let's talk.
Book a call