Skip to content

Commit 563dc62

Browse files
committed
Improve qldoc for ServiceStack.qll
1 parent 3f1f83f commit 563dc62

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

csharp/ql/src/semmle/code/csharp/frameworks/ServiceStack.qll

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
/**
2+
* General modelling of ServiceStack framework including separate modules for:
3+
* - flow sources
4+
* - SQLi sinks
5+
* - XSS sinks
6+
*/
7+
18
import csharp
29

310
/** Provides definitions related to the namespace `ServiceStack`. */
@@ -52,6 +59,13 @@ module Sources {
5259
)
5360
}
5461

62+
/**
63+
* Remote flow sources for ServiceStack
64+
*
65+
* Assumes all nested fields/properties on request DTOs are tainted, which is
66+
* an overapproximation and may lead to FPs depending on how Service Stack app
67+
* is configured.
68+
*/
5569
class ServiceStackSource extends RemoteFlowSource {
5670
ServiceStackSource() {
5771
// Parameters are sources. In practice only interesting when they are string/primitive typed.
@@ -70,11 +84,12 @@ module Sources {
7084
}
7185
}
7286

73-
/** SQL sinks for the ServiceStack framework */
87+
/** SQLi support for the ServiceStack framework */
7488
module SQL {
7589
private import ServiceStack::ServiceStack
7690
private import semmle.code.csharp.security.dataflow.SqlInjection::SqlInjection
7791

92+
/** SQLi sinks for ServiceStack */
7893
class ServiceStackSink extends Sink {
7994
ServiceStackSink() {
8095
exists(MethodCall mc, Method m, int p |
@@ -116,24 +131,21 @@ module SQL {
116131
}
117132
}
118133

119-
/** XSS sinks for the ServiceStack framework */
134+
/** XSS support for ServiceStack framework */
120135
module XSS {
121136
private import ServiceStack::ServiceStack
122137
private import semmle.code.csharp.security.dataflow.XSS::XSS
123138

124-
class XssSinks extends Sink {
125-
XssSinks() { this.asExpr() instanceof XssExpr }
126-
}
127-
128-
class XssExpr extends Expr {
129-
XssExpr() {
139+
/** XSS sinks for ServiceStack */
140+
class XssSink extends Sink {
141+
XssSink() {
130142
exists(ServiceClass service, ReturnStmt r |
131-
this = r.getExpr() and
143+
this.asExpr() = r.getExpr() and
132144
r.getEnclosingCallable() = service.getARequestMethod()
133145
) or
134146
exists(ObjectCreation oc |
135147
oc.getType().hasQualifiedName("ServiceStack.HttpResult") and
136-
this = oc.getArgument(0)
148+
this.asExpr() = oc.getArgument(0)
137149
)
138150
}
139151
}

0 commit comments

Comments
 (0)