The Gap Between Compliance and Security
Passing a PCI DSS audit does not make your app secure. It means your app meets the minimum requirements for handling cardholder data. A determined attacker does not consult your compliance certificate before probing for vulnerabilities.
The gap between compliance and security is where real-world breaches happen. Compliance tells you to encrypt data at rest. Security engineering tells you which encryption algorithm, how to manage keys, what to do when a device is compromised, and how to detect that the encryption was bypassed at runtime.
This guide bridges that gap. We map regulatory requirements to engineering controls, provide implementation patterns, and give you the audit checklist that should run on every release.
Regulatory Mapping: What Each Standard Requires
| Requirement | PCI DSS v4.0 | PSD2 (EU) | SOC 2 Type II | OWASP MASVS |
|---|---|---|---|---|
| Encrypt data at rest | Req 3.5 | Art. 95 (security measures) | CC6.1 | MASVS-STORAGE |
| Encrypt data in transit | Req 4.2 | Art. 95 | CC6.1 | MASVS-NETWORK |
| Strong customer authentication | N/A | Art. 97 (SCA) | CC6.1 | MASVS-AUTH |
| Secure key management | Req 3.6–3.7 | Implied by Art. 95 | CC6.1 | MASVS-CRYPTO |
| Access control | Req 7–8 | Art. 95 | CC6.2–CC6.3 | MASVS-AUTH |
| Logging and monitoring | Req 10 | Art. 96 (incident reporting) | CC7.1–CC7.3 | MASVS-RESILIENCE |
| Vulnerability management | Req 6.3 | Implied | CC7.1 | MASVS-CODE |
| Tamper detection | Req 11.6 | Implied by SCA | CC7.2 | MASVS-RESILIENCE |
| Incident response | Req 12.10 | Art. 96 (72-hour notification) | CC7.4 | Not in scope |
OWASP MASVS Compliance Matrix for Fintech
MASVS organizes mobile security into categories. Here is how each maps to fintech requirements:
| MASVS Category | Fintech Relevance | Key Controls |
|---|---|---|
| MASVS-STORAGE | Card data, tokens, PII | No sensitive data in plaintext files, logs, or backups. Keychain/Keystore for secrets. |
| MASVS-CRYPTO | Transaction signing, token generation | No deprecated algorithms (MD5, SHA1, DES). Key derivation with PBKDF2 or Argon2. Hardware-backed keys where available. |
| MASVS-AUTH | Login, SCA, session management | Biometric + device binding. Session tokens expire. Re-authentication for sensitive operations. |
| MASVS-NETWORK | API communication, payment processing | TLS 1.2+. Certificate pinning. No cleartext traffic. |
| MASVS-PLATFORM | OS-level integration | No exported components leaking data. Deep link validation. Secure WebView configuration. |
| MASVS-CODE | Binary protection | Obfuscation. No debugging symbols in release builds. Dependency vulnerability scanning. |
| MASVS-RESILIENCE | Anti-tampering | Jailbreak detection. Debugger detection. Integrity checks. RASP. |
Certificate Pinning: Implementation That Survives Rotation
Certificate pinning ensures the app only trusts specific server certificates, defeating man-in-the-middle attacks even when a compromised CA issues a fraudulent certificate.
Pin to Public Keys, Not Certificates
Certificates expire and rotate. Public keys can persist across certificate renewals if you reuse the key pair. Pin to the Subject Public Key Info (SPKI) hash:
Certificate Pinning Strategy:
┌───────────────────────────────────┐
│ App ships with: │
│ Primary pin: sha256/AAAA... │ ← Current server public key
│ Backup pin: sha256/BBBB... │ ← Next rotation key (pre-generated)
│ Emergency: sha256/CCCC... │ ← CA public key (last resort)
└───────────────────────────────────┘
Rotation flow:
1. Generate new key pair (DDDD) on server
2. Push DDDD as the new backup via config endpoint
3. Renew certificate using the BBBB key pair
4. App validates against BBBB (now primary)
5. Old AAAA pin expires from app config
Conceptual Implementation (OkHttp / Android)
#6a9955]">// Conceptual — adapt to your HTTP client and pin management strategy
val certificatePinner = CertificatePinner.Builder()
.add(
"api.example.com",
"sha256/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=", #6a9955]">// Primary
"sha256/BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB=" #6a9955]">// Backup
)
.build()
val client = OkHttpClient.Builder()
.certificatePinner(certificatePinner)
.build()
iOS: App Transport Security + TrustKit
On iOS, App Transport Security (ATS) enforces TLS by default. For pinning, use TrustKit or implement the URLSessionDelegate challenge handler with SPKI hash comparison.
Runtime Application Self-Protection (RASP)
Static security (obfuscation, encryption at rest) protects the app binary. Runtime protection detects and responds to attacks while the app is running.
RASP Protection Layers
┌─────────────────────────────────────────────────┐
│ App Binary │
├─────────────────────────────────────────────────┤
│ Layer 1: Environment Checks │
│ • Jailbreak / root detection │
│ • Emulator detection │
│ • Debugger detection (ptrace, sysctl) │
├─────────────────────────────────────────────────┤
│ Layer 2: Integrity Checks │
│ • Binary signature verification │
│ • Code segment hash validation │
│ • Resource file integrity │
├─────────────────────────────────────────────────┤
│ Layer 3: Instrumentation Detection │
│ • Frida detection (port scanning, artifacts) │
│ • Xposed framework detection (Android) │
│ • Method swizzling detection (iOS) │
├─────────────────────────────────────────────────┤
│ Layer 4: Response │
│ • Block sensitive operations │
│ • Wipe local secrets │
│ • Alert server-side monitoring │
│ • Graceful degradation (read-only mode) │
└─────────────────────────────────────────────────┘
Jailbreak Detection Vectors (iOS)
No single check is reliable against sophisticated jailbreaks. Use multiple vectors:
Detection vectors (check all, fail if any positive):
1. File existence: /Applications/Cydia.app, /private/var/lib/apt
2. URL scheme: Can the app open cydia:#6a9955]">// ?
3. Sandbox escape: Can the app write to /private/ ?
4. Fork behavior: Can the app call fork()? (blocked on stock iOS)
5. Dylib injection: Are unexpected dynamic libraries loaded?
6. Symbol resolution: Can the app resolve Substrate or libhooker symbols?
Root Detection Vectors (Android)
Detection vectors:
1. Binary existence: /system/xbin/su, /system/bin/su
2. Build tags: Does Build.TAGS contain "test-keys"?
3. Package presence: com.topjohnwu.magisk, eu.chainfire.supersu
4. Property check: ro.debuggable = 1, ro.secure = 0
5. Mount check: /system mounted as read-write
6. SELinux status: Is SELinux in permissive mode?
Response Policy
Detection without response is a security log entry, not a security control. Define what happens when a compromised environment is detected:
| Threat Level | Detection | Response |
|---|---|---|
| Low | Emulator detected | Block in production builds; allow in debug |
| Medium | Jailbreak/root detected | Disable biometric auth, require PIN + OTP. Alert server. |
| High | Debugger attached | Terminate session. Wipe local tokens. Alert server. |
| Critical | Binary tampering detected | Refuse to launch. Wipe all local data. Report to fraud team. |
Threat Model: Payment App vs. Banking App
The security profile differs by app type:
Payment App (e.g., checkout, POS, payment link)
Data flow:
Card data → Tokenize (client-side, never store PAN) → Send token to payment processor
Key threats:
• Man-in-the-middle capturing card data before tokenization
• Screen overlay attacks capturing card entry
• Memory scraping for card data in transit
Key controls:
• Certificate pinning on tokenization endpoint
• Secure input fields (disable screenshots, clipboard, autocomplete)
• Memory wiping after tokenization completes
• PCI DSS SAQ A-EP or SAQ D depending on integration model
Banking App (e.g., account management, transfers)
Data flow:
Persistent session → Account data, balances, transaction history → Transfers, payments
Key threats:
• Session hijacking via token theft
• Credential stuffing if password-only auth
• Transaction tampering via MITM or local instrumentation
• Social engineering via fake push notifications
Key controls:
• Device binding (cryptographic key stored in Keychain/Keystore)
• Transaction signing with device-bound key
• Push notification verification (server-initiated challenge)
• Session timeout with re-authentication for sensitive operations
• PSD2 SCA for all payment initiation
Secure Data Storage
What Must Never Be Stored in Plaintext
| Data | Storage Rule | Platform Mechanism |
|---|---|---|
| Card numbers (PAN) | Never store. Tokenize immediately. | N/A — do not persist |
| Authentication tokens | Encrypted at rest, hardware-backed | iOS Keychain (kSecAttrAccessibleWhenUnlockedThisDeviceOnly), Android Keystore |
| Biometric templates | Never extracted from secure enclave | iOS Secure Enclave, Android StrongBox |
| User PII | Encrypted at rest | SQLCipher or platform encryption APIs |
| API keys | Not in source code, not in app bundle | Fetched from server after authentication |
| Transaction logs | Encrypted, time-limited retention | Encrypted local DB with TTL-based purge |
Security Audit Checklist (Per Release)
Run this checklist before every production release, not just at launch:
Network Security
- [ ] TLS 1.2+ enforced, no fallback to 1.0 or 1.1
- [ ] Certificate pinning active with backup pins
- [ ] No cleartext HTTP traffic (verify with network proxy)
- [ ] API endpoints validate authentication on every request
Data Storage
- [ ] No sensitive data in application logs (search for PAN patterns, tokens, passwords)
- [ ] No sensitive data in app backups (Android: allowBackup=false, iOS: exclude from iCloud)
- [ ] Tokens and secrets stored in Keychain/Keystore, not SharedPreferences/UserDefaults
- [ ] Local database encrypted (SQLCipher or equivalent)
Authentication
- [ ] Biometric authentication bound to device key, not just a UI gate
- [ ] Session tokens expire and require re-authentication
- [ ] Failed login attempts are rate-limited server-side
- [ ] PSD2 SCA implemented for applicable transactions
Binary Protection
- [ ] Code obfuscation applied (ProGuard/R8 for Android, bitcode + symbol stripping for iOS)
- [ ] No debugging symbols in release builds
- [ ] Third-party dependency vulnerability scan completed (no critical or high CVEs)
Runtime Protection
- [ ] Jailbreak/root detection active with defined response policy
- [ ] Debugger detection active
- [ ] Integrity check on app binary at launch
- [ ] Screenshot and screen recording disabled on sensitive screens
Compliance
- [ ] PCI DSS self-assessment questionnaire (SAQ) reviewed for applicable scope
- [ ] Data processing records updated for GDPR/privacy requirements
- [ ] Incident response plan tested within the last 12 months
- [ ] Penetration test completed within the last 12 months (or after major changes)
Common Mistakes in Fintech App Security
1. Treating Compliance as Security
PCI DSS Requirement 6.3 says to identify and manage vulnerabilities. It does not say how to detect Frida hooking your payment flow at runtime. Compliance is the floor, not the ceiling.
2. Certificate Pinning Without Rotation
A pinned certificate expires. If the app has no mechanism to update pins, every user is locked out until they update the app. Build a pin-update mechanism into the app from day one.
3. Client-Side-Only Validation
Never trust the client for security decisions. Jailbreak detection runs on the client and can be bypassed. The server must enforce transaction limits, authentication, and authorization independently of what the client reports.
4. Storing Card Data "Temporarily"
There is no temporary storage of PANs that is PCI-compliant without full PCI DSS certification. Tokenize card data at the point of capture using a PCI-certified payment processor's SDK. The card number should never exist in your application's memory longer than the time it takes to send it to the tokenization endpoint.
5. Skipping Security on Internal Builds
Debug builds with security disabled are the builds that get leaked, reverse-engineered, and used to map your API surface. Apply obfuscation and certificate pinning to all builds. Use feature flags, not build variants, to toggle debug capabilities.
The Bottom Line
Mobile app security in financial services is a layered discipline. Regulatory compliance (PCI DSS, PSD2, SOC 2) defines the boundaries. OWASP MASVS provides the verification framework. And runtime protections — certificate pinning, RASP, jailbreak detection, integrity checks — close the gap between what the checklist requires and what an attacker actually tries.
Run the audit checklist on every release. Test the runtime protections with real attack tools (Frida, objection, Burp Suite). And remember: the goal is not to pass an audit. The goal is to protect your users' money.




