Skip to content

ci: prevent script injection via github.head_ref in gendoc-docs - #315

Merged
Reefact merged 1 commit into
mainfrom
claude/code-scanning-issues-7xvf3o
Jul 27, 2026
Merged

ci: prevent script injection via github.head_ref in gendoc-docs#315
Reefact merged 1 commit into
mainfrom
claude/code-scanning-issues-7xvf3o

Conversation

@Reefact

@Reefact Reefact commented Jul 27, 2026

Copy link
Copy Markdown
Owner

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-controllable
value — directly into a run: shell script, allowing shell-command injection via a
crafted 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

  • Build / CI / tooling

Changes

  • gendoc-docs.yml — in the "Commit the regenerated catalog to this branch" step,
    bind github.head_ref to a HEAD_REF environment variable and change the push to
    git push origin "HEAD:$HEAD_REF" (was git push origin HEAD:${{ github.head_ref }}).
  • The unrelated ref: ${{ github.head_ref }} on the actions/checkout step is an
    action 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)
  • Analyzer tests — not run (analyzers untouched)
  • Validated the workflow YAML still parses (yaml.safe_load) and confirmed no
    untrusted context remains in any run: block.
  • Verified the commit header against tools/commit-lint/lint-commit-message.sh --ci.

Documentation

  • No documentation change required

Architecture decisions

  • No architectural decision in this pull request

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

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
Reefact enabled auto-merge July 27, 2026 10:42
@Reefact
Reefact merged commit 10fbc0d into main Jul 27, 2026
16 checks passed
@Reefact
Reefact deleted the claude/code-scanning-issues-7xvf3o branch July 27, 2026 10:49
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.

2 participants