Skip to content

Commit 8bd7990

Browse files
Implement local auth query
1 parent 10343dd commit 8bd7990

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/** Definitions for the insecure local authentication query. */
2+
3+
import java
4+
5+
/** A base class that is used as a callback for biometric authentication. */
6+
private class AuthenticationCallbackClass extends Class {
7+
AuthenticationCallbackClass() {
8+
this.hasQualifiedName("android.hardware.fingerprint",
9+
"FingerprintManager$AuthenticationCallback")
10+
or
11+
this.hasQualifiedName("android.hardware.biometrics", "BiometricPrompt$AuthenticationCallback")
12+
}
13+
}
14+
15+
/** An implementation of the `onAuthenticationSucceeded` method for an authentication callback. */
16+
class AuthenticationSuccessCallback extends Method {
17+
AuthenticationSuccessCallback() {
18+
this.getDeclaringType().getASupertype+() instanceof AuthenticationCallbackClass and
19+
this.hasName("onAuthenticationSucceeded")
20+
}
21+
22+
/** Gets the parameter containing the `authenticationResult` */
23+
Parameter getResultParameter() { result = this.getParameter(0) }
24+
25+
/** Gets a use of the result parameter that's used in a `super` call to the base `AuthenticationCallback` class. */
26+
private VarAccess getASuperResultUse() {
27+
exists(SuperMethodCall sup |
28+
sup.getEnclosingCallable() = this and
29+
result = sup.getArgument(0) and
30+
result = this.getResultParameter().getAnAccess() and
31+
this.getDeclaringType().getASupertype() instanceof AuthenticationCallbackClass
32+
)
33+
}
34+
35+
/** Gets a use of the result parameter, other than one used in a `super` call. */
36+
VarAccess getAResultUse() {
37+
result = this.getResultParameter().getAnAccess() and
38+
not result = this.getASuperResultUse()
39+
}
40+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* @name Insecure local authentication
3+
* @description Local authentication that does not make use of a `CryptoObject` can be bypassed.
4+
* @kind problem
5+
* @problem.severity warning
6+
* @security-severity ...TODO
7+
* @precision high
8+
* @id java/android/insecure-local-authentication
9+
* @tags security
10+
* external/cwe/cwe-287
11+
*/
12+
13+
import java
14+
import semmle.code.java.security.AndroidLocalAuthQuery
15+
16+
from AuthenticationSuccessCallback c
17+
where not exists(c.getAResultUse())
18+
select c, "This authentication callback does not use its result for a cryptographic operation."

0 commit comments

Comments
 (0)