OS Command Injection In gh
Description
GitHub CLI: GitHub Actions log output in gh run view allows terminal escape sequence injection
Summary
A security vulnerability has been identified in GitHub CLI that could allow terminal escape sequence injection when users view GitHub Actions workflow logs using gh run view --log or gh run view --log-failed.
Details
The vulnerability stems from the way GitHub CLI handles raw Actions log output. The gh run view --log and gh run view --log-failed commands stream workflow log lines to stdout or the configured pager without sanitizing terminal control sequences. An attacker who can influence GitHub Actions log content, for example via a PR triggered workflow, can embed escape sequences that are replayed in the user's terminal when they inspect the run.
Depending on the victim's terminal emulator, injected sequences could change the window title, manipulate on screen content, or in some terminal emulators (such as screen) potentially execute arbitrary commands.
In 2.92.0, GitHub CLI sanitizes terminal control sequences in Actions log output before writing to the terminal.
PoC
Create a workflow that emits terminal escape sequences in its log output:
name: Escape Sequence PoC on: workflow_dispatch: jobs: emit-escape-sequences: runs-on: ubuntu-latest...
Then trigger the workflow and view its logs:
gh workflow run 'Escape Sequence PoC' gh run view <run_id> --log
On vulnerable versions, the raw ESC bytes (0x1b) are passed through to the terminal unsanitized. On 2.92.0 and later, escape sequences are stripped and only the safe visible text is displayed.
Impact
An attacker who can control GitHub Actions workflow output can inject terminal escape sequences into a maintainer's terminal session when they inspect the run with gh run view --log or gh run view --log-failed. The practical impact depends on the victim's terminal emulator.
Remediation and Mitigation
Upgrade gh to 2.92.0
Pipe log output through a sanitizer (e.g., gh run view --log | cat -v) as a workaround on older versions
Exercise caution when viewing logs from untrusted workflow runs
Update Impact
Minimal update. May introduce new vulnerabilities or breaking changes.
Ecosystem | Package | Affected version | Patched versions |
|---|---|---|---|
debian 12 | - | ||
debian 13 | - | ||
go | 2.92.0 | ||
go | - |
Aliases
References