Repository navigation
fix(action): pass runtime inputs as data, never as script text - #1643
Merged
Merged
Conversation
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.
Contributor
|
Warning Review limit reachedEnable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
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. View limit details
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Defect
#1546 (P1, sweep-verified): the
Set output pathsstep (action.yml:809-824at mainc6bc743b) expanded${{ inputs.out }}directly into the Bash program text and appended rawecho name=valuelines 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
outwrote 11 records;out=/tmp/forged\n<LF>gate-outcome-path=/tmp/forgedexited 0 and wrote 22 records with attacker-controlled duplicategate-outcome-pathvalues, matching the issue's reported control (11 vs 22 records).Fix
action.yml— the step now transportsinputs.outas data throughenv: UB_REVIEW_OUT_DIRand the run block contains no${{ }}expansion at all; each declared key is emitted viaprintf '%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#839fail-closed contract step are unchanged (documented outputs indocs/ACTION_REFERENCE.mdpreserved 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 anoutput_paths_step()extractor mirroringrunner_shell(). Every test also asserts the structural contract: the env mapping is exactlyUB_REVIEW_OUT_DIR: ${{ inputs.out }}and the run script contains no${{and noinputs.out.Validation (exact commands and results)
$(), 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 hostsubprocess.run(["bash", ...])resolvesC:\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.ROOTpointed at this worktree, only the bash path patched): 4/4 new tests pass,test_path_mode_does_not_buildand 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 carriesenv: {UB_REVIEW_OUT_DIR: '${{ inputs.out }}'}and a run block with zero{{ }}expressions.Known gaps
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.actionlintis not installed locally and is not a gate step; not run.Set output pathsstep. The issue's broader inventory (otherrun:blocks that still interpolateinputs.outinto argv text ataction.yml:754, 796-798, 805-806) remains open under fix(action): preserve runtime inputs as data through Bash and output-file parsing #1546.Fixes #1546