Skip to content

fix: randomize heredoc delimiter in GITHUB_OUTPUT writes#527

Open
fg0x0 wants to merge 1 commit into
google-github-actions:mainfrom
fg0x0:fix/randomize-heredoc-delimiter
Open

fix: randomize heredoc delimiter in GITHUB_OUTPUT writes#527
fg0x0 wants to merge 1 commit into
google-github-actions:mainfrom
fg0x0:fix/randomize-heredoc-delimiter

Conversation

@fg0x0

@fg0x0 fg0x0 commented Jun 8, 2026

Copy link
Copy Markdown

Summary

Randomize the heredoc delimiter used when writing gemini_response and gemini_errors to $GITHUB_OUTPUT in action.yml.

The fixed EOF delimiter allows an LLM response containing a bare EOF line to close the heredoc early. Subsequent name=value lines in the response then become arbitrary step outputs, enabling bash injection in downstream consumer workflows.

Changes

  • Replace echo "gemini_response<<EOF" with a random ghdelim_<hex> delimiter
  • Replace echo "gemini_errors<<EOF" with a random ghdelim_<hex> delimiter
  • Uses openssl rand -hex 16 per GitHub's canonical pattern

Testing

# Before fix: EOF in response breaks the heredoc
RESPONSE="line1\nEOF\ninjected=value"
echo "gemini_response<<EOF" >> output.txt
echo "$RESPONSE" >> output.txt
echo "EOF" >> output.txt
# Result: injected=value becomes a step output

# After fix: random delimiter is unguessable
_DELIM="ghdelim_$(openssl rand -hex 16)"
echo "gemini_response<<${_DELIM}" >> output.txt
echo "$RESPONSE" >> output.txt
echo "${_DELIM}" >> output.txt
# Result: entire response captured as gemini_response, no injection

Fixes #526

References

@fg0x0 fg0x0 requested review from a team as code owners June 8, 2026 08:59
@google-cla

google-cla Bot commented Jun 8, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Replace fixed 'EOF' heredoc delimiter with a random per-invocation
delimiter (ghdelim_<random>) when writing gemini_response and
gemini_errors to $GITHUB_OUTPUT.

The fixed 'EOF' delimiter allows an LLM response containing a bare
'EOF' line to close the heredoc early. Subsequent name=value lines
in the response then become arbitrary step outputs, enabling bash
injection in any downstream consumer workflow that interpolates
${{ steps.gemini_run.outputs.X }} into a run: block.

This follows the canonical pattern from GitHub's official docs:
https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#multiline-strings

Fixes the vulnerability described in:
- Google VRP Issue #514026965
- Related to GHSA-62f2-6rx8-v262 (TOML template fix)

Present since v0.1.12 (PR google-github-actions#247, 2025-08-25).
@fg0x0 fg0x0 force-pushed the fix/randomize-heredoc-delimiter branch from 1f02a38 to 52820a0 Compare June 8, 2026 09:06

@kkarrenn kkarrenn left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this change!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Security: fixed EOF heredoc delimiter in action.yml enables step output injection

2 participants