1
+ /**
2
+ * General modelling of ServiceStack framework including separate modules for:
3
+ * - flow sources
4
+ * - SQLi sinks
5
+ * - XSS sinks
6
+ */
7
+
1
8
import csharp
2
9
3
10
/** Provides definitions related to the namespace `ServiceStack`. */
@@ -52,6 +59,13 @@ module Sources {
52
59
)
53
60
}
54
61
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
+ */
55
69
class ServiceStackSource extends RemoteFlowSource {
56
70
ServiceStackSource ( ) {
57
71
// Parameters are sources. In practice only interesting when they are string/primitive typed.
@@ -70,11 +84,12 @@ module Sources {
70
84
}
71
85
}
72
86
73
- /** SQL sinks for the ServiceStack framework */
87
+ /** SQLi support for the ServiceStack framework */
74
88
module SQL {
75
89
private import ServiceStack:: ServiceStack
76
90
private import semmle.code.csharp.security.dataflow.SqlInjection:: SqlInjection
77
91
92
+ /** SQLi sinks for ServiceStack */
78
93
class ServiceStackSink extends Sink {
79
94
ServiceStackSink ( ) {
80
95
exists ( MethodCall mc , Method m , int p |
@@ -116,24 +131,21 @@ module SQL {
116
131
}
117
132
}
118
133
119
- /** XSS sinks for the ServiceStack framework */
134
+ /** XSS support for ServiceStack framework */
120
135
module XSS {
121
136
private import ServiceStack:: ServiceStack
122
137
private import semmle.code.csharp.security.dataflow.XSS:: XSS
123
138
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 ( ) {
130
142
exists ( ServiceClass service , ReturnStmt r |
131
- this = r .getExpr ( ) and
143
+ this . asExpr ( ) = r .getExpr ( ) and
132
144
r .getEnclosingCallable ( ) = service .getARequestMethod ( )
133
145
) or
134
146
exists ( ObjectCreation oc |
135
147
oc .getType ( ) .hasQualifiedName ( "ServiceStack.HttpResult" ) and
136
- this = oc .getArgument ( 0 )
148
+ this . asExpr ( ) = oc .getArgument ( 0 )
137
149
)
138
150
}
139
151
}
0 commit comments