mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
JS: add js/command-line-injection heuristic source: JSON.stringify()
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
|
||||
import javascript
|
||||
import SyntacticHeuristics
|
||||
private import semmle.javascript.security.dataflow.CommandInjection
|
||||
|
||||
/**
|
||||
* A heuristic source of data flow in a security query.
|
||||
@@ -26,3 +27,13 @@ private class RemoteFlowPassword extends HeuristicSource, RemoteFlowSource {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* A use of `JSON.stringify`, viewed as a source for command line injections
|
||||
* since it does not properly escape single quotes and dollar symbols.
|
||||
*/
|
||||
private class JSONStringifyAsCommandInjectionSource extends HeuristicSource, CommandInjection::Source {
|
||||
JSONStringifyAsCommandInjectionSource() {
|
||||
this = DataFlow::globalVarRef("JSON").getAMemberCall("stringify")
|
||||
}
|
||||
}
|
||||
@@ -1,2 +1,3 @@
|
||||
| additionalCommandInjections.js:2:28:2:35 | password |
|
||||
| sources.js:2:5:2:12 | password |
|
||||
| sources.js:3:5:3:20 | JSON.stringify() |
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
(function() {
|
||||
password;
|
||||
JSON.stringify();
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user