バイオメトリック認証のバイパス (Android)
Reading time: 10 minutes
tip
AWSハッキングを学び、実践する:HackTricks Training AWS Red Team Expert (ARTE)
GCPハッキングを学び、実践する:HackTricks Training GCP Red Team Expert (GRTE)
Azureハッキングを学び、実践する:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricksをサポートする
- サブスクリプションプランを確認してください!
- **💬 Discordグループまたはテレグラムグループに参加するか、Twitter 🐦 @hacktricks_liveをフォローしてください。
- HackTricksおよびHackTricks CloudのGitHubリポジトリにPRを提出してハッキングトリックを共有してください。
方法 1 – 暗号オブジェクトを使用しないバイパス
ここでの焦点は、認証プロセスにおいて重要な onAuthenticationSucceeded コールバックです。WithSecureの研究者たちは、NULL CryptoObject を onAuthenticationSucceeded(...) でバイパスするための Fridaスクリプト を開発しました。このスクリプトは、メソッドの呼び出し時に指紋認証の自動バイパスを強制します。以下は、Androidの指紋コンテキストにおけるバイパスを示す簡略化されたスニペットで、完全なアプリケーションは GitHub で入手可能です。
biometricPrompt = new BiometricPrompt(this, executor, new BiometricPrompt.AuthenticationCallback() {
@Override
public void onAuthenticationSucceeded(@NonNull BiometricPrompt.AuthenticationResult result) {
Toast.makeText(MainActivity.this,"Success",Toast.LENGTH_LONG).show();
}
});
Fridaスクリプトを実行するコマンド:
frida -U -f com.generic.insecurebankingfingerprint --no-pause -l fingerprint-bypass.js
Method 2 – Exception Handling Approach
Another Frida script by WithSecure addresses bypassing insecure crypto object usage. The script invokes onAuthenticationSucceeded with a CryptoObject that hasn't been authorized by a fingerprint. If the application tries to use a different cipher object, it will trigger an exception. The script prepares to invoke onAuthenticationSucceeded and handle the javax.crypto.IllegalBlockSizeException in the Cipher class, ensuring subsequent objects used by the application are encrypted with the new key.
Fridaスクリプトを実行するコマンド:
frida -U -f com.generic.insecurebankingfingerprint --no-pause -l fingerprint-bypass-via-exception-handling.js
指紋画面に到達し、authenticate()
が開始されると、Fridaコンソールでbypass()
と入力してバイパスを有効にします:
Spawning com.generic.insecurebankingfingerprint...
[Android Emulator 5554::com.generic.insecurebankingfingerprint]-> Hooking BiometricPrompt.authenticate()...
Hooking BiometricPrompt.authenticate2()...
Hooking FingerprintManager.authenticate()...
[Android Emulator 5554::com.generic.insecurebankingfingerprint]-> bypass()
Method 3 – Instrumentation Frameworks
Instrumentation frameworks like Xposed or Frida can be used to hook into application methods at runtime. For fingerprint authentication, these frameworks can:
- モック認証コールバック: By hooking into the
onAuthenticationSucceeded
,onAuthenticationFailed
, oronAuthenticationError
methods of theBiometricPrompt.AuthenticationCallback
, you can control the outcome of the fingerprint authentication process. - SSLピンニングをバイパス: This allows an attacker to intercept and modify the traffic between the client and the server, potentially altering the authentication process or stealing sensitive data.
Example command for Frida:
frida -U -l script-to-bypass-authentication.js --no-pause -f com.generic.in
Method 4 – リバースエンジニアリングとコード修正
リバースエンジニアリングツール(APKTool
、dex2jar
、JD-GUI
など)を使用して、Androidアプリケーションを逆コンパイルし、そのソースコードを読み、認証メカニズムを理解することができます。一般的な手順は次のとおりです。
- APKの逆コンパイル: APKファイルをより人間が読みやすい形式(Javaコードなど)に変換します。
- コードの分析: 指紋認証の実装を探し、潜在的な弱点(フォールバックメカニズムや不適切な検証チェックなど)を特定します。
- APKの再コンパイル: 指紋認証をバイパスするためにコードを修正した後、アプリケーションは再コンパイルされ、署名され、テストのためにデバイスにインストールされます。
Method 5 – カスタム認証ツールの使用
認証メカニズムをテストおよびバイパスするために設計された専門的なツールやスクリプトがあります。例えば:
- MAGISKモジュール: MAGISKは、ユーザーがデバイスをルート化し、指紋を含むハードウェアレベルの情報を修正または偽装できるモジュールを追加するためのAndroid用ツールです。
- カスタムビルドスクリプト: スクリプトは、Android Debug Bridge(ADB)と対話するか、アプリケーションのバックエンドと直接対話して指紋認証をシミュレートまたはバイパスするために作成できます。
Method 6 – BiometricPrompt
(API 28-34)用のユニバーサルFridaフック
2023年に、Universal-Android-Biometric-BypassというブランドのコミュニティFridaスクリプトがCodeShareに登場しました。このスクリプトは、BiometricPrompt.authenticate()
のすべてのオーバーロードとレガシーのFingerprintManager.authenticate()
をフックし、nullのCryptoObject
を含む偽造されたAuthenticationResult
でonAuthenticationSucceeded()
を直接トリガーします。APIレベルに動的に適応するため、ターゲットアプリが返されたCryptoObject
に対して暗号チェックを行わない場合、Android 14(API 34)でも機能します。
# Install the script from CodeShare and run it against the target package
frida -U -f com.target.app --no-pause -l universal-android-biometric-bypass.js
Key ideas
- すべてはユーザースペースで発生します – カーネルの脆弱性やルートは必要ありません。
- 攻撃はUIに対して完全に静かです: システムの生体認証ダイアログは決して表示されません。
- 緩和策: 常に
result.cryptoObject
とその暗号/署名を確認してから、機密機能のロックを解除してください。
Method 7 – Downgrade / Fallback Manipulation
Android 11以降、開発者は setAllowedAuthenticators()
(または古い setDeviceCredentialAllowed()
)を介して受け入れ可能な認証者を指定できます。ランタイムフッキング攻撃は、allowedAuthenticators
ビットフィールドをより弱い BIOMETRIC_WEAK | DEVICE_CREDENTIAL
値に強制することができます:
// Frida one-liner – replace strong-only policy with weak/device-credential
var PromptInfoBuilder = Java.use('androidx.biometric.BiometricPrompt$PromptInfo$Builder');
PromptInfoBuilder.setAllowedAuthenticators.implementation = function(flags){
return this.setAllowedAuthenticators(0x0002 | 0x8000); // BIOMETRIC_WEAK | DEVICE_CREDENTIAL
};
アプリが返された AuthenticationResult
をその後検証しない場合、攻撃者は単に PIN/Pattern フォールバックボタンを押すか、新しい弱い生体認証を登録してアクセスを得ることができます。
方法 8 – ベンダー / カーネルレベルのCVE
Androidのセキュリティ速報に注意してください:最近のカーネル側のバグはいくつかあり、指紋HALを通じてローカル特権昇格を可能にし、実質的に センサーのパイプラインを無効にしたりショートサーキットさせたり します。例としては:
- CVE-2023-20995 –
CustomizedSensor.cpp
のcaptureImage
における論理エラー(Pixel 8、Android 13)により、ユーザーの操作なしでロック解除をバイパス可能。 - CVE-2024-53835 / CVE-2024-53840 – “異常な根本原因による生体認証バイパスの可能性” が 2024年12月のPixel速報 で修正されました。
これらの脆弱性はロック画面をターゲットにしていますが、ルート化されたテスターはアプリレベルの欠陥と組み合わせてアプリ内の生体認証をバイパスすることも可能です。
開発者向けの強化チェックリスト(クイックペンテスターのメモ)
- Keystore キーを生成する際に
setUserAuthenticationRequired(true)
とsetInvalidatedByBiometricEnrollment(true)
を強制します。キーを使用する前に有効な生体認証が必要です。 - nullまたは予期しない暗号/署名 の
CryptoObject
を拒否します;これを致命的な認証エラーとして扱います。 BiometricPrompt
を使用する際は、BIOMETRIC_STRONG
を優先し、高リスクのアクションに対して 決してBIOMETRIC_WEAK
またはDEVICE_CREDENTIAL
にフォールバックしない でください。- 最新の
androidx.biometric
バージョン(≥1.2.0-beta02)を固定します – 最近のリリースでは自動的なnull暗号チェックが追加され、許可される認証者の組み合わせが厳しくなります。
参考文献
tip
AWSハッキングを学び、実践する:HackTricks Training AWS Red Team Expert (ARTE)
GCPハッキングを学び、実践する:HackTricks Training GCP Red Team Expert (GRTE)
Azureハッキングを学び、実践する:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricksをサポートする
- サブスクリプションプランを確認してください!
- **💬 Discordグループまたはテレグラムグループに参加するか、Twitter 🐦 @hacktricks_liveをフォローしてください。
- HackTricksおよびHackTricks CloudのGitHubリポジトリにPRを提出してハッキングトリックを共有してください。