fix: quote arguments for passing to auto completion server #20
+9
−3
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.
I realized there was code in the zsh completion generation code that caused vulnerabilities.
tab/src/zsh.ts
Line 61 in d5659d5
Here, the
requestComp
variable contains the words that the user entered on the command line(${words[2,-1]})
.The eval command reinterprets this string as a shell command and executes it.
issue point
If the user enters a string containing shell metacharacters (e.g.
;
,&
,|
,$()
, etc.) as a command line argument, eval will interpret these metacharacters as command delimiters or subcommand execution with special meaning.This may cause unintended arbitrary commands to be executed.
example
Suppose the user types the following (name is mycli, and exec is mycli):
mycli some-command '; rm -rf ~ #'
In this case,
requestComp
would be a string like“mycli complete -- some-command '; rm -rf ~ #”
. If eval executes this, the following commands may be executed in order.As you can see, because the user input is not properly escaped or quoted, there is a risk that arbitrary commands could be injected by using
eval
.tab case may be a rare case, but if it is input in some way, it could cause comm