Skip to content

Commit 4c97f68

Browse files
committed
remove postmessage events as source for js/resource-exhaustion
1 parent 51a0b6d commit 4c97f68

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

javascript/ql/lib/semmle/javascript/security/dataflow/ResourceExhaustionCustomizations.qll

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ module ResourceExhaustion {
2929

3030
/** A source of remote user input, considered as a data flow source for resource exhaustion vulnerabilities. */
3131
class RemoteFlowSourceAsSource extends Source instanceof RemoteFlowSource {
32-
RemoteFlowSourceAsSource() { not this instanceof ClientSideRemoteFlowSource }
32+
RemoteFlowSourceAsSource() {
33+
// exclude source that only happen client-side
34+
not this instanceof ClientSideRemoteFlowSource and
35+
not this = DataFlow::parameterNode(any(PostMessageEventHandler pmeh).getEventParameter())
36+
}
3337
}
3438

3539
/**

javascript/ql/test/query-tests/Security/CWE-770/ResourceExhaustion/resource-exhaustion.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,8 @@ function browser() {
9898
setTimeout(() => {
9999
console.log("f00");
100100
}, delay); // OK - source is client side
101+
102+
window.onmessage = (e) => {
103+
setTimeout(() => {}, e.data); // OK - source is client side
104+
}
101105
}

0 commit comments

Comments
 (0)