File tree Expand file tree Collapse file tree 2 files changed +21
-12
lines changed Expand file tree Collapse file tree 2 files changed +21
-12
lines changed Original file line number Diff line number Diff line change @@ -1815,6 +1815,25 @@ module Array {
1815
1815
preservesValue = true
1816
1816
}
1817
1817
}
1818
+
1819
+ /**
1820
+ * Holds if there an array element `pred` might taint the array defined by `succ`.
1821
+ * This is used for queries where we consider an entire array to be tainted if any of its elements are tainted.
1822
+ */
1823
+ predicate taintedArrayObjectSteps ( DataFlow:: Node pred , DataFlow:: Node succ ) {
1824
+ exists ( DataFlow:: CallNode call |
1825
+ call .getMethodName ( ) = [ "<<" , "push" , "append" ] and
1826
+ call .getReceiver ( ) = succ and
1827
+ pred = call .getArgument ( 0 ) and
1828
+ call .getNumberOfArguments ( ) = 1
1829
+ )
1830
+ or
1831
+ exists ( DataFlow:: CallNode call |
1832
+ call .getMethodName ( ) = "[]" and
1833
+ succ = call and
1834
+ pred = call .getArgument ( _)
1835
+ )
1836
+ }
1818
1837
}
1819
1838
1820
1839
/**
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import codeql.ruby.DataFlow
10
10
import UnsafeCodeConstructionCustomizations:: UnsafeCodeConstruction
11
11
private import codeql.ruby.TaintTracking
12
12
private import codeql.ruby.dataflow.BarrierGuards
13
+ private import codeql.ruby.frameworks.core.Array
13
14
14
15
/**
15
16
* A taint-tracking configuration for detecting code constructed from library input vulnerabilities.
@@ -33,17 +34,6 @@ class Configuration extends TaintTracking::Configuration {
33
34
34
35
override predicate isAdditionalTaintStep ( DataFlow:: Node pred , DataFlow:: Node succ ) {
35
36
// if an array element gets tainted, then we treat the entire array as tainted
36
- exists ( DataFlow:: CallNode call |
37
- call .getMethodName ( ) = [ "<<" , "push" , "append" ] and
38
- call .getReceiver ( ) = succ and
39
- pred = call .getArgument ( 0 ) and
40
- call .getNumberOfArguments ( ) = 1
41
- )
42
- or
43
- exists ( DataFlow:: CallNode call |
44
- call .getMethodName ( ) = "[]" and
45
- succ = call and
46
- pred = call .getArgument ( _)
47
- )
37
+ Array:: taintedArrayObjectSteps ( pred , succ )
48
38
}
49
39
}
You can’t perform that action at this time.
0 commit comments