Skip to content

Commit ed48efe

Browse files
committed
recognize access to a query object through function calls
1 parent f792998 commit ed48efe

File tree

1 file changed

+14
-5
lines changed
  • javascript/ql/src/semmle/javascript/frameworks

1 file changed

+14
-5
lines changed

javascript/ql/src/semmle/javascript/frameworks/Express.qll

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,16 @@ module Express {
463463
override RequestSource src;
464464
}
465465

466+
/**
467+
* Gets a reference to the "query" or "params" object from a request-object originating from route-handler `rh`.
468+
*/
469+
DataFlow::SourceNode getAQueryObjectReference(DataFlow::TypeTracker t, RouteHandler rh) {
470+
t.startInProp(["params", "query"]) and
471+
result = rh.getARequestSource()
472+
or
473+
exists(DataFlow::TypeTracker t2 | result = getAQueryObjectReference(t2, rh).track(t2, t))
474+
}
475+
466476
/**
467477
* An access to a user-controlled Express request input.
468478
*/
@@ -471,13 +481,12 @@ module Express {
471481
string kind;
472482

473483
RequestInputAccess() {
484+
kind = "parameter" and
485+
this = getAQueryObjectReference(DataFlow::TypeTracker::end(), rh).getAPropertyRead()
486+
or
474487
exists(DataFlow::SourceNode request | request = rh.getARequestSource().ref() |
475488
kind = "parameter" and
476-
(
477-
this = request.getAMethodCall("param")
478-
or
479-
this = request.getAPropertyRead(["params", "query"]).getAPropertyRead()
480-
)
489+
this = request.getAMethodCall("param")
481490
or
482491
// `req.originalUrl`
483492
kind = "url" and

0 commit comments

Comments
 (0)