Most mobile login bugs I audit do not happen in the UI—they happen because a developer wired up Face ID or Android's BiometricPrompt like an if statement. The prompt succeeds, returns true, and the app either unlocks a locally cached JWT or fires a /login call with a hardcoded device flag. On a test phone, it feels slick. Under a basic Frida hook on a jailbroken device, that boolean check collapses in thirty seconds.
When companies build regulated, fintech, healthcare, or B2B field apps, biometric login cannot be cosmetic convenience. It has to prove two things to your backend: the physical device holds a hardware-bound private key, and the OS just verified the user's biometrics to unlock that specific key.
Why Boolean Biometric Checks Fail Security Audits
A local-only prompt separates the authentication check from the credential that grants server access. Even if you store a refresh token in Keychain or EncryptedSharedPreferences, storing it without biometric access-control flags on the cryptographic key means any process running with user-level access on a compromised device can read the token without triggering Face ID.
| Implementation Pattern | Key Storage | Server Verification | Bypass Risk | Best Fit |
|---|---|---|---|---|
| Boolean UI gate + saved token | Standard Keychain / SharedPrefs | None (sends old token) | High (runtime hook bypasses prompt) | Low-risk consumer preferences only |
| Hardware key + challenge signing | Secure Enclave / Android Keystore (TEE/StrongBox) |
Verifies ECDSA signature per login | Low (key never leaves hardware) | Fintech, enterprise, B2B SaaS |
| Passkeys (FIDO2 / WebAuthn) | Synced platform credential manager | Verifies WebAuthn assertion | Very Low (phishing-resistant) | Cross-device consumer & enterprise apps |
For most native and cross-platform apps built with mobile app development teams, hardware-backed asymmetric challenge-response gives you full control over device revocation, enrollment UX, and offline unlock without forcing every customer into passkey education on day one.
The Cryptographic Enrollment and Sign-In Flow
Your backend never sees a fingerprint or face scan. Both iOS (following Apple's LocalAuthentication + Secure Enclave model) and Android (following Android's app architecture and keystore guidance) isolate biometric matching inside secure hardware. Your app's job is to bind an ECDSA P-256 keypair to that hardware gate.
Step 1: Device Enrollment After Strong Login
Enrollment only happens after the user signs in with their primary factor (password + MFA, SSO, or magic link):
- The mobile app asks Secure Enclave / Android Keystore to generate an ECDSA P-256 keypair with
userAuthenticationRequired = trueand invalidation on new biometric enrollment. - The app sends the public key (
SPKIbase64), device metadata, and platform attestation (App Attest / Play Integrity token if required) toPOST /api/v1/auth/biometrics/register. - The backend stores the public key tied to
user_idanddevice_id, returning a uniquecredential_id.
CREATE TABLE user_biometric_keys (
id BIGSERIAL PRIMARY KEY,
user_id BIGINT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
device_id VARCHAR(128) NOT NULL,
credential_id VARCHAR(128) NOT NULL UNIQUE,
public_key_pem TEXT NOT NULL,
platform VARCHAR(16) NOT NULL CHECK (platform IN ('ios', 'android')),
last_used_at TIMESTAMPTZ,
revoked_at TIMESTAMPTZ,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
CREATE INDEX idx_biometric_user_active
ON user_biometric_keys (user_id, device_id)
WHERE revoked_at IS NULL;
Step 2: Challenge-Response Verification on Login
Every time the user taps "Sign in with Face ID" or opens a locked session:
- Client calls
POST /api/v1/auth/biometrics/challengewithcredential_id. - Server generates a 32-byte cryptographically random
nonce, caches it in Redis with a 60-second TTL bound tocredential_id, and returns{ "challenge": "..." }. - Client passes a signing operation (
CryptoObjecton Android,SecKeyCreateSignatureon iOS) into the OS biometric prompt. The OS unlocks the private key only after the biometric match succeeds. - Client posts
{ "credential_id", "challenge", "signature" }toPOST /api/v1/auth/biometrics/verify. - Server consumes the Redis nonce atomically (
GETDEL), verifies the ECDSA signature againstpublic_key_pem, and mints a fresh short-lived access token + rotating refresh token.
{
"request": {
"credential_id": "cred_8f31c9a04e2b",
"challenge": "b9J0v8Y2sQ4kL7mP1xR5tW8zN3cF6hK9",
"signature": "MEUCIQDx4...base64_der_ecdsa_signature...=="
},
"response": {
"access_token": "eyJhbGci...",
"expires_in": 900,
"refresh_token": "rt_live_92a7...",
"biometric_verified_at": "2026-04-13T09:14:22Z"
}
}
Because the nonce is single-use and expires in 60 seconds, replaying a captured network request fails immediately. Because the private key cannot sign without OS biometric approval, hooking the Flutter or React Native UI layer gains an attacker nothing.
Handling Cross-Platform Bridges Without Breaking Performance
In Flutter and React Native, standard "local_auth" wrappers often only expose the boolean OS dialog—not CryptoObject signing. You have two clean options:
- Use a cryptographic biometric plugin or write a thin native module (~120 lines of Swift and Kotlin) exposed over a MethodChannel / TurboModule. Keeping the signing call off the UI isolate—following Flutter's performance best practices—prevents frame drops while hardware keys initialize.
- Pair biometric unlock with encrypted local storage for offline apps. If your app works offline (field inspection, logistics, clinical notes), wrap a local data encryption key (DEK) with the hardware biometric key, rather than storing raw user tokens in plaintext SQLite.
Edge Cases That Break Production Support Tickets
Biometric systems fail silently when engineering teams only test happy paths on a flagship iPhone:
1. Biometric Enrollment Changes
When a user registers a spare finger on Android or sets up an alternate appearance in Face ID, setInvalidatedByBiometricEnrollment(true) (Android) and biometryCurrentSet (iOS) invalidate the private key. Catch KeyPermanentlyInvalidatedException and errSecItemNotFound explicitly, delete the local credential_id, call DELETE /api/v1/auth/biometrics/{id} if online, and prompt password + MFA re-enrollment with a clear message instead of a generic "Authentication failed."
2. Lockout and Device Passcode Fallback
After five failed Face ID attempts, iOS locks biometrics until the user enters the device passcode. Decide upfront whether your threat model allows device passcode fallback (deviceCredential / .userPresence) or requires strict biometrics only (.biometryCurrentSet + BIOMETRIC_STRONG). In shared-tablet environments (warehouses, clinics), never allow device-PIN fallback to unlock a single employee's session.
3. Multi-Account and Shared Devices
Store a map of user_id -> credential_id only if your app intentionally supports account switching; otherwise overwrite any prior biometric binding on that device during login so a departing employee's biometrics cannot re-enter a corporate account.
4. Remote Session and Device Revocation
Expose a "Trusted Devices" screen on both mobile and web. When an admin disables an employee or a user reports a lost phone, setting revoked_at in user_biometric_keys plus revoking active refresh tokens stops biometric re-entry immediately—even before the old phone checks in.
Pre-Launch Security Checklist
Before shipping biometric auth to TestFlight or Google Play closed testing, verify these five conditions:
- StrongBox / Secure Enclave fallback tested: Older Android devices without StrongBox fall back to TEE; ensure your key generator gracefully handles
StrongBoxUnavailableExceptionwithout crashing. - Single-use challenge consumption: Confirm concurrent verify requests with the same
noncereturn401on the second call via atomic RedisGETDEL. - Root/jailbreak and step-up rules defined: High-risk actions (wire transfers, exporting patient records, changing payout bank details) should force a fresh biometric signature (
max_auth_age <= 60s), not reuse a 15-minute session token. - Clean key cleanup on logout: Explicit sign-out should revoke the server credential or require fresh password authentication before re-binding, depending on whether your product offers "quick unlock" vs "full sign-out."
If you are planning a new mobile release or hardening an existing auth flow, our launch consulting sessions and case studies show how we pair Laravel/Node backends with native-grade Flutter and React Native security. At SmitDev, I work directly with teams at $55/day for 8–9 hours of dedicated engineering or $1,999/month dedicated delivery—backed by 170+ shipped projects across global markets.
Need a principal engineer to audit your biometric signing flow or build it cleanly from scratch? Reach out via our contact page with your target platforms and compliance requirements.