Feature: Detect unquoted shell variable expansions in run: blocks
#1595
Replies: 4 comments
-
|
Hi @ManuelLerchnerQC, thanks for opening an issue. Could you elaborate a bit on the security relevance of an audit here? In my experience unquoted shell variables don't generally result in security problems, although they are a code smell and do sometimes cause reliability problems. Given that, I'm generally inclined to not support this kind of check in zizmor, and instead point people to actionlint for it (IIUC they wrap shellcheck to provide this check). However, if curious to hear arguments for it having more security salience and therefore being a good candidate for zizmor 🙂 |
Beta Was this translation helpful? Give feedback.
-
|
Hi! Joining the discussion as @ManuelLerchnerQC pointed me to it. The biggest risk with unquoted variables is that they allow an attacker to pass multiple arguments to a single command when only one is expected. This Stack Exchange answer provides an example: awk -v foo=$external_input '$2 == foo'If $ external_input='x BEGIN{system("uname")}'
$ awk -v foo=$external_input '$2 == foo'
LinuxSo, unlike The answer above also references other issues that are less critical, IMO, but should still be considered. |
Beta Was this translation helpful? Give feedback.
-
|
Yeah, there's something secondary here: a lot of tools (like Have you all tried actionlint for this purpose? To my understanding a lot of zizmor users combine the two effectively, with zizmor providing security checks and actionlint providing general quality and correctness checks. |
Beta Was this translation helpful? Give feedback.
-
|
We will have a look into
Of course. You could argue, though, that this is much less of an issue because you explicitly opted into passing everything as separate arguments with the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Pre-submission checks
What's the problem this feature will solve?
Unquoted shell variable expansions in GitHub Actions
run:blocks can cause unintended word splitting or glob expansion when variables contain spaces or special characters. This is a well-known class of issues and is flagged by tools such as ShellCheck.Since GitHub context values (e.g. branch names or PR titles) are often user-controlled, unquoted expansions can lead to broken workflows or unsafe command execution.
Currently,
zizmordoes not detect these unquoted variable expansions.Describe the solution you'd like
zizmorshould detect potentially unsafe unquoted shell variable expansions inrun:blocks and flag them as issues.Example of problematic code:
In this example,
$BRANCH_NAMEmay contain spaces or other special characters, causing unexpected behavior when passed unquoted to shell commands.Expected behavior / Suggested fix
zizmorshould flag unquoted variable expansions used as shell command arguments and suggest proper quoting (potentially as an unsafe fix, since such usage may also be intentional).For example, a suggested fix could look like this:
Additional context
There is an existing issue around incorrect quoting in auto-fixes (e.g., single-quoting variable expansions) at #1346, but this request focuses on detecting missing quoting rather than on how fixes are applied.
Whether and how an autofix is offered is a separate concern, I think.
Beta Was this translation helpful? Give feedback.
All reactions