Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b743ee4

Browse files
authored
Merge pull request #314 from esben-semmle/js/json-stringify-as-command-line-injection-source-heuristic
Approved by xiemaisi
2 parents a525c18 + 2881649 commit b743ee4

3 files changed

Lines changed: 13 additions & 0 deletions

File tree

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import javascript
88
import SyntacticHeuristics
9+
private import semmle.javascript.security.dataflow.CommandInjection
910

1011
/**
1112
* A heuristic source of data flow in a security query.
@@ -26,3 +27,13 @@ private class RemoteFlowPassword extends HeuristicSource, RemoteFlowSource {
2627
}
2728

2829
}
30+
31+
/**
32+
* A use of `JSON.stringify`, viewed as a source for command line injections
33+
* since it does not properly escape single quotes and dollar symbols.
34+
*/
35+
private class JSONStringifyAsCommandInjectionSource extends HeuristicSource, CommandInjection::Source {
36+
JSONStringifyAsCommandInjectionSource() {
37+
this = DataFlow::globalVarRef("JSON").getAMemberCall("stringify")
38+
}
39+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
| additionalCommandInjections.js:2:28:2:35 | password |
22
| sources.js:2:5:2:12 | password |
3+
| sources.js:3:5:3:20 | JSON.stringify() |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
(function() {
22
password;
3+
JSON.stringify();
34
})();

0 commit comments

Comments
 (0)