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.

@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!

@fg0x0 fg0x0 force-pushed the fix/randomize-heredoc-delimiter branch from 52820a0 to c1c5ea2 Compare June 23, 2026 03:39
@fg0x0

fg0x0 commented Jun 23, 2026

Copy link
Copy Markdown
Author

@googlebot I signed it.

@fg0x0 fg0x0 force-pushed the fix/randomize-heredoc-delimiter branch from 059ed38 to 681e48d Compare June 23, 2026 03:57
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