File tree Expand file tree Collapse file tree 2 files changed +40
-0
lines changed
lib/semmle/code/java/security Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change 11/** Definitions for the insecure local authentication query. */
22
33import java
4+ import semmle.code.java.dataflow.DataFlow
45
56/** A base class that is used as a callback for biometric authentication. */
67private class AuthenticationCallbackClass extends Class {
@@ -40,3 +41,21 @@ class AuthenticationSuccessCallback extends Method {
4041 not result = this .getASuperResultUse ( )
4142 }
4243}
44+
45+ /** A call that sets a parameter for key generation that is insecure for use with biometric authentication. */
46+ class InsecureBiometricKeyParam extends MethodCall {
47+ InsecureBiometricKeyParam ( ) {
48+ exists ( string name , CompileTimeConstantExpr val |
49+ this .getMethod ( )
50+ .hasQualifiedName ( "android.security.keystore" , "KeyGenParameterSpec$Builder" , name ) and
51+ DataFlow:: localExprFlow ( val , this .getArgument ( 0 ) ) and
52+ (
53+ name = [ "setUserAuthenticationRequired" , "setInvalidatedByBiometricEnrollment" ] and
54+ val .getBooleanValue ( ) = false
55+ or
56+ name = "setUserAuthenticationValidityDurationSeconds" and
57+ val .getIntValue ( ) != - 1
58+ )
59+ )
60+ }
61+ }
Original file line number Diff line number Diff line change 1+ /**
2+ * @name Insecurely generated keys for local authentication
3+ * @description Keys used for local biometric authentication should be generated with secure parameters.
4+ * @kind problem
5+ * @problem.severity warning
6+ * @security-severity 9.3
7+ * @precision medium
8+ * @id java/android/insecure-local-key-gen
9+ * @tags security
10+ * external/cwe/cwe-287
11+ */
12+
13+ import java
14+ import semmle.code.java.security.AndroidLocalAuthQuery
15+
16+ /** Holds if the application contains an instance of a key being used for local biometric authentication. */
17+ predicate usesLocalAuth ( ) { exists ( AuthenticationSuccessCallback cb | exists ( cb .getAResultUse ( ) ) ) }
18+
19+ from InsecureBiometricKeyParam call
20+ where usesLocalAuth ( )
21+ select call , "This key is not secure for biometric authentication."
You can’t perform that action at this time.
0 commit comments