Skip to content

Commit 826541d

Browse files
committed
Actions: EnvPathInjection
1 parent 6e5c7f7 commit 826541d

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

actions/ql/lib/codeql/actions/security/EnvPathInjectionQuery.qll

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ private import codeql.actions.TaintTracking
33
private import codeql.actions.dataflow.ExternalFlow
44
private import codeql.actions.security.ArtifactPoisoningQuery
55
private import codeql.actions.security.UntrustedCheckoutQuery
6+
private import codeql.actions.security.ControlChecks
67

78
abstract class EnvPathInjectionSink extends DataFlow::Node { }
89

@@ -110,7 +111,32 @@ private module EnvPathInjectionConfig implements DataFlow::ConfigSig {
110111
}
111112

112113
predicate observeDiffInformedIncrementalMode() {
113-
any() // TODO: Make sure that the location overrides match the query's select clause: Column 7 does not select a source or sink originating from the flow call on line 23 (/Users/d10c/src/semmle-code/ql/actions/ql/src/Security/CWE-077/EnvPathInjectionCritical.ql@39:36:39:40)
114+
any()
115+
}
116+
117+
Location getASelectedSourceLocation(DataFlow::Node source) {
118+
none()
119+
}
120+
121+
Location getASelectedSinkLocation(DataFlow::Node sink) {
122+
result = sink.getLocation()
123+
or // where clause from EnvPathInjectionCritical.ql
124+
exists(Event event, RemoteFlowSource source | result = event.getLocation() |
125+
inPrivilegedContext(sink.asExpr(), event) and
126+
isSource(source) and
127+
(
128+
not source.getSourceType() = "artifact" and
129+
not exists(ControlCheck check |
130+
check.protects(sink.asExpr(), event, "code-injection")
131+
)
132+
or
133+
source.getSourceType() = "artifact" and
134+
not exists(ControlCheck check |
135+
check.protects(sink.asExpr(), event, ["untrusted-checkout", "artifact-poisoning"])
136+
) and
137+
sink instanceof EnvPathInjectionFromFileReadSink
138+
)
139+
)
114140
}
115141
}
116142

0 commit comments

Comments
 (0)