Skip to content

fix: route workflow_dispatch inputs through env vars to prevent template injection (template-injection) #1532

Closed

Description

@planetf1

Summary

Tracked from #331 (zizmor CI gate). PR #1530 introduced zizmor enforcement and found that dispatch-to-contribs.yml uses ${{ github.event.inputs.version }} directly inside run: blocks, which is a template injection vector.

The workflow is workflow_dispatch and release-triggered only — no external attacker can trigger it without maintainer write access. The practical risk is low (requires insider intent or a compromised maintainer account), but the fix is mechanical and eliminates the issue entirely.

Affected locations

File Lines Expression
dispatch-to-contribs.yml 33–34 ${{ github.event.inputs.version }} in version-resolve run: block
dispatch-to-contribs.yml 60 ${{ steps.version.outputs.version }} in dispatch run: block (low confidence)

Fix

Route template expressions through environment variables per the AGENTS.md convention:

# Before (vulnerable)
run: |
  if [ -n "${{ github.event.inputs.version }}" ]; then
    VERSION="${{ github.event.inputs.version }}"

# After (safe)
env:
  INPUT_VERSION: ${{ github.event.inputs.version }}
run: |
  if [ -n "${INPUT_VERSION}" ]; then
    VERSION="${INPUT_VERSION}"

zizmor --fix can generate the corrected form automatically.

Definition of done

  1. Route all template expressions in run: blocks through env: vars
  2. Remove the template-injection entries from .github/zizmor.yml
  3. zizmor reports no template-injection findings in dispatch-to-contribs.yml

Activity

  1. added
    p2
    security
    chore
    on Aug 11, 2026
  2. simoncraf commented on Sep 27, 2026

    @simoncraf
    Contributor

    I would like to work on this.

  3. planetf1 commented on Sep 30, 2026

    @planetf1
    ContributorAuthor

    Corrected a line-number error in the affected-locations table: the low-confidence steps.version.outputs.version finding is on line 60 (--field 'client_payload[version]=...'), not 59 — 59 is the preceding --field event_type=... line. Verified against a live zizmor run against this file: lines 33 and 34 are High confidence, line 60 is Low confidence, all matching the fix pattern described above.

  4. planetf1 commented on Sep 30, 2026

    @planetf1
    ContributorAuthor

    Assigned to @simoncraf — go ahead!

  5. added a commit that references this issue on Oct 8, 2026
    7db6761
  6. added a commit that references this issue on Oct 9, 2026
    84c3cea
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

chorep2security

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions