7
7
* @problem.severity error
8
8
* @precision high
9
9
* @kind path-problem
10
- * @id java/unsafe-reflection
10
+ * @id java/android/ unsafe-reflection
11
11
* @tags security
12
12
* experimental
13
13
* external/cwe/cwe-470
14
14
*/
15
15
16
16
import java
17
- import semmle.code.java.dataflow.DataFlow
18
17
import semmle.code.java.dataflow.TaintTracking
19
18
import semmle.code.java.controlflow.Guards
20
19
import semmle.code.java.dataflow.SSA
21
20
import semmle.code.java.frameworks.android.Intent
22
21
23
22
class CheckSignaturesGuard extends Guard instanceof EqualityTest {
24
- MethodAccess checkSignatures ;
23
+ MethodCall checkSignatures ;
25
24
26
25
CheckSignaturesGuard ( ) {
27
26
this .getAnOperand ( ) = checkSignatures and
@@ -52,23 +51,23 @@ predicate signatureChecked(Expr safe) {
52
51
53
52
module InsecureLoadingConfig implements DataFlow:: ConfigSig {
54
53
predicate isSource ( DataFlow:: Node src ) {
55
- exists ( Method m | m = src .asExpr ( ) .( MethodAccess ) .getMethod ( ) |
54
+ exists ( Method m | m = src .asExpr ( ) .( MethodCall ) .getMethod ( ) |
56
55
m .getDeclaringType ( ) .getASourceSupertype * ( ) instanceof TypeContext and
57
56
m .hasName ( "createPackageContext" ) and
58
- not signatureChecked ( src .asExpr ( ) .( MethodAccess ) .getArgument ( 0 ) )
57
+ not signatureChecked ( src .asExpr ( ) .( MethodCall ) .getArgument ( 0 ) )
59
58
)
60
59
}
61
60
62
61
predicate isSink ( DataFlow:: Node sink ) {
63
- exists ( MethodAccess ma |
62
+ exists ( MethodCall ma |
64
63
ma .getMethod ( ) .hasQualifiedName ( "java.lang" , "ClassLoader" , "loadClass" )
65
64
|
66
65
sink .asExpr ( ) = ma .getQualifier ( )
67
66
)
68
67
}
69
68
70
69
predicate isAdditionalFlowStep ( DataFlow:: Node node1 , DataFlow:: Node node2 ) {
71
- exists ( MethodAccess ma , Method m |
70
+ exists ( MethodCall ma , Method m |
72
71
ma .getMethod ( ) = m and
73
72
m .getDeclaringType ( ) .getASourceSupertype * ( ) instanceof TypeContext and
74
73
m .hasName ( "getClassLoader" )
@@ -87,4 +86,3 @@ from InsecureLoadFlow::PathNode source, InsecureLoadFlow::PathNode sink
87
86
where InsecureLoadFlow:: flowPath ( source , sink )
88
87
select sink .getNode ( ) , source , sink , "Class loaded from a $@ without signature check" ,
89
88
source .getNode ( ) , "third party library"
90
-
0 commit comments