@@ -30,29 +30,18 @@ class CommandInjectionAdditionalFlowStep extends Unit {
30
30
}
31
31
32
32
/**
33
- * A reference to any member of `Process` .
33
+ * An additional taint step for command injection vulnerabilities .
34
34
*/
35
- private class ProcessHost extends MemberRefExpr {
36
- ProcessHost ( ) { this .getBase ( ) instanceof ProcessRef }
37
- }
38
-
39
- /**
40
- * An expression of type `Process`.
41
- */
42
- private class ProcessRef extends Expr {
43
- ProcessRef ( ) {
44
- this .getType ( ) instanceof ProcessType or
45
- this .getType ( ) = any ( OptionalType t | t .getBaseType ( ) instanceof ProcessType )
35
+ private class CommandInjectionArrayAdditionalFlowStep extends CommandInjectionAdditionalFlowStep {
36
+ override predicate step ( DataFlow:: Node nodeFrom , DataFlow:: Node nodeTo ) {
37
+ // needed until we have proper content flow through arrays.
38
+ exists ( ArrayExpr arr |
39
+ nodeFrom .asExpr ( ) = arr .getAnElement ( ) and
40
+ nodeTo .asExpr ( ) = arr
41
+ )
46
42
}
47
43
}
48
44
49
- /**
50
- * The type `Process`.
51
- */
52
- private class ProcessType extends NominalType {
53
- ProcessType ( ) { this .getFullName ( ) = "Process" }
54
- }
55
-
56
45
/**
57
46
* A `DataFlow::Node` that is written into a `Process` object.
58
47
*/
@@ -63,26 +52,9 @@ private class ProcessSink extends CommandInjectionSink instanceof DataFlow::Node
63
52
// with `Process.launchPath` is a sink.
64
53
exists ( NominalType t , Expr e |
65
54
t .getABaseType * ( ) .getUnderlyingType ( ) .getName ( ) = "Process" and
66
- e .getFullyConverted ( ) = this .asExpr ( ) and
67
- e .getFullyConverted ( ) .getType ( ) = t
68
- )
69
- }
70
- }
71
-
72
- /**
73
- * A `DataFlow::Node` that is written into a field of a `Process` object.
74
- */
75
- private class ProcessSink2 extends CommandInjectionSink instanceof DataFlow:: Node {
76
- ProcessSink2 ( ) {
77
- exists ( AssignExpr assign , ProcessHost s |
78
- assign .getDest ( ) = s and
79
- this .asExpr ( ) = assign .getSource ( )
80
- )
81
- or
82
- exists ( AssignExpr assign , ProcessHost s , ArrayExpr a |
83
- assign .getDest ( ) = s and
84
- a = assign .getSource ( ) and
85
- this .asExpr ( ) = a .getAnElement ( )
55
+ this .( DataFlow:: PostUpdateNode ) .getPreUpdateNode ( ) .asExpr ( ) = e and
56
+ e .getFullyConverted ( ) .getType ( ) = t and
57
+ not e .( DeclRefExpr ) .getDecl ( ) instanceof SelfParamDecl
86
58
)
87
59
}
88
60
}
0 commit comments