Skip to content

Commit 00078d1

Browse files
authored
Merge pull request github#3601 from hvitved/csharp/overlapping-configs
C#: Avoid multiple taint-tracking configurations
2 parents ad8647f + 1e8b7ed commit 00078d1

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

csharp/ql/src/Security Features/CWE-079/StoredXSS.ql

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@
1414
import csharp
1515
import semmle.code.csharp.security.dataflow.flowsources.Stored
1616
import semmle.code.csharp.security.dataflow.XSS::XSS
17-
import semmle.code.csharp.dataflow.DataFlow::DataFlow::PathGraph
17+
import semmle.code.csharp.dataflow.DataFlow2
18+
import DataFlow2::PathGraph
1819

1920
class StoredTaintTrackingConfiguration extends TaintTrackingConfiguration {
20-
override predicate isSource(DataFlow::Node source) { source instanceof StoredFlowSource }
21+
override predicate isSource(DataFlow2::Node source) { source instanceof StoredFlowSource }
2122
}
2223

2324
from
24-
StoredTaintTrackingConfiguration c, DataFlow::PathNode source, DataFlow::PathNode sink,
25+
StoredTaintTrackingConfiguration c, DataFlow2::PathNode source, DataFlow2::PathNode sink,
2526
string explanation
2627
where
2728
c.hasFlowPath(source, sink) and

csharp/ql/src/semmle/code/csharp/security/dataflow/XSS.qll

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ module XSS {
1414
import semmle.code.csharp.security.dataflow.flowsinks.Html
1515
import semmle.code.csharp.security.dataflow.flowsinks.Remote
1616
import semmle.code.csharp.security.dataflow.flowsources.Remote
17+
private import semmle.code.csharp.dataflow.DataFlow2
18+
private import semmle.code.csharp.dataflow.TaintTracking2
1719

1820
/**
1921
* Holds if there is tainted flow from `source` to `sink` that may lead to a
@@ -24,7 +26,7 @@ module XSS {
2426
predicate xssFlow(XssNode source, XssNode sink, string message) {
2527
// standard taint-tracking
2628
exists(
27-
TaintTrackingConfiguration c, DataFlow::PathNode sourceNode, DataFlow::PathNode sinkNode
29+
TaintTrackingConfiguration c, DataFlow2::PathNode sourceNode, DataFlow2::PathNode sinkNode
2830
|
2931
sourceNode = source.asDataFlowNode() and
3032
sinkNode = sink.asDataFlowNode() and
@@ -46,7 +48,7 @@ module XSS {
4648

4749
module PathGraph {
4850
query predicate edges(XssNode pred, XssNode succ) {
49-
exists(DataFlow::PathNode a, DataFlow::PathNode b | DataFlow::PathGraph::edges(a, b) |
51+
exists(DataFlow2::PathNode a, DataFlow2::PathNode b | DataFlow2::PathGraph::edges(a, b) |
5052
pred.asDataFlowNode() = a and
5153
succ.asDataFlowNode() = b
5254
)
@@ -57,7 +59,7 @@ module XSS {
5759
}
5860

5961
private newtype TXssNode =
60-
TXssDataFlowNode(DataFlow::PathNode node) or
62+
TXssDataFlowNode(DataFlow2::PathNode node) or
6163
TXssAspNode(AspInlineMember m)
6264

6365
/**
@@ -73,20 +75,20 @@ module XSS {
7375
Location getLocation() { none() }
7476

7577
/** Gets the data flow node corresponding to this node, if any. */
76-
DataFlow::PathNode asDataFlowNode() { result = this.(XssDataFlowNode).getDataFlowNode() }
78+
DataFlow2::PathNode asDataFlowNode() { result = this.(XssDataFlowNode).getDataFlowNode() }
7779

7880
/** Gets the ASP inline code element corresponding to this node, if any. */
7981
AspInlineMember asAspInlineMember() { result = this.(XssAspNode).getAspInlineMember() }
8082
}
8183

8284
/** A data flow node, viewed as an XSS flow node. */
8385
class XssDataFlowNode extends TXssDataFlowNode, XssNode {
84-
DataFlow::PathNode node;
86+
DataFlow2::PathNode node;
8587

8688
XssDataFlowNode() { this = TXssDataFlowNode(node) }
8789

8890
/** Gets the data flow node corresponding to this node. */
89-
DataFlow::PathNode getDataFlowNode() { result = node }
91+
DataFlow2::PathNode getDataFlowNode() { result = node }
9092

9193
override string toString() { result = node.toString() }
9294

@@ -130,7 +132,7 @@ module XSS {
130132
/**
131133
* A taint-tracking configuration for cross-site scripting (XSS) vulnerabilities.
132134
*/
133-
class TaintTrackingConfiguration extends TaintTracking::Configuration {
135+
class TaintTrackingConfiguration extends TaintTracking2::Configuration {
134136
TaintTrackingConfiguration() { this = "XSSDataFlowConfiguration" }
135137

136138
override predicate isSource(DataFlow::Node source) { source instanceof Source }

0 commit comments

Comments
 (0)