Skip to content

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

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

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,40 @@ private module EnvVarInjectionConfig implements DataFlow::ConfigSig {
163163
exists(run.getScript().getAFileReadCommand())
164164
)
165165
}
166+
167+
predicate observeDiffInformedIncrementalMode() { any() }
168+
169+
Location getASelectedSourceLocation(DataFlow::Node source) { none() }
170+
171+
Location getASelectedSinkLocation(DataFlow::Node sink) {
172+
result = sink.getLocation()
173+
or
174+
// where clause from EnvVarInjectionCritical.ql
175+
exists(Event event, RemoteFlowSource source | result = event.getLocation() |
176+
inPrivilegedContext(sink.asExpr(), event) and
177+
isSource(source) and
178+
// exclude paths to file read sinks from non-artifact sources
179+
(
180+
// source is text
181+
not source.getSourceType() = "artifact" and
182+
not exists(ControlCheck check |
183+
check.protects(sink.asExpr(), event, ["envvar-injection", "code-injection"])
184+
)
185+
or
186+
// source is an artifact or a file from an untrusted checkout
187+
source.getSourceType() = "artifact" and
188+
not exists(ControlCheck check |
189+
check
190+
.protects(sink.asExpr(), event,
191+
["envvar-injection", "untrusted-checkout", "artifact-poisoning"])
192+
) and
193+
(
194+
sink instanceof EnvVarInjectionFromFileReadSink or
195+
madSink(sink, "envvar-injection")
196+
)
197+
)
198+
)
199+
}
166200
}
167201

168202
/** Tracks flow of unsafe user input that is used to construct and evaluate an environment variable. */

0 commit comments

Comments
 (0)