Skip to content

build-release-task.yml and the Publisher Stubs Interpolate the Branch Into a run: Script #1529

Closed

Description

@ptr727

Defect

.github/workflows/build-release-task.yml's release-asset delete step interpolates ${{ inputs.branch }} straight into its run: script, inside the double-quoted --jq filter:

if ! ids=$(gh api "repos/$GITHUB_REPOSITORY/actions/runs/${{ github.run_id }}/artifacts" --paginate \
  --jq ".artifacts[] | select(.name | startswith(\"release-asset-${{ inputs.branch }}-\")) | .id"); then

An expression is substituted into the script text before bash parses it, so a branch carrying shell syntax becomes code rather than data. Git accepts ref names such as a$(id) or one containing a backtick or ", so a branch named that way runs in a job whose environment holds the GitHub token. The documented publisher stubs in docs/reusable-workflows.md, the NuGet and PyPI consume-then-delete steps, use the same shape with ${{ github.ref_name }}.

Constructed example: a branch named x$(touch /tmp/pwned) reaching this step on a non-smoke publish runs touch before gh is invoked.

Why it is not urgent

The step runs only on a non-smoke publish, which someone with write access starts, and they can already edit the workflow, so it crosses no permission boundary. D2.3 also limits a publish to main and develop. It surfaced while reviewing the fix for a related log-line finding on #1526, and is the recognized Actions anti-pattern of an expression inside run: rather than a reachable exploit.

Possible fix

Pass the value through env: and reference it as a shell variable, as the rest of the task already does, for example BRANCH: ${{ inputs.branch }} and startswith(\"release-asset-\" + env.BRANCH + \"-\") or a --arg to jq, in the task and in both documented stubs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions