Skip to content

fix(action): pass runtime inputs as data, never as script text - #1643

Merged
EffortlessSteven merged 1 commit into
mainfrom
fix/1546-action-input-data-not-text
Nov 4, 2026
Merged

EffortlessSteven merged 1 commit into
mainfrom
fix/1546-action-input-data-not-text

Conversation

@EffortlessSteven

Copy link
Copy Markdown
Member

Defect

#1546 (P1, sweep-verified): the Set output paths step (action.yml:809-824 at main c6bc743b) expanded ${{ inputs.out }} directly into the Bash program text and appended raw echo name=value lines to $GITHUB_OUTPUT. Quoting does not stop shell syntax inside the value from becoming program text, and the line-oriented file-command protocol let an LF-containing path input add records, duplicate a declared output key, or emit bare lines that the runner parser rejects (Bash success, hosted-step failure).

Reproduced against the origin/main step script before this change: an ordinary out wrote 11 records; out = /tmp/forged\n<LF>gate-outcome-path=/tmp/forged exited 0 and wrote 22 records with attacker-controlled duplicate gate-outcome-path values, matching the issue's reported control (11 vs 22 records).

Fix

  • action.yml — the step now transports inputs.out as data through env: UB_REVIEW_OUT_DIR and the run block contains no ${{ }} expansion at all; each declared key is emitted via printf '%s\n' "key=$(printf '%s' "$value" | tr -d '\r\n')" so CR/LF in the value cannot forge records or bare lines. Output names, path suffixes, step id, and the adjacent #839 fail-closed contract step are unchanged (documented outputs in docs/ACTION_REFERENCE.md preserved verbatim).
  • scripts/test-action-bootstrap.py — four named regressions (test_output_paths_pin_documented_single_line_records, test_output_path_input_shell_text_stays_inert_data, test_output_path_input_cannot_forge_records_with_lf, test_output_path_input_cannot_emit_bare_lines_with_crlf) plus an output_paths_step() extractor mirroring runner_shell(). Every test also asserts the structural contract: the env mapping is exactly UB_REVIEW_OUT_DIR: ${{ inputs.out }} and the run script contains no ${{ and no inputs.out.

Validation (exact commands and results)

  • Defect reproduction, pre-fix: extracted the origin/main step script (11 lines) and ran the LF-forging control through Git Bash — 22 records vs 11 ordinary, duplicate declared key with forged value confirmed.
  • Post-fix behavioral controls (fixed script, real bash): ordinary value with a space → exact 11 records; shell-text payload (backticks, $(), quotes, ;, =) → literal data preserved, no sentinel created; LF + duplicate declared key → exactly 11 records, exact key set, no forged value; CRLF + bare line → 11 records, every line contains =.
  • python scripts/test-action-bootstrap.py (this Windows host): Ran 23 tests ... FAILED (failures=18, errors=1). Baseline on unmodified origin/main: Ran 19 tests ... FAILED (failures=14, errors=1). The delta is exactly my four new shell-executing tests failing at the same point as the 14 pre-existing ones: on this host subprocess.run(["bash", ...]) resolves C:\Windows\System32\bash.exe (WSL launcher), which cannot execute (Error code: Bash/Service/0x8007007c) — a pre-existing host limitation, not an assertion failure. The structural assertions in the new tests (env mapping, no ${{ in script) pass even in that run.
  • Same assertions with Git Bash resolved (scratch copy of the committed test file, ROOT pointed at this worktree, only the bash path patched): 4/4 new tests pass, test_path_mode_does_not_build and all four structural/text tests pass; the 13-14 fake-cargo/symlink tests fail identically before and after this change (Windows-host shebang/exec artifacts). The committed suite is authoritative on Linux.
  • cargo fmt --all — clean (no Rust files in the diff).
  • cargo clippy --locked --workspace --all-targets — exit 0; 3 warnings, all pre-existing in untouched files (src/proof/red_green.rs:385 — the tolerated one, tests/pr_context_hydration.rs:40, tests/common/executable_fixture.rs:26).
  • python -c "yaml.safe_load(...)" on the edited action.yml — parses; fixed step carries env: {UB_REVIEW_OUT_DIR: '${{ inputs.out }}'} and a run block with zero {{ }} expressions.

Known gaps

  • The committed Python suite (gate step "Verify Action bootstrap contract", ub-review-gate.yml:58-59) could not pass on this Windows host even before the change (see above); its Linux run is validated by the gate, not locally.
  • actionlint is not installed locally and is not a gate step; not run.
  • Scope is bounded per the fixer assignment to the Set output paths step. The issue's broader inventory (other run: blocks that still interpolate inputs.out into argv text at action.yml:754, 796-798, 805-806) remains open under fix(action): preserve runtime inputs as data through Bash and output-file parsing #1546.
  • Emission strips CR/LF (concatenating segments) rather than rejecting the input with a diagnostic; the ask prescribes strip-before-emit. A rejection diagnostic remains available as follow-up.

Fixes #1546

The Set output paths step expanded ${{ inputs.out }} directly into Bash
program text and appended raw 'echo name=value' lines to GITHUB_OUTPUT,
so an action input could inject shell syntax and forge structured
output records that consumer workflows branch on (#1546).

Transport the out input through an env mapping, emit each declared key
through a printf helper that strips CR/LF before writing, and keep the
#839 fail-closed contract step untouched. Output names and path
suffixes are unchanged.
@coderabbitai

coderabbitai Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

  • Ask an admin to enable usage-based reviews

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Next included review available in 22 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 151 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Essentials
  • Run ID: e394195f-9c22-4cda-9cbb-04a719b8852a
Commits

Reviewing files that changed from the base of the PR and between c6bc743 and 0cb00e3.

Files selected for processing: 2
  • action.yml
  • scripts/test-action-bootstrap.py
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@EffortlessSteven
EffortlessSteven merged commit 962e50f into main Nov 4, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(action): preserve runtime inputs as data through Bash and output-file parsing

1 participant