Summary
gh aw compile generates lock workflows that interpolate ${{ runner.tool_cache }} directly inside an executable shell run: block.
CodeQL flags this as actions/code-injection/medium.
We have several workflows that use on.workflow-call and use a centralized repo ops pattern. The centralized workflow is extremely important to use to maintain workflows in one place.
The ${{ runner.tool_cache }} appears more broadly but the CodeQL alerts appear related to workflows that use the on.workflow-call.
Generated Code
- name: Set runtime paths
id: set-runtime-paths
run: |
if [ -z "${RUNNER_TOOL_CACHE:-}" ]; then
echo "RUNNER_TOOL_CACHE=${{ runner.tool_cache }}" >> "$GITHUB_ENV"
fi
CodeQL Alert
Potential code injection in ${{ runner.tool_cache }}, which may be controlled by external user.
Observed Context
This appears in generated .lock.yml files produced by gh aw compile.
The source .md workflow files do not contain this shell line. It is introduced by compilation, so manual editing is not durable.
Version
Observed in v 0.87.10
Proposed fix
Replace with
env:
GH_AW_RUNNER_TOOL_CACHE: ${{ runner.tool_cache }}
run: |
if [ -z "${RUNNER_TOOL_CACHE:-}" ]; then
echo "RUNNER_TOOL_CACHE=${{ GH_AW_RUNNER_TOOL_CACHE }}" >> "$GITHUB_ENV"
fi
Request
Please update gh aw compile so ${{ runner.tool_cache }} is passed through env: and referenced as a shell variable, rather then being interpolated directly into executable run: script text.
Impact
We have a centralized workflow with a large number of reusable workflows, so the count of CodeQL alerts is significant.
Thank you for reviewing the matter.
Summary
gh aw compilegenerates lock workflows that interpolate${{ runner.tool_cache }}directly inside an executable shellrun:block.CodeQL flags this as
actions/code-injection/medium.We have several workflows that use
on.workflow-calland use a centralized repo ops pattern. The centralized workflow is extremely important to use to maintain workflows in one place.The
${{ runner.tool_cache }}appears more broadly but the CodeQL alerts appear related to workflows that use theon.workflow-call.Generated Code
CodeQL Alert
Potential code injection in
${{ runner.tool_cache }}, which may be controlled by external user.Observed Context
This appears in generated .lock.yml files produced by gh aw compile.
The source .md workflow files do not contain this shell line. It is introduced by compilation, so manual editing is not durable.
Version
Observed in v 0.87.10
Proposed fix
Replace with
Request
Please update gh aw compile so ${{ runner.tool_cache }} is passed through env: and referenced as a shell variable, rather then being interpolated directly into executable run: script text.
Impact
We have a centralized workflow with a large number of reusable workflows, so the count of CodeQL alerts is significant.
Thank you for reviewing the matter.