A test script dropped an environment variable into a command without quotes. Word splitting turns its value into extra arguments, and the right value loads attacker-chosen code during CI.
What goes wrong
A package script built a test command by expanding an environment variable inline, without quotes. The intent was to let someone pick the reporter. The shell does not know that is the intent.
An unquoted expansion is subject to word splitting and glob expansion. Whatever the variable holds gets chopped on whitespace into separate arguments. Set it to a reporter name followed by an option that requires a file, and you have injected an extra flag that tells the test runner to load a script of your choosing. Now arbitrary code runs inside the test process, with that process's access to your source checkout and any secrets the build holds.
CI is a high-value target precisely because it holds credentials and runs semi-trusted input on a schedule. Quote your expansions. Better yet, do not build shell commands out of environment variables at all. Pass arguments as an array to the runner so the shell never gets a vote.
The pattern
# a package script, run through a shell
test-cmd: runner --reporter $RUN_OPTS ./tests
# RUN_OPTS = "spec --require ./evil.js"
# the shell splits it on the space into two arguments,
# so the runner loads evil.js before any test runs# option 1: quote the expansion
test-cmd: runner --reporter "$RUN_OPTS" ./tests
# option 2 (better): skip the shell entirely
spawn("runner",
["--reporter", env.RUN_OPTS, "./tests"],
{ shell: false })Every gate held. The exploit path was reproduced against a negative control, the impact was calibrated, and the finding was signed report-ready.
Why it matters to you
If an attacker can influence that variable through a pull request, a fork's CI config, or a compromised dependency's setup, they run code in your build. Build compromise is how supply-chain attacks start, and it usually rides in on something as dull as an unquoted variable in a script nobody has read in years.
Check your own code
- Grep your scripts for unquoted variable expansions inside commands.
- Quote every expansion, or invoke tools without a shell and pass args as an array.
- Treat CI environment variables as untrusted input, especially on fork and PR builds.