Offline educational model of CVE-2026-26189 (trivy-action envfile source injection)
Offline model of CVE-2026-26189 (GHSA-9p44-j4g5-cfx5): the composite
action aquasecurity/trivy-action wrote each input as
export NAME=<input> into trivy_envs.txt with echo and no shell
quoting, and entrypoint.sh then ran source ./trivy_envs.txt, so shell
syntax inside an input was read by bash. The sink came with 7aca5acc9500;
the fix, bc61dc55704e (trivy-action 0.34.0), writes the line with
printf 'export %s=%q\n'. Educational, deterministic, C11 checked with
ASan/UBSan. No action, workflow, runner or Trivy is run; no
trivy_envs.txt is written and nothing is sourced or evaluated. The model
builds the line as a string and a static reader says what bash would do
with it.
Spanish: README.es.md. Exercises: PRACTICE.md.
| Diff line | Code | Model |
|---|---|---|
7aca5acc9500 action.yaml ctx 151/159 | shell: bash for "Set Trivy environment variables" | the writer is bash (echo without -e) |
| bc61dc55704e old 186 / new 186 | [ ! -z "$input_value" ] -> [ -n "$input_value" ], != "$default_value" | NOT_WRITTEN (same answer before and after) |
| 7aca5acc9500 new 184 = bc61dc55704e old 188 | echo "export $var_name=$input_value" >> trivy_envs.txt | pre line |
| bc61dc55704e new 189 | printf 'export %s=%q\n' "$var_name" "$input_value" >> trivy_envs.txt | post line, src/bash_q.c |
7aca5acc9500 entrypoint.sh new 8-9 | if [ -f ./trivy_envs.txt ]; then source ./trivy_envs.txt | src/bread.c reads the line |
The GHSA names the same call sites (action.yaml:188, entrypoint.sh:9).
How each action input reaches $2 of set_env_var_if_provided, and which
inputs and defaults exist, is not in the diffs; the variable names in
the fixtures come from test/test.bats in 7aca5acc9500 (new 158-161) and
the defaults are synthetic.
Labels, in priority order: NOT_WRITTEN, BAD_INPUT, SYNTAX_ERROR,
CMD_SUBST, CONTROL_OP (; & | ( ) or a further line), REDIRECT,
EXPANSION ($name, ${..}, $[..]), TILDE, BRACE, WORD_SPLIT,
VALUE_CHANGED (one word, but not the input), LITERAL.
results/)| Input | pre | post |
|---|---|---|
trivy-$(id).sarif (the GHSA's PR-title pattern), trivy-`id`.sarif | CMD_SUBST | LITERAL |
a;id, a\nid, a|id, a&&id | CONTROL_OP | LITERAL |
a>f, a<f | REDIRECT | LITERAL |
$HOME, x${PATH}, $[1] | EXPANSION | LITERAL |
~, a:~/x / {a,b}, x{1..3} | TILDE / BRACE | LITERAL |
a b, a\tb / a 'b, ' / "a", a\b, a #c | WORD_SPLIT / SYNTAX_ERROR / VALUE_CHANGED | LITERAL |
image.sarif, CRITICAL,HIGH, knqyf263/vuln-image:1.2.3, a=~, a* | LITERAL | LITERAL |
| empty, or equal to the default | NOT_WRITTEN | NOT_WRITTEN |
results/sweep.csv tries every byte 0x01-0x7f alone and between a and
b: before the fix 15 bytes leave LITERAL in each position; after it,
none do and the dequoted value always equals the input. In the tests every
1- and 2-byte ASCII value, every 3-byte value over a 40-symbol special
alphabet and 60,000 generated values give LITERAL after the fix.
src/bash_q.c restates what the local GNU bash 5.2.37 prints for
printf %q, ASCII only: '' for empty; if any byte is a control byte the
whole value becomes $'...' (\a \b \t \n \v \f \r \E, \\, \', other
control bytes as three-digit octal); otherwise a backslash before
space ! " $ & ' ( ) * , ; < > ? [ \ ] ^ ` { | }, before ~ at the
start or after = or :, and before # at the start.
scripts/crosscheck_bash.sh (local, not in CI) compares the C and Python
versions with that bash on 4,051 inputs (0 differences) by passing the
value only as an argument to printf %q, and runs bash -n (parse only)
on the lines.
sh scripts/build.sh test # -Wall -Wextra -Werror, ASan + UBSan
python3 scripts/derive_expected.py | diff - fixtures/expected.tsv
sh scripts/build.sh results /tmp/r && diff -r results /tmp/r
./build/trvenv case pre TRIVY_OUTPUT 'a;id' # prints the line; runs nothing
python3 scripts/crosscheck_labels.py build/trvenv # C vs Python, 4,051 inputs
fixtures/cases.tsv holds positive, negative, edge and out-of-domain cases
with labels derived by hand. fixtures/expected.tsv comes from
scripts/derive_expected.py, a separate Python implementation of %q and
of the reader; the C tests compare against both.
A model is not a finding: see LIMITATIONS.md and SOURCES.md. License: Apache-2.0.