Files
ECC/scripts
Nguyen Thanh Dat 788bb6a8ff fix(gateguard): resume the option scan past a value, and stop capping expansion
Two review findings, both reproduced against the built hook first.

The `-c` scan gave up when it met an option that takes a value. But such an
option consumes exactly one value and the scan should continue after it —
`sh -o errexit -c '<cmd>'` and `bash --init-file /dev/null -c '<cmd>'` both
run the payload, and both were denied before this branch and allowed after
it. That is a regression I introduced with the cluster reader, and the shape
of the mistake was reading "this option takes a value" as "there is nothing
further to find". Only a `c` sharing a token with that value is excluded
(`sh -oc`, which the shell rejects outright). Long options that take a value
are skipped for the same reason.

`env -S` expansion stopped after a fixed number of layers and then fell
through to the branch that treats the split string as an opaque option value
— putting the command back behind the option, which is the bypass the
expansion exists to close. The verdict flipped at exactly the cap: with
`env -Senv ... -S "rm -rf /important/data"`, seven layers denied and eight
allowed, and `-Senv` is env's attached split-string form, so that command is
valid and runs.

Raising the number would only move the edge. Each expansion replaces the
option with the words of a string that is a strict substring of it, so the
remaining character count decreases every time and the walk terminates on
its own; bounding the loop by that count keeps the guarantee while making
the bound unreachable. A thousand nested layers classify in 11ms.

Suite 221 -> 230.
2026-08-25 20:46:50 +07:00
..