Skip to content

Commit bfc7a8b

Browse files
authored
Merge pull request #22268 from theinfosecguy/js-response-threat-promise-chain
JS: Track response data through promises
2 parents 75cbcab + cbdc74e commit bfc7a8b

5 files changed

Lines changed: 458 additions & 0 deletions

File tree

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: minorAnalysis
3+
---
4+
* JavaScript security queries using the `response` threat model now track promise-wrapped client response data into promise fulfillment values. This may improve results for queries such as `js/xss` when response data is consumed through `.then(...)` chains.

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,6 +1016,18 @@ module ClientRequest {
10161016
override string getSourceType() { result = "HTTP response data" }
10171017
}
10181018

1019+
/**
1020+
* A taint step from promise-wrapped response data to the value that the promise resolves to.
1021+
*/
1022+
private class ClientRequestResponsePromiseStep extends TaintTracking::SharedTaintStep {
1023+
override predicate promiseStep(DataFlow::Node node1, DataFlow::Node node2) {
1024+
exists(ClientRequest r |
1025+
r.getAResponseDataNode(_, true).getALocalSource().flowsTo(node1) and
1026+
PromiseFlow::loadStep(node1, node2, Promises::valueProp())
1027+
)
1028+
}
1029+
}
1030+
10191031
/**
10201032
* An additional taint step that captures taint propagation from the receiver of fetch response methods
10211033
* (such as "json", "text", "blob", and "arrayBuffer") to the call result.

0 commit comments

Comments
 (0)