mirror of
https://github.com/HackTricks-wiki/hacktricks.git
synced 2025-10-10 18:36:50 +00:00
Translated ['src/mobile-pentesting/android-app-pentesting/bypass-biometr
This commit is contained in:
parent
e2aa9ee048
commit
5e36421923
@ -1,4 +1,4 @@
|
||||
# バイパス生体認証 (Android)
|
||||
# バイオメトリック認証のバイパス (Android)
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
@ -17,7 +17,7 @@ Fridaスクリプトを実行するコマンド:
|
||||
```bash
|
||||
frida -U -f com.generic.insecurebankingfingerprint --no-pause -l fingerprint-bypass.js
|
||||
```
|
||||
## **方法2 – 例外処理アプローチ**
|
||||
## **Method 2 – Exception Handling Approach**
|
||||
|
||||
Another [Frida script](https://github.com/WithSecureLABS/android-keystore-audit/blob/master/frida-scripts/fingerprint-bypass-via-exception-handling.js) 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.
|
||||
|
||||
@ -33,35 +33,80 @@ Hooking BiometricPrompt.authenticate2()...
|
||||
Hooking FingerprintManager.authenticate()...
|
||||
[Android Emulator 5554::com.generic.insecurebankingfingerprint]-> bypass()
|
||||
```
|
||||
## **方法 3 – インスツルメンテーション フレームワーク**
|
||||
## **Method 3 – Instrumentation Frameworks**
|
||||
|
||||
Xposed や Frida のようなインスツルメンテーション フレームワークは、アプリケーションのメソッドにランタイムでフックするために使用できます。指紋認証の場合、これらのフレームワークは次のことができます:
|
||||
Instrumentation frameworks like Xposed or Frida can be used to hook into application methods at runtime. For fingerprint authentication, these frameworks can:
|
||||
|
||||
1. **認証コールバックをモックする**: `BiometricPrompt.AuthenticationCallback` の `onAuthenticationSucceeded`、`onAuthenticationFailed`、または `onAuthenticationError` メソッドにフックすることで、指紋認証プロセスの結果を制御できます。
|
||||
2. **SSL ピンニングをバイパスする**: これにより、攻撃者はクライアントとサーバー間のトラフィックを傍受および変更でき、認証プロセスを変更したり、機密データを盗んだりする可能性があります。
|
||||
1. **モック認証コールバック**: By hooking into the `onAuthenticationSucceeded`, `onAuthenticationFailed`, or `onAuthenticationError` methods of the `BiometricPrompt.AuthenticationCallback`, you can control the outcome of the fingerprint authentication process.
|
||||
2. **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.
|
||||
|
||||
Frida の例コマンド:
|
||||
Example command for Frida:
|
||||
```bash
|
||||
frida -U -l script-to-bypass-authentication.js --no-pause -f com.generic.in
|
||||
```
|
||||
## **方法 4 – リバースエンジニアリングとコード修正**
|
||||
## **Method 4 – リバースエンジニアリングとコード修正**
|
||||
|
||||
リバースエンジニアリングツールとして `APKTool`、`dex2jar`、`JD-GUI` を使用して、Androidアプリケーションを逆コンパイルし、そのソースコードを読み、認証メカニズムを理解することができます。一般的な手順は以下の通りです:
|
||||
リバースエンジニアリングツール(`APKTool`、`dex2jar`、`JD-GUI`など)を使用して、Androidアプリケーションを逆コンパイルし、そのソースコードを読み、認証メカニズムを理解することができます。一般的な手順は次のとおりです。
|
||||
|
||||
1. **APKの逆コンパイル**: APKファイルをより人間が読みやすい形式(Javaコードなど)に変換します。
|
||||
2. **コードの分析**: 指紋認証の実装を探し、潜在的な弱点(フォールバックメカニズムや不適切な検証チェックなど)を特定します。
|
||||
3. **APKの再コンパイル**: 指紋認証をバイパスするためにコードを修正した後、アプリケーションは再コンパイルされ、署名され、テストのためにデバイスにインストールされます。
|
||||
|
||||
## **方法 5 – カスタム認証ツールの使用**
|
||||
## **Method 5 – カスタム認証ツールの使用**
|
||||
|
||||
認証メカニズムをテストし、バイパスするために設計された専門的なツールやスクリプトがあります。例えば:
|
||||
認証メカニズムをテストおよびバイパスするために設計された専門的なツールやスクリプトがあります。例えば:
|
||||
|
||||
1. **MAGISKモジュール**: MAGISKはAndroid用のツールで、ユーザーがデバイスをルート化し、指紋を含むハードウェアレベルの情報を修正または偽装するモジュールを追加できます。
|
||||
2. **カスタムビルドのスクリプト**: スクリプトはAndroidデバッグブリッジ(ADB)と対話するか、アプリケーションのバックエンドと直接対話して指紋認証をシミュレートまたはバイパスするために書かれることがあります。
|
||||
1. **MAGISKモジュール**: MAGISKは、ユーザーがデバイスをルート化し、指紋を含むハードウェアレベルの情報を修正または偽装できるモジュールを追加するためのAndroid用ツールです。
|
||||
2. **カスタムビルドスクリプト**: スクリプトは、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)でも機能します。
|
||||
```bash
|
||||
# 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` 値に強制することができます:
|
||||
```javascript
|
||||
// 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暗号チェックが追加され、許可される認証者の組み合わせが厳しくなります。
|
||||
|
||||
## 参考文献
|
||||
|
||||
- [https://securitycafe.ro/2022/09/05/mobile-pentesting-101-bypassing-biometric-authentication/](https://securitycafe.ro/2022/09/05/mobile-pentesting-101-bypassing-biometric-authentication/)
|
||||
- [Universal Android Biometric Bypass – Frida CodeShare](https://codeshare.frida.re/@ax/universal-android-biometric-bypass/)
|
||||
- [Android Pixel Security Bulletin 2024-12-01](https://source.android.com/security/bulletin/pixel/2024-12-01)
|
||||
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
Loading…
x
Reference in New Issue
Block a user