Skip to content

Commit 4d33190

Browse files
committed
JS: Restrict this-argument passing in API graphs
1 parent 84c788a commit 4d33190

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

javascript/ql/lib/semmle/javascript/ApiGraphs.qll

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,7 +1324,9 @@ module API {
13241324
exists(DataFlow::TypeTracker t, StepSummary summary, DataFlow::SourceNode prev |
13251325
prev = trackUseNode(nd, promisified, boundArgs, prop, t) and
13261326
StepSummary::step(prev, res, summary) and
1327-
result = t.append(summary)
1327+
result = t.append(summary) and
1328+
// Block argument-passing into 'this'
1329+
not (summary = CallStep() and res instanceof DataFlow::ThisNode)
13281330
)
13291331
}
13301332

@@ -1381,7 +1383,9 @@ module API {
13811383
exists(DataFlow::TypeBackTracker t, StepSummary summary, DataFlow::Node next |
13821384
next = trackDefNode(nd, t) and
13831385
StepSummary::step(prev, next, summary) and
1384-
result = t.prepend(summary)
1386+
result = t.prepend(summary) and
1387+
// Block argument-passing steps from 'this' back to a receiver
1388+
not (summary = CallStep() and prev instanceof DataFlow::ThisNode)
13851389
)
13861390
}
13871391

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
| tst.js:4:17:4:119 | /** use ... rn() */ | use moduleImport("something").getMember("exports").getMember("one") has no outgoing edge labelled getMember("two"); it has no outgoing edges at all. |

0 commit comments

Comments
 (0)