Skip to content

CI: fix template injection in workflow run: blocks#6445

Closed
brtnfld wants to merge 10 commits into
HDFGroup:developfrom
brtnfld:fix/workflow-template-injection
Closed

CI: fix template injection in workflow run: blocks#6445
brtnfld wants to merge 10 commits into
HDFGroup:developfrom
brtnfld:fix/workflow-template-injection

Conversation

@brtnfld

@brtnfld brtnfld commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • ${{ inputs.* }} and ${{ steps.*.outputs.* }} expressions used directly inside run: shell blocks are a template-injection vector: the expression is expanded as literal text into the shell script before the shell parses it, so values containing shell metacharacters could alter the command
  • Move all such expressions to env: blocks on the same step and reference them as plain shell variables ($VAR) or PowerShell variables ($env:VAR)
  • Expressions in env: are expanded safely by the Actions runner before the shell sees them, eliminating the injection path
  • Fixes zizmor template-injection findings across 6 files: setup-jextract/action.yml, symlink-ctest-scripts/action.yml, abi-report.yml, ctest.yml, maven-deploy.yml, maven-staging.yml

Move ${{ inputs.* }} and ${{ steps.*.outputs.* }} expressions from
run: shell blocks into env: blocks on the same step, then reference
them as plain shell/$env:PSVar variables. This eliminates the
template-injection vector that zizmor flags: expressions in env: are
expanded safely before the shell sees them, while expressions inlined
directly in run: are expanded as literal text into the script and can
be dangerous if the value contains shell metacharacters.

@github-advanced-security github-advanced-security AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

zizmor found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

@github-actions

github-actions Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Review Checklist

This PR touches the following areas. Each needs at least one
sign-off from its listed owners before merging — an approval
covering only one area does not satisfy the others.

brtnfld added 5 commits June 11, 2026 16:10
Complete the template-injection fix across all affected workflow files.
Moves ${{ inputs.* }}, ${{ steps.*.outputs.* }}, ${{ matrix.* }},
${{ vars.* }}, ${{ secrets.* }}, ${{ runner.* }}, and
${{ github.event.repository.* }} expressions from run: shell blocks
into env: blocks on the same step, then references them as plain shell
variables. 44 files changed, 0 error[template-injection] findings
remain.
…njection fix script

- main.yml, vfd-ros3.yml: rename invalid YAML key
  'INPUT_FORCE_JAVA_IMPLEMENTATION == '\''JNI'\''' → ENABLE_JNI; fix
  shell references accordingly
- main.yml: rename unreadable '_MATRIX_OSTYPE_____WINDOWS__' → IS_NOT_WINDOWS
- maven-deploy.yml: rename invalid YAML key 'GPG_PRIVATE_KEY != '\'''\''' → HAS_GPG_KEY;
  fix shell reference
- maven-build-test.yml: rename verbose auto-generated
  'FORMAT__HTTPS___MAVEN_PKG_GITHUB_COM__0____GITHUB_REPOSITORY_' → MAVEN_PKG_URL
- ctest.yml: fix PowerShell env var syntax $RUNNER_WORKSPACE → $env:RUNNER_WORKSPACE
- analysis.yml: fix bash variable boundary $REPO_FULL_NAME_COV → ${REPO_FULL_NAME}_COV
RUNNER_WORKSPACE is a built-in GitHub Actions environment variable
automatically available on all runners. Explicitly re-mapping it via
env: RUNNER_WORKSPACE: ${{ runner.workspace }} in every step is pure
boilerplate. Remove it from 33 files (170 lines total); run scripts
already reference $RUNNER_WORKSPACE / $env:RUNNER_WORKSPACE and will
continue to work unchanged.
…eanup

Removing the RUNNER_WORKSPACE mappings in the previous commit left 88
bare env: lines (no key-value pairs) across 16 workflow files. Empty
env: blocks are invalid per the GitHub Actions schema and cause
actionlint warnings. Strip them all.
@brtnfld brtnfld requested a review from jhendersonHDF June 11, 2026 21:47
brtnfld added 3 commits June 11, 2026 16:57
The earlier global sed incorrectly converted $RUNNER_WORKSPACE to
$env:RUNNER_WORKSPACE in bash steps as well as PowerShell steps.
$env:RUNNER_WORKSPACE is PowerShell-only syntax; bash steps must
use $RUNNER_WORKSPACE. Restore 58 bash-step references while keeping
$env:RUNNER_WORKSPACE in the 31 shell: pwsh blocks where it is correct.
@brtnfld brtnfld removed the request for review from hyoklee June 11, 2026 22:10
@brtnfld

brtnfld commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator Author

Closing in favor of a targeted fix. The reusable workflow files fixed here receive their inputs from the calling workflow (call-workflows.yml), which is clean — so those fixes were unnecessary. A new PR will address only the genuine risks: workflow_dispatch inputs used directly in run: blocks in java-implementation-test.yml, maven-staging.yml, maven-build-test.yml, test-maven-packages.yml, publish-branch.yml, and test-binary-installation.yml.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants