File tree Expand file tree Collapse file tree 2 files changed +13
-12
lines changed
javascript/ql/src/semmle/javascript Expand file tree Collapse file tree 2 files changed +13
-12
lines changed Original file line number Diff line number Diff line change @@ -167,12 +167,8 @@ module Koa {
167167 kind = "body" and
168168 this .asExpr ( ) .( PropAccess ) .accesses ( request , "body" )
169169 or
170- exists ( PropAccess query |
171- kind = "parameter" and
172- // `ctx.request.query.name`
173- query .accesses ( request , "query" ) and
174- this .asExpr ( ) .( PropAccess ) .accesses ( query , _)
175- )
170+ kind = "parameter" and
171+ this = getAQueryParameterAccess ( rh )
176172 or
177173 exists ( string propName |
178174 // `ctx.request.url`, `ctx.request.originalUrl`, or `ctx.request.href`
@@ -203,6 +199,16 @@ module Koa {
203199 override string getKind ( ) {
204200 result = kind
205201 }
202+
203+ override predicate isUserControlledObject ( ) {
204+ this = getAQueryParameterAccess ( rh )
205+ }
206+
207+ }
208+
209+ private DataFlow:: Node getAQueryParameterAccess ( RouteHandler rh ) {
210+ // `ctx.request.query.name`
211+ result .asExpr ( ) .( PropAccess ) .getBase ( ) .( PropAccess ) .accesses ( rh .getARequestExpr ( ) , "query" )
206212 }
207213
208214 /**
Original file line number Diff line number Diff line change @@ -54,12 +54,7 @@ module TypeConfusionThroughParameterTampering {
5454 private class TypeTamperableRequestParameter extends Source {
5555
5656 TypeTamperableRequestParameter ( ) {
57- this .( HTTP:: RequestInputAccess ) .getKind ( ) = "parameter" and
58- not exists ( Express:: RequestExpr request , DataFlow:: PropRead base |
59- // Express's `req.params.name` is always a string
60- base .accesses ( request .flow ( ) , "params" ) and
61- this = base .getAPropertyRead ( _)
62- )
57+ this .( HTTP:: RequestInputAccess ) .isUserControlledObject ( )
6358 }
6459
6560 }
You can’t perform that action at this time.
0 commit comments