Biometric Authentication Security
Mobile Cryptographic Implementation · Mobile Application Security track
15 min read
In this module
Biometrics on Mobile Devices
Fingerprint, face, iris — biometrics now run the unlock and most sensitive in-app authorisations. The security of all that depends entirely on how the result gets used. A check that hands the app a true boolean is a totally different beast from one that unlocks a hardware-protected key.
This split — local authentication vs cryptographic authentication — is the one idea in mobile biometric security you cannot afford to fudge. Get it wrong and the whole flow becomes theatre.
iOS: Face ID and Touch ID
Secure Enclave Processing
On iOS, every biometric operation happens inside the Secure Enclave. The sensor captures raw data — fingerprint ridges, a 3D depth map of a face — and pipes it directly to the Enclave. The main application processor never lays eyes on it.
Inside the Enclave, the raw capture becomes a mathematical template, stored in encrypted memory. New captures are matched against the stored template, again entirely inside the Enclave. The only thing leaving the chip is the verdict: match or no match.
Key security properties of this design:
- No template export: Biometric templates never leave the Secure Enclave. They are not included in backups, not synced to iCloud, and not accessible to any software on the device.
- No cross-device transfer: Templates are encrypted with the device's hardware UID key. They cannot be moved to another device.
- Anti-replay: Each biometric session uses a fresh nonce to prevent replay attacks.
- Liveness detection: Face ID uses an infrared depth camera (TrueDepth) that builds a 3D model of the face, making flat photograph attacks ineffective. Touch ID sensors detect the electrical properties of living skin.
iOS LAContext API
The LocalAuthentication framework provides the LAContext class for requesting biometric authentication:
let context = LAContext()var error: NSError?
if context.canEvaluatePolicy( .deviceOwnerAuthenticationWithBiometrics, error: &error) {
context.evaluatePolicy( .deviceOwnerAuthenticationWithBiometrics, localizedReason: "Authorise payment") { success, error in if success { // User authenticated self.proceedWithPayment() } }}This is local authentication. The success boolean is the only thing the app gets, and from there the app decides what happens next. Convenient, sure. Hopelessly insecure for anything that matters, as you'll see.
Android: BiometricPrompt API
Biometric Strength Classes
Android classifies biometric sensors into three strength classes defined in the Android Compatibility Definition Document (CDD):
- Class 3 (Strong): Must have a spoof acceptance rate below 7%, meet presentation attack detection requirements, and support cryptographic biometric authentication. Required for hardware-backed key unlocking.
- Class 2 (Weak): Meets basic biometric accuracy requirements but may not have strong anti-spoofing. Cannot be used for cryptographic authentication.
- Class 1 (Convenience): Lowest accuracy tier. Suitable only for device unlock convenience, not for security-sensitive operations.
The BiometricPrompt API allows developers to specify the minimum strength they require:
val promptInfo = BiometricPrompt.PromptInfo.Builder() .setTitle("Authorise Transaction") .setSubtitle("Confirm payment of GBP 50.00") .setAllowedAuthenticators( BiometricManager.Authenticators.BIOMETRIC_STRONG) .setNegativeButtonText("Cancel") .build()
biometricPrompt.authenticate(promptInfo, cryptoObject)Specify BIOMETRIC_STRONG and only Class 3 biometrics will satisfy the prompt. If the device tops out at Class 2 (older face unlocks, for example), authentication fails outright rather than quietly downgrading behind your back.
Biometric Processing on Android
Where iOS has one Apple-designed Secure Enclave, Android leaves the implementation to whoever builds the device. The CDD lays out the floor:
- Biometric template storage must be in the TEE or a dedicated secure element.
- Matching must occur in the TEE or secure element.
- Raw biometric data must not be accessible to the application processor after enrolment.
Quality across manufacturers ranges from "audited and trustworthy" to "we shipped it on a Friday". The strength classification system exists exactly because of that variance — it lets apps demand a minimum level without tying themselves to specific hardware.
The Boolean Problem: Local vs Cryptographic Authentication
This is the part that gets people fired. Consider two ways to authorise a bank transfer:
Approach 1: Local Authentication (Insecure)
// iOS - INSECURE approachcontext.evaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, localizedReason: "Authorise transfer") { success, _ in if success { // Boolean check passed - proceed self.sendTransferRequest(amount: 5000) }}// Android - INSECURE approachbiometricPrompt.authenticate(promptInfo)// In callback:override fun onAuthenticationSucceeded(result: ...) { // Boolean check passed - proceed sendTransferRequest(amount = 5000)}The problem: that success boolean lives in app memory and nowhere else. An attacker with Frida or any other runtime instrumentation tool can:
- Hook the callback function.
- Force the
successparameter totrue. - Watch the app cheerfully proceed as if a real user just authenticated.
No biometric ever ran. One flipped boolean in process memory and the entire check evaporates.
Approach 2: Cryptographic Authentication (Secure)
It starts when the key is created. The access-control flags at creation time are what make the key biometric-gated; without them the later code signs for anyone.
// iOS - create the key once, inside the Secure Enclavelet access = SecAccessControlCreateWithFlags( nil, kSecAttrAccessibleWhenPasscodeSetThisDeviceOnly, [.privateKeyUsage, .biometryCurrentSet], // invalidated if enrolment changes nil)!let attributes: [String: Any] = [ kSecAttrKeyType as String: kSecAttrKeyTypeECSECPrimeRandom, kSecAttrKeySizeInBits as String: 256, kSecAttrTokenID as String: kSecAttrTokenIDSecureEnclave, kSecPrivateKeyAttrs as String: [ kSecAttrIsPermanent as String: true, kSecAttrApplicationTag as String: "transfer-signing-key", kSecAttrAccessControl as String: access ]]var error: Unmanaged<CFError>?let privateKey = SecKeyCreateRandomKey(attributes as CFDictionary, &error)// Android - create the key once, in the TEE or StrongBoxval spec = KeyGenParameterSpec.Builder( "transfer-signing-key", KeyProperties.PURPOSE_SIGN) .setDigests(KeyProperties.DIGEST_SHA256) .setUserAuthenticationRequired(true) // timeout 0 = a fresh biometric for every single use .setUserAuthenticationParameters(0, KeyProperties.AUTH_BIOMETRIC_STRONG) .setInvalidatedByBiometricEnrollment(true) .build()KeyPairGenerator.getInstance(KeyProperties.KEY_ALGORITHM_EC, "AndroidKeyStore") .apply { initialize(spec) } .generateKeyPair().biometryCurrentSet (rather than .biometryAny) and setInvalidatedByBiometricEnrollment(true) both kill the key if someone adds a new finger or face, so an attacker who learns the passcode can't enrol themselves and carry on signing. A timeout of 0 matters too: a key that stays unlocked for 30 seconds after one scan will sign whatever the app asks in that window.
Then each operation uses the key. transferData below includes the server's nonce:
// iOS - SECURE approach// Key was created with biometric access controllet query: [String: Any] = [ kSecClass as String: kSecClassKey, kSecAttrApplicationTag as String: "transfer-signing-key", kSecReturnRef as String: true, kSecUseAuthenticationContext as String: context]// Key is LOCKED until biometric succeeds in Secure Enclavevar keyRef: CFTypeRef?let status = SecItemCopyMatching(query as CFDictionary, &keyRef)// Use the key to sign the transfer requestlet signature = SecKeyCreateSignature( keyRef as! SecKey, .ecdsaSignatureMessageX962SHA256, transferData as CFData, nil)// Send signed request to server// Android - SECURE approachval signature = Signature.getInstance("SHA256withECDSA")signature.initSign(keyStore.getKey( "transfer-signing-key", null) as PrivateKey)
val cryptoObject = BiometricPrompt.CryptoObject(signature)biometricPrompt.authenticate(promptInfo, cryptoObject)
// In callback - key is now unlocked by hardwareoverride fun onAuthenticationSucceeded( result: BiometricPrompt.AuthenticationResult) { val sig = result.cryptoObject?.signature ?: return sig.update(transferData) val signatureBytes = sig.sign() // Send signed request to server}Here the biometric never coughs up a boolean. It unlocks a cryptographic key inside the Secure Enclave (iOS) or TEE/StrongBox (Android). That key physically refuses to sign anything until the hardware has confirmed a real biometric match. Frida can't flip a boolean to fake that match, because the check lives in hardware the attacker can't instrument from software. It isn't a cure-all, though. Someone with code execution inside the app can still swap the data being signed just before the user scans, or reuse a key that a time-bound policy left unlocked. Per-use authentication, a server nonce, and showing the user what they're approving (Android's Protected Confirmation goes furthest) shrink that gap.
The server is the other half. The full round trip below starts at enrolment and adds a server nonce, so a captured signature can't be replayed for a second transfer. The last block shows what a Frida hook on the success callback buys the attacker: nothing the server will accept.
The secure pattern for biometric authentication is: generate a key inside secure hardware with biometric access control, then use the biometric prompt to unlock that key for a cryptographic operation (signing or decryption). The server verifies the cryptographic signature, not a boolean. This moves the trust boundary from the application (which can be instrumented) to the secure hardware (which cannot be instrumented from software).
Biometric Spoofing and Presentation Attacks
A presentation attack attempts to fool a biometric sensor with a fake biometric sample:
Fingerprint Spoofing
Latent prints lifted from coffee cups and door handles are the starting material. Silicone moulds, gelatine, conductive ink on thin films — these all have a research history. Modern capacitive sensors fight back by reading the electrical properties of living skin (impedance, moisture). Ultrasonic sensors, found on some Android devices, map the 3D ridge structure beneath the skin. Replicating either in a spoof is genuinely hard.
Face Spoofing
Plain 2D face recognition (camera, no depth sensing) folds to photograph and video replays. 3D face recognition — iOS Face ID with TrueDepth, structured-light sensors on some Android phones — fires thousands of infrared dots at your face to build a depth map. A flat photo or replayed video doesn't produce the right depth response.
That's not the end of the story. Researchers have fooled some 3D systems with high-fidelity 3D-printed masks. Face ID layers on neural-network anti-spoofing trained to spot masks in the infrared and depth data, but every biometric system has a price tag attached to defeating it.
Liveness Detection
Liveness detection (or presentation attack detection, PAD) is how the system separates a real human from a clever fake. The toolbox:
- Passive liveness: Analysing the captured image for signs of a spoof (moire patterns from screens, specular reflections from photographs, lack of micro-movements).
- Active liveness: Requesting the user to perform an action (blink, turn their head, smile). This defeats static spoofs but can be circumvented by video replays.
- Hardware liveness: Using sensor properties that are inherently difficult to spoof (infrared reflectance of living tissue, ultrasonic sub-surface fingerprint mapping, pulse detection).
Fallback Mechanisms
Biometrics always need a fallback. Real life intrudes — wet fingers, a black eye, a cracked sensor, too many failed attempts — and the user still needs a way in.
iOS Fallback Behaviour
Five failed Face ID or Touch ID attempts in a row and iOS demands the device passcode. The passcode is also forced:
- After a device restart (before any biometric is accepted).
- After 48 hours without a device unlock.
- After a remote lock command.
- When enrolling or modifying biometric settings.
Apps can't switch this off — the passcode fallback is a system-level guarantee. What apps can do, via LAContext, is decide whether their flow accepts the passcode or fails closed when biometrics aren't available.
Android Fallback Behaviour
Android's BiometricPrompt allows developers to specify fallback behaviour:
BIOMETRIC_STRONGonly: no fallback to PIN or device credential.BIOMETRIC_STRONG | DEVICE_CREDENTIAL: falls back to PIN, pattern, or password after failed biometric attempts.- After five consecutive failed biometric attempts on most implementations, the system locks out biometric authentication and requires the device credential.
On most devices, lockout duration and attempt counts are enforced in the TEE, not the Android framework, though how strictly depends on the vendor's implementation. The app can't reset the counter, can't override it, can't argue with it.
On iOS, and on most Android devices, the biometric attempt counter and lockout timer are managed by the secure hardware (Secure Enclave or TEE), not by the operating system. Android leaves the details to each vendor's TEE, so check rather than assume on the devices you care about. A compromised OS kernel cannot reset the lockout counter or bypass the lockout period. This ensures that brute-force attacks against the biometric are rate-limited even on a fully compromised device.
iOS LAContext vs Android BiometricPrompt: Security Models Compared
The platforms take very different shapes here, with consequences worth knowing about.
Centralised vs Decentralised Hardware
iOS has one Apple-designed Secure Enclave on every device. Apple owns the hardware and the software, so the security model is uniform. Every iPhone with Face ID or Touch ID runs the same biometric pipeline.
Android lives in a zoo. TEE implementation, sensor quality, anti-spoofing — all of it varies by manufacturer and device. The BiometricPrompt API and strength classes paper over the diversity, but the actual guarantees you get depend on what silicon the user's phone happens to ship with.
API Design Philosophy
iOS LAContext is deliberately spartan. It does biometric evaluation and gates access to Keychain items with biometric access control. Apps cannot fish out raw biometric data, match scores, or intermediate state. There's no door to open.
Android BiometricPrompt hides similar details, but the CryptoObject integration is more upfront. The developer hands in a Signature, Cipher, or Mac object and the biometric unlocks it for use. The cryptographic-auth pattern is right there in the API surface, harder to ignore.
Key Invalidation
On iOS, Keychain items locked behind biometric access control go invalid the moment biometric enrolment changes — adding a new fingerprint, for instance. The app has to notice and re-enrol.
Android leaves it up to the key. Keys created with setInvalidatedByBiometricEnrollment(true) (the default) die permanently when a new biometric is enrolled. Set the flag to false and the keys survive enrolment changes — easier UX, weaker security.
The Bottom Line
Both platforms agree on the rule: never trust a boolean. Use the biometric to unlock a hardware-protected key. Have the server verify a cryptographic signature, not the app's word that someone touched the sensor. The pattern shrugs off boolean-flipping Frida hooks and binary patches because the gatekeeper sits in silicon the attacker cannot reach from userspace. Pair it with per-use keys and a server nonce so code inside the app can't quietly get extra signatures out of one scan.