Some values in a workflow come from strangers. A pull request title, an issue comment, a branch name. If you put them straight into a run script, a stranger can write shell commands that your workflow runs.
This step puts the pull request title directly into the run script, with the double braces. GitHub replaces the expression before the shell runs. So the title becomes part of the script itself.
.github/workflows/pr.ymlyaml
name: PR checkon: pull_requestjobs: check: runs-on: ubuntu-latest steps: - name: Show the title run: echo "Checking ${{ github.event.pull_request.title }}"
Cat shows the attacker's pull request title. It closes the quote, and adds commands. Our helper sets this as the title, and the workflow runs the commands. Who am I prints the user, so the attacker's code really ran. In a real workflow, it could read secrets, or push code.
Terminal
cat title.txtFix typo"; whoami; echo "I ran a commandrun-steps .github/workflows/pr.yml --event pull_request --set "github.event.pull_request.title=$(cat title.txt)" | grep -vE '^Workflow|Job' ✓ Show the title Checking Fix typo root I ran a command
The safe way passes the title through an environment variable. The shell reads it as plain text, and never runs it. Same evil title, and now it's just printed. Use this pattern for any value a stranger can control.
Terminal
cat .github/workflows/pr.yml | tail -3 env: TITLE: ${{ github.event.pull_request.title }} run: echo "Checking $TITLE"run-steps .github/workflows/pr.yml --event pull_request --set "github.event.pull_request.title=$(cat title.txt)" | grep -vE '^Workflow|Job' ✓ Show the title Checking Fix typo"; whoami; echo "I ran a command