Skip to content

Commit 18bc008

Browse files
committed
Fix, prevent addHook return values from being treated as XSS sinks
1 parent fdfdcc0 commit 18bc008

File tree

1 file changed

+5
-1
lines changed
  • javascript/ql/lib/semmle/javascript/frameworks

1 file changed

+5
-1
lines changed

javascript/ql/lib/semmle/javascript/frameworks/Fastify.qll

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,9 @@ module Fastify {
175175
AddHookRouteSetup() { this.getMethodName() = "addHook" }
176176

177177
override predicate isMiddlewareSetup() { any() }
178+
179+
/** Gets the route handler that is being registered. */
180+
RouteHandler getARouteHandler() { result = this.getArgument(1) }
178181
}
179182

180183
/** Gets the name of the `n`th handler function that can be installed a route setup, in order of execution. */
@@ -328,7 +331,8 @@ module Fastify {
328331
ResponseSendArgument() {
329332
this = rh.getAResponseSource().ref().getAMethodCall("send").getArgument(0)
330333
or
331-
this = rh.(DataFlow::FunctionNode).getAReturn()
334+
this = rh.(DataFlow::FunctionNode).getAReturn() and
335+
not exists(AddHookRouteSetup hookSetup | rh = hookSetup.getARouteHandler())
332336
}
333337

334338
override RouteHandler getRouteHandler() { result = rh }

0 commit comments

Comments
 (0)