@@ -81,19 +81,15 @@ module Fasthttp {
81
81
}
82
82
}
83
83
84
- /**
85
- * The methods that can write to HTTP Response Body.
86
- * These methods can be dangerous if they are user controllable.
87
- */
88
- class HttpResponseBodySink extends SharedXss:: Sink {
89
- HttpResponseBodySink ( ) {
90
- exists ( Method m |
91
- m .hasQualifiedName ( packagePath ( ) , "RequestCtx" , [ "Success" , "SuccessString" ] ) and
92
- this = m .getACall ( ) .getArgument ( 1 )
93
- )
94
- }
84
+ private predicate responseBodyWriterResult ( DataFlow:: Node src ) {
85
+ exists ( Method responseBodyWriter |
86
+ responseBodyWriter .hasQualifiedName ( packagePath ( ) , "Response" , "BodyWriter" ) and
87
+ src = responseBodyWriter .getACall ( ) .getResult ( 0 )
88
+ )
95
89
}
96
90
91
+ private module ResponseBodyWriterFlow = DataFlow:: SimpleGlobal< responseBodyWriterResult / 1 > ;
92
+
97
93
private class ResponseBody extends Http:: ResponseBody:: Range {
98
94
DataFlow:: MethodCallNode call ;
99
95
string methodName ;
@@ -112,6 +108,14 @@ module Fasthttp {
112
108
"AppendBody" , "AppendBodyString" , "SetBody" , "SetBodyRaw" , "SetBodyStream" ,
113
109
"SetBodyString" , "Success" , "SuccessString"
114
110
]
111
+ or
112
+ exists ( Method write , DataFlow:: CallNode writeCall |
113
+ write .hasQualifiedName ( "io" , "Writer" , "Write" ) and
114
+ writeCall = write .getACall ( ) and
115
+ ResponseBodyWriterFlow:: flowsTo ( writeCall .getReceiver ( ) ) and
116
+ this = writeCall .getArgument ( 0 )
117
+ ) and
118
+ methodName = "BodyWriter"
115
119
}
116
120
117
121
override Http:: ResponseWriter getResponseWriter ( ) { result .getANode ( ) = call .getReceiver ( ) }
0 commit comments