forked from github/codeql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEnvValueInjection.ql
33 lines (26 loc) · 1.12 KB
/
EnvValueInjection.ql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/**
* @name User controlled environment variable value injection
* @description assigning important environment variables from user controlled data is not secure
* @kind path-problem
* @id js/env-value-injection
* @problem.severity error
* @security-severity 7.5
* @precision medium
* @tags security
* external/cwe/cwe-089
*/
import javascript
/** A taint tracking configuration for unsafe environment injection. */
module EnvValueInjectionConfig implements DataFlow::ConfigSig {
predicate isSource(DataFlow::Node source) { source instanceof RemoteFlowSource }
predicate isSink(DataFlow::Node sink) {
sink = API::moduleImport("process").getMember("env").getAMember().asSink()
}
predicate observeDiffInformedIncrementalMode() { any() }
}
module EnvValueInjectionFlow = TaintTracking::Global<EnvValueInjectionConfig>;
import EnvValueInjectionFlow::PathGraph
from EnvValueInjectionFlow::PathNode source, EnvValueInjectionFlow::PathNode sink
where EnvValueInjectionFlow::flowPath(source, sink)
select sink.getNode(), source, sink, "this environment variable assignment is $@.",
source.getNode(), "user controllable"