2
2
* Provides a taint tracking configuration for reasoning about shell command
3
3
* constructed from library input vulnerabilities
4
4
*
5
- * Note, for performance reasons: only import this file if `Configuration` is needed,
6
- * otherwise `UnsafeShellCommandConstructionCustomizations` should be imported instead.
5
+ * Note, for performance reasons: only import this file if
6
+ * `UnsafeShellCommandConstructionFlow` is needed, otherwise
7
+ * `UnsafeShellCommandConstructionCustomizations` should be imported instead.
7
8
*/
8
9
9
10
import codeql.ruby.DataFlow
@@ -14,8 +15,9 @@ private import codeql.ruby.dataflow.BarrierGuards
14
15
15
16
/**
16
17
* A taint-tracking configuration for detecting shell command constructed from library input vulnerabilities.
18
+ * DEPRECATED: Use `UnsafeShellCommandConstructionFlow`
17
19
*/
18
- class Configuration extends TaintTracking:: Configuration {
20
+ deprecated class Configuration extends TaintTracking:: Configuration {
19
21
Configuration ( ) { this = "UnsafeShellCommandConstruction" }
20
22
21
23
override predicate isSource ( DataFlow:: Node source ) { source instanceof Source }
@@ -39,3 +41,30 @@ class Configuration extends TaintTracking::Configuration {
39
41
set .isElementOfTypeOrUnknown ( "int" )
40
42
}
41
43
}
44
+
45
+ private module UnsafeShellCommandConstructionConfig implements DataFlow:: ConfigSig {
46
+ predicate isSource ( DataFlow:: Node source ) { source instanceof Source }
47
+
48
+ predicate isSink ( DataFlow:: Node sink ) { sink instanceof Sink }
49
+
50
+ predicate isBarrier ( DataFlow:: Node node ) {
51
+ node instanceof CommandInjection:: Sanitizer or // using all sanitizers from `rb/command-injection`
52
+ node instanceof StringConstCompareBarrier or
53
+ node instanceof StringConstArrayInclusionCallBarrier
54
+ }
55
+
56
+ // override to require the path doesn't have unmatched return steps
57
+ DataFlow:: FlowFeature getAFeature ( ) { result instanceof DataFlow:: FeatureHasSourceCallContext }
58
+
59
+ predicate allowImplicitRead ( DataFlow:: Node node , DataFlow:: ContentSet set ) {
60
+ // allow implicit reads of array elements
61
+ isSink ( node ) and
62
+ set .isElementOfTypeOrUnknown ( "int" )
63
+ }
64
+ }
65
+
66
+ /**
67
+ * Taint-tracking for detecting shell command constructed from library input vulnerabilities.
68
+ */
69
+ module UnsafeShellCommandConstructionFlow =
70
+ TaintTracking:: Global< UnsafeShellCommandConstructionConfig > ;
0 commit comments