ci: prevent script injection via github.head_ref in gendoc-docs - #315
Merged
Conversation
github.head_ref is the pull request's branch name and is controllable by the PR author. Expanding it directly into the `run:` script let a crafted branch name inject shell commands into the "Commit the regenerated catalog" step (OSSF Scorecard "Dangerous-Workflow", the only code-level code-scanning alert). Route it through an environment variable and reference it quoted, so the shell -- not the Actions template engine -- handles the branch name as data. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Kwid3AAwhHZQzCEGSoYdPY
Reefact
enabled auto-merge
July 27, 2026 10:42
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the one code-level alert on the code-scanning dashboard: the OSSF Scorecard
Dangerous-Workflow finding in
gendoc-docs.yml. The workflow expanded${{ github.head_ref }}— the PR author's branch name, an attacker-controllablevalue — directly into a
run:shell script, allowing shell-command injection via acrafted branch name. The value is now routed through an environment variable and
referenced quoted, so the shell handles it as data rather than the Actions template
engine splicing it into the script text.
Type of change
Changes
gendoc-docs.yml— in the "Commit the regenerated catalog to this branch" step,bind
github.head_refto aHEAD_REFenvironment variable and change the push togit push origin "HEAD:$HEAD_REF"(wasgit push origin HEAD:${{ github.head_ref }}).ref: ${{ github.head_ref }}on theactions/checkoutstep is anaction input (not shell), so it is not an injection vector and is left unchanged —
consistent with Scorecard flagging only the
run:usage.Testing
dotnet build FirstClassErrors.sln— not run (no application code changed)dotnet test FirstClassErrors.sln— not run (no application code changed)yaml.safe_load) and confirmed nountrusted context remains in any
run:block.tools/commit-lint/lint-commit-message.sh --ci.Documentation
Architecture decisions
Related issues
None — addresses an OSSF Scorecard code-scanning alert; no tracking issue exists.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Kwid3AAwhHZQzCEGSoYdPY
Generated by Claude Code