github / github/codeql

False negative: AndroidInsecureLocalAuthentication.ql

オープン
#21,526 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る
question
主要言語
CodeQL
スター
10.1k
フォーク
2.1k
平均マージ
2日 15時間
マージ済み PR(30日)
141

説明

Version
codeql 2.23.9

When I detect the code like this using Security/CWE/CWE-287/AndroidInsecureLocalAuthentication.ql, the problem is reported normally:
```java
package scensct.core.pos;
import android.hardware.fingerprint.FingerprintManager;
public class PosCase1 extends FingerprintManager.AuthenticationCallback {
@Override
public void onAuthenticationSucceeded(FingerprintManager.AuthenticationResult result) { // [REPORTED LINE]
// Parameter 'result' is declared but never accessed or referenced.
// No cryptographic operation or any use of 'result'.
System.out.println("Authentication succeeded.");
}
}
```
However, when I insert a temporary variable, AndroidInsecureLocalAuthentication.ql is unable to detect the problem:
```java
package scensct.var.pos;

import android.hardware.fingerprint.FingerprintManager;

public class PosCase1_Var3 extends FingerprintManager.AuthenticationCallback {
@Override
public void onAuthenticationSucceeded(FingerprintManager.AuthenticationResult result) {
// Introduce a temporary variable that shadows but does not use result.
Object ignored = result;
// Still no cryptographic operation or actual usage.
System.out.println("Authentication succeeded.");
// The 'ignored' variable is never read.
}
}
```
AndroidInsecureLocalAuthentication.ql scanning the following code also fails to detect the issue:
```java
package scensct.var.pos;

import android.hardware.biometrics.BiometricPrompt;

public class PosCase2_Var1 extends BiometricPrompt.AuthenticationCallback {
@Override
public void onAuthenticationSucceeded(BiometricPrompt.AuthenticationResult result) {
// Introduce a temporary variable that does not change the usage
BiometricPrompt.AuthenticationResult res = result;
super.onAuthenticationSucceeded(res);
}
}
```

```java

package scensct.var.pos;

import android.hardware.biometrics.BiometricPrompt;

public class PosCase2_Var4 extends BiometricPrompt.AuthenticationCallback {
// Extract a private helper method that only passes the parameter
private void callSuper(BiometricPrompt.AuthenticationResult r) {
super.onAuthenticationSucceeded(r);
}

@Override
public void onAuthenticationSucceeded(BiometricPrompt.AuthenticationResult result) {
callSuper(result);
}
}
```

```java

package scensct.var.pos;

import android.hardware.biometrics.BiometricPrompt;

public class PosCase2_Var5 extends BiometricPrompt.AuthenticationCallback {
@Override
public void onAuthenticationSucceeded(BiometricPrompt.AuthenticationResult result) {
// Add a redundant local variable and a no-op statement
BiometricPrompt.AuthenticationResult authResult = result;
int dummy = 0; // unrelated to result
super.onAuthenticationSucceeded(authResult);
}
}

```

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

Security/CWE/CWE-287/AndroidInsecureLocalAuthentication.ql から始め、報告されている Java の例を再現し、パラメータの直接使用、代入、委譲、およびヘルパーを介した呼び出しを比較します。提供された各バリエーションについて、クエリが安全でない認証処理を一貫して報告し、偽陰性がないことが完了の条件です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
java
領域
security
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
静か
明瞭さ
おおむね明確
初心者へのやさしさ
55/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。