File tree Expand file tree Collapse file tree 4 files changed +51
-24
lines changed
javascript/ql/src/semmle/javascript/security Expand file tree Collapse file tree 4 files changed +51
-24
lines changed Original file line number Diff line number Diff line change 16
16
import javascript
17
17
private import semmle.javascript.dataflow.InferredTypes
18
18
19
+ /** Provides classes and predicates for reasoning about deeply tainted objects. */
19
20
module TaintedObject {
20
21
private import DataFlow
22
+ import TaintedObjectCustomizations:: TaintedObject
21
23
22
- private class TaintedObjectLabel extends FlowLabel {
23
- TaintedObjectLabel ( ) { this = "tainted-object" }
24
+ // Materialize flow labels
25
+ private class ConcreteTaintedObjectLabel extends TaintedObjectLabel {
26
+ ConcreteTaintedObjectLabel ( ) { this = this }
24
27
}
25
28
26
- /**
27
- * Gets the flow label representing a deeply tainted object.
28
- *
29
- * A "tainted object" is an array or object whose property values are all assumed to be tainted as well.
30
- *
31
- * Note that the presence of the this label generally implies the presence of the `taint` label as well.
32
- */
33
- FlowLabel label ( ) { result instanceof TaintedObjectLabel }
34
-
35
29
/**
36
30
* Holds for the flows steps that are relevant for tracking user-controlled JSON objects.
37
31
*/
@@ -79,11 +73,6 @@ module TaintedObject {
79
73
*/
80
74
predicate isSource ( Node source , FlowLabel label ) { source instanceof Source and label = label ( ) }
81
75
82
- /**
83
- * A source of a user-controlled deep object.
84
- */
85
- abstract class Source extends DataFlow:: Node { }
86
-
87
76
/** Request input accesses as a JSON source. */
88
77
private class RequestInputAsSource extends Source {
89
78
RequestInputAsSource ( ) { this .( HTTP:: RequestInputAccess ) .isUserControlledObject ( ) }
Original file line number Diff line number Diff line change
1
+ /**
2
+ * Provides access to the "tainted object" flow label defined in `TaintedObject.qll`, without
3
+ * materializing that flow label.
4
+ */
5
+
6
+ import javascript
7
+
8
+ /** Provides classes and predicates for reasoning about deeply tainted objects. */
9
+ module TaintedObject {
10
+ /** A flow label representing a deeply tainted object. */
11
+ abstract class TaintedObjectLabel extends DataFlow:: FlowLabel {
12
+ TaintedObjectLabel ( ) { this = "tainted-object" }
13
+ }
14
+
15
+ /**
16
+ * Gets the flow label representing a deeply tainted object.
17
+ *
18
+ * A "tainted object" is an array or object whose property values are all assumed to be tainted as well.
19
+ *
20
+ * Note that the presence of the this label generally implies the presence of the `taint` label as well.
21
+ */
22
+ DataFlow:: FlowLabel label ( ) { result instanceof TaintedObjectLabel }
23
+
24
+ /**
25
+ * A source of a user-controlled deep object.
26
+ */
27
+ abstract class Source extends DataFlow:: Node { }
28
+ }
Original file line number Diff line number Diff line change @@ -21,13 +21,7 @@ module DeepObjectResourceExhaustion {
21
21
Configuration ( ) { this = "DeepObjectResourceExhaustion" }
22
22
23
23
override predicate isSource ( DataFlow:: Node source , DataFlow:: FlowLabel label ) {
24
- source instanceof Source and label = TaintedObject:: label ( )
25
- or
26
- // We currently can't expose the TaintedObject label in the Customizations library
27
- // so just add its default sources here.
28
- source instanceof TaintedObject:: Source and label = TaintedObject:: label ( )
29
- or
30
- source instanceof RemoteFlowSource and label .isTaint ( )
24
+ source .( Source ) .getAFlowLabel ( ) = label
31
25
}
32
26
33
27
override predicate isSink ( DataFlow:: Node sink , DataFlow:: FlowLabel label ) {
Original file line number Diff line number Diff line change 4
4
*/
5
5
6
6
import javascript
7
+ private import semmle.javascript.security.TaintedObjectCustomizations
7
8
8
9
/**
9
10
* Provides sources, sinks and sanitizers for reasoning about
@@ -13,7 +14,22 @@ module DeepObjectResourceExhaustion {
13
14
/**
14
15
* A data flow source for slow input validation.
15
16
*/
16
- abstract class Source extends DataFlow:: Node { }
17
+ abstract class Source extends DataFlow:: Node {
18
+ /** Gets a flow label to associate with this source. */
19
+ DataFlow:: FlowLabel getAFlowLabel ( ) { result = TaintedObject:: label ( ) }
20
+ }
21
+
22
+ private class TaintedObjectSourceAsSource extends Source {
23
+ TaintedObjectSourceAsSource ( ) { this instanceof TaintedObject:: Source }
24
+
25
+ override DataFlow:: FlowLabel getAFlowLabel ( ) { result = TaintedObject:: label ( ) }
26
+ }
27
+
28
+ private class RemoteFlowSourceAsSource extends Source {
29
+ RemoteFlowSourceAsSource ( ) { this instanceof RemoteFlowSource }
30
+
31
+ override DataFlow:: FlowLabel getAFlowLabel ( ) { result .isTaint ( ) }
32
+ }
17
33
18
34
/**
19
35
* A data flow sink for slow input validation.
You can’t perform that action at this time.
0 commit comments