What happens
_sanitize_workflow_value (in scripts/lib/post-failure-report.lib.sh), the function underlying gha_echo/sanitize_gha_log_output/sanitize_comment_workflow_commands, strips literal :: and percent-encoded %0A/%0a/%0D/%0d sequences, but does not strip ANSI escape sequences (\x1b[...) or other control characters:
_sanitize_workflow_value() {
local value="$1"
value="${value//::/}"
value="${value//%0A/}"
value="${value//%0a/}"
value="${value//%0D/}"
value="${value//%0d/}"
printf '%s' "${value}"
}
This function is the shared sanitization primitive for every gha_echo call across the codebase (post-code.sh, post-fix.sh, post-review.sh, post-retro.sh, pr-assignee.lib.sh, relabel-retrigger.lib.sh, etc.) — any of these that echo externally-sourced text (API error bodies, review content, etc.) through gha_echo inherit this gap.
What should happen
_sanitize_workflow_value (or a variant used specifically where externally-sourced text is involved) should also strip ANSI/CSI escape sequences and other non-printable control characters, consistent with defense-in-depth for GitHub Actions workflow-command log injection.
Context
Flagged during review of #469 (scripts/lib/relabel-retrigger.lib.sh's retrigger_via_label, which passes gh CLI stderr output through gha_echo). Not fixed as part of that PR since the gap is in shared infrastructure used by many other call sites, not something introduced there — a local, one-off fix in a single consumer would leave every other gha_echo caller with the same gap and create inconsistent sanitization behavior across the codebase. In practice, gh CLI disables ANSI color output when stderr isn't a TTY (which is the case for all these redirected-to-file/variable call sites), so the practical exposure is low, but the sanitizer's documented contract (stripping workflow-command-injection vectors) doesn't fully match its implementation.
What happens
_sanitize_workflow_value(inscripts/lib/post-failure-report.lib.sh), the function underlyinggha_echo/sanitize_gha_log_output/sanitize_comment_workflow_commands, strips literal::and percent-encoded%0A/%0a/%0D/%0dsequences, but does not strip ANSI escape sequences (\x1b[...) or other control characters:This function is the shared sanitization primitive for every
gha_echocall across the codebase (post-code.sh,post-fix.sh,post-review.sh,post-retro.sh,pr-assignee.lib.sh,relabel-retrigger.lib.sh, etc.) — any of these that echo externally-sourced text (API error bodies, review content, etc.) throughgha_echoinherit this gap.What should happen
_sanitize_workflow_value(or a variant used specifically where externally-sourced text is involved) should also strip ANSI/CSI escape sequences and other non-printable control characters, consistent with defense-in-depth for GitHub Actions workflow-command log injection.Context
Flagged during review of #469 (
scripts/lib/relabel-retrigger.lib.sh'sretrigger_via_label, which passesghCLI stderr output throughgha_echo). Not fixed as part of that PR since the gap is in shared infrastructure used by many other call sites, not something introduced there — a local, one-off fix in a single consumer would leave every othergha_echocaller with the same gap and create inconsistent sanitization behavior across the codebase. In practice,ghCLI disables ANSI color output when stderr isn't a TTY (which is the case for all these redirected-to-file/variable call sites), so the practical exposure is low, but the sanitizer's documented contract (stripping workflow-command-injection vectors) doesn't fully match its implementation.