Skip to content

Commit 71a7ec5

Browse files
committed
Use StringOps to identify functions used for verifing the origin
1 parent c490cfd commit 71a7ec5

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

javascript/ql/src/experimental/Security/CWE-020/PostMessageNoOriginCheck.ql

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,12 @@ import semmle.javascript.security.dataflow.DOM
1717
/**
1818
* A method call for the insecure functions used to verify the `MessageEvent.origin`.
1919
*/
20-
class InsufficientOriginChecks extends DataFlow::MethodCallNode {
20+
class InsufficientOriginChecks extends DataFlow::Node {
2121
InsufficientOriginChecks() {
22-
exists(string name | name = getMethodName() |
23-
name = "indexOf" or
24-
name = "includes" or
25-
name = "endsWith" or
26-
name = "startsWith" or
27-
name = "lastIndexOf"
22+
exists(DataFlow::Node node |
23+
this.(StringOps::StartsWith).getSubstring() = node or
24+
this.(StringOps::Includes).getSubstring() = node or
25+
this.(StringOps::EndsWith).getSubstring() = node
2826
)
2927
}
3028
}

0 commit comments

Comments
 (0)