Skip to content

Commit e41080f

Browse files
author
Esben Sparre Andreasen
committed
JS: add RemoteServerResponse as a heuristic remote flow source
1 parent f7bfc47 commit e41080f

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

javascript/ql/src/semmle/javascript/heuristics/AdditionalSources.qll

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,25 @@ private class JSONStringifyAsCommandInjectionSource extends HeuristicSource,
3131
JSONStringifyAsCommandInjectionSource() {
3232
this = DataFlow::globalVarRef("JSON").getAMemberCall("stringify")
3333
}
34+
35+
override string getSourceType() { result = "a string from JSON.stringify" }
36+
}
37+
38+
/**
39+
* A response from a remote server.
40+
*/
41+
class RemoteServerResponse extends HeuristicSource, RemoteFlowSource {
42+
RemoteServerResponse() {
43+
exists(ClientRequest r |
44+
this = r.getAResponseDataNode() and
45+
not exists(string url, string protocolPattern |
46+
// exclude URLs to the current host
47+
r.getUrl().mayHaveStringValue(url) and
48+
protocolPattern = "(?[a-z+]{3,10}:)" and
49+
not url.regexpMatch(protocolPattern + "?//.*")
50+
)
51+
)
52+
}
53+
54+
override string getSourceType() { result = "a response from a remote server" }
3455
}

0 commit comments

Comments
 (0)