Skip to content

[WIP] Fix template injection error in sync-actions.yml#9

Merged
pelikhan merged 2 commits intomainfrom
copilot/fix-template-injection-error
Mar 11, 2026
Merged

[WIP] Fix template injection error in sync-actions.yml#9
pelikhan merged 2 commits intomainfrom
copilot/fix-template-injection-error

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 11, 2026

  • Fix template injection vulnerability in .github/workflows/sync-actions.yml
    • Pass inputs.ref as an environment variable (INPUT_REF: ${{ inputs.ref }}) in the "Resolve ref" step's env: section
    • Change RAW_REF="${{ inputs.ref }}" to RAW_REF="${INPUT_REF}" to avoid direct shell expansion of user-controlled input

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

…sync-actions.yml

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@pelikhan pelikhan marked this pull request as ready for review March 11, 2026 14:46
Copilot AI review requested due to automatic review settings March 11, 2026 14:46
@pelikhan pelikhan merged commit c81663e into main Mar 11, 2026
2 checks passed
@pelikhan pelikhan deleted the copilot/fix-template-injection-error branch March 11, 2026 14:47
Copilot stopped work on behalf of pelikhan due to an error March 11, 2026 14:47
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to mitigate a GitHub Actions template-injection risk in the sync-actions.yml reusable workflow by avoiding direct ${{ inputs.ref }} interpolation inside a shell run: script.

Changes:

  • Pass inputs.ref via an environment variable (INPUT_REF) in the “Resolve ref” step.
  • Replace RAW_REF="${{ inputs.ref }}" with RAW_REF="${INPUT_REF}" to avoid direct expression interpolation in that step.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines 188 to +190
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
INPUT_REF: ${{ inputs.ref }}
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

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

This change prevents expression interpolation of inputs.ref in the "Resolve ref" step, but the workflow still directly expands ${{ inputs.ref }} inside a run: script in the earlier "Log workflow context" step (lines 44/46). That keeps the template-injection risk because a crafted ref value containing quotes/newlines could break the generated shell script before any permission checks run. Consider removing ${{ inputs.ref }} from all run: blocks (e.g., pass it via env at the job level and reference $INPUT_REF/use printf '%s\n' when logging).

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants