forked from github/codeql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEnvVarInjectionMedium.ql
More file actions
37 lines (35 loc) · 1.31 KB
/
EnvVarInjectionMedium.ql
File metadata and controls
37 lines (35 loc) · 1.31 KB
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
34
35
36
37
/**
* @name Environment variable built from user-controlled sources
* @description Building an environment variable from user-controlled sources may alter the execution of following system commands
* @kind path-problem
* @problem.severity error
* @security-severity 5.0
* @precision medium
* @id actions/envvar-injection/medium
* @tags actions
* security
* external/cwe/cwe-077
* external/cwe/cwe-020
*/
import actions
import codeql.actions.security.EnvVarInjectionQuery
import codeql.actions.dataflow.ExternalFlow
import codeql.actions.dataflow.FlowSources
import EnvVarInjectionFlow::PathGraph
from EnvVarInjectionFlow::PathNode source, EnvVarInjectionFlow::PathNode sink
where
EnvVarInjectionFlow::flowPath(source, sink) and
inNonPrivilegedContext(sink.getNode().asExpr()) and
// exclude paths to file read sinks from non-artifact sources
(
not source.getNode().(RemoteFlowSource).getSourceType() = "artifact"
or
source.getNode().(RemoteFlowSource).getSourceType() = "artifact" and
(
sink.getNode() instanceof EnvVarInjectionFromFileReadSink or
madSink(sink.getNode(), "envvar-injection")
)
)
select sink.getNode(), source, sink,
"Potential environment variable injection in $@, which may be controlled by an external user.",
sink, sink.getNode().toString()