Overview
gh-annotations writes GitHub Actions workflow commands directly to stdout. The current implementation already encodes raw \r and \n bytes, which prevents direct line-break command injection. However, GitHub workflow command parsing has separate escaping rules for command data and command properties.
The file= annotation property currently does not escape %, :, and , according to the workflow command property grammar. Annotation message data also does not escape % before CR/LF encoding.
Expected behavior
Values written into GitHub Actions workflow commands should follow the same split used by actions/toolkit:
- data:
%, \r, \n
- properties:
%, \r, \n, :, ,
Why this matters
Source paths and package metadata can be influenced by scanned repository contents. Applying the full workflow command escaping rules avoids malformed annotations and reduces the chance of command parsing confusion in GitHub Actions logs.
Proposed fix
Add dedicated helpers for workflow command data/property escaping and use them only in the gh-annotations output path:
- property escaping for
file=...
- data escaping for the annotation message and rendered tables
I have a small patch prepared with regression coverage for %, ,, :, and %0A-style sequences.
Overview
gh-annotationswrites GitHub Actions workflow commands directly to stdout. The current implementation already encodes raw\rand\nbytes, which prevents direct line-break command injection. However, GitHub workflow command parsing has separate escaping rules for command data and command properties.The
file=annotation property currently does not escape%,:, and,according to the workflow command property grammar. Annotation message data also does not escape%before CR/LF encoding.Expected behavior
Values written into GitHub Actions workflow commands should follow the same split used by
actions/toolkit:%,\r,\n%,\r,\n,:,,Why this matters
Source paths and package metadata can be influenced by scanned repository contents. Applying the full workflow command escaping rules avoids malformed annotations and reduces the chance of command parsing confusion in GitHub Actions logs.
Proposed fix
Add dedicated helpers for workflow command data/property escaping and use them only in the
gh-annotationsoutput path:file=...I have a small patch prepared with regression coverage for
%,,,:, and%0A-style sequences.