Skip to content

Commit d84333d

Browse files
committed
added *ReadBody* Methods as UntrustedFlowSource
1 parent bfa0fb6 commit d84333d

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

go/ql/lib/semmle/go/frameworks/Fasthttp.qll

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,12 @@ module Fasthttp {
399399
]) and
400400
this = m.getACall().getResult(0)
401401
)
402+
or
403+
exists(Method m |
404+
m.hasQualifiedName(packagePath(), "Request",
405+
["ReadBody", "ReadLimitBody", "ContinueReadBodyStream", "ContinueReadBody"]) and
406+
this = m.getACall().getArgument(0)
407+
)
402408
}
403409
}
404410

go/ql/test/library-tests/semmle/go/frameworks/Fasthttp/fasthttp.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,13 @@ func fasthttpServer() {
166166
body2, _ := requestCtx.Request.BodyInflate() // $ UntrustedFlowSource="... := ...[0]"
167167
body3, _ := requestCtx.Request.BodyUnbrotli() // $ UntrustedFlowSource="... := ...[0]"
168168
body4, _ := requestCtx.Request.BodyUncompressed() // $ UntrustedFlowSource="... := ...[0]"
169-
requestCtx.Request.BodyStream() // $ UntrustedFlowSource="call to BodyStream"
170-
requestCtx.Request.ReadBody(dstReader, 100, 1000)
171-
requestCtx.Request.ReadLimitBody(dstReader, 100)
172-
requestCtx.Request.ContinueReadBodyStream(dstReader, 100, true)
173-
requestCtx.Request.ContinueReadBody(dstReader, 100)
174169
fmt.Println(body1, body2, body3, body4)
170+
requestCtx.Request.BodyStream() // $ UntrustedFlowSource="call to BodyStream"
171+
172+
requestCtx.Request.ReadBody(dstReader, 100, 1000) // $ UntrustedFlowSource="dstReader"
173+
requestCtx.Request.ReadLimitBody(dstReader, 100) // $ UntrustedFlowSource="dstReader"
174+
requestCtx.Request.ContinueReadBodyStream(dstReader, 100, true) // $ UntrustedFlowSource="dstReader"
175+
requestCtx.Request.ContinueReadBody(dstReader, 100) // $ UntrustedFlowSource="dstReader"
175176

176177
// Response methods
177178
// Xss Sinks Related method
@@ -186,6 +187,7 @@ func fasthttpServer() {
186187
fmt.Fprintf(rspWriter, "%s", userInputByte) // $ XssSink=userInputByte
187188
io.WriteString(rspWriter, userInput) // $ XssSink=userInput
188189
io.TeeReader(userInputReader, rspWriter) // $ XssSink=userInputReader
190+
io.TeeReader(userInputReader, rspWriter) // $ XssSink=userInputReader
189191
bufioReader := bufio.NewReader(dstReader)
190192
bufioReader.WriteTo(rspWriter) // $ XssSink=bufioReader
191193
bytesUserInput := bytes.NewBuffer(userInputByte)

0 commit comments

Comments
 (0)