Trusted Commands don't work when piped
Before opening, please confirm:
- [x] I have searched for duplicate or closed issues
Operating System
darwin
Kiro Version
0.1.9
Bug Description
Adding all the commands used in a pipe to the Trusted Commands list doesn't allow Kiro to run the commands automatically. It will still prompt to "Trust/Run" the command with pipes.
Additionally, it should also recommend adding, in this case:
grep *head *
To the Trusted Commands list too.
Steps to Reproduce
- Add
npx eslint *,grep *andhead *to the trusted commands list. - Prompt Kiro to look for linting errors in a Typescript file
- A prompt will show asking the user to "Cancel/Trust/Run"
Expected Behavior
Kiro should have trusted the commands even though they were used in a pipe.
Conversation ID
77cb5adb-3365-44bd-8bf4-1c11e58720c5
Additional Context
No response
Running into the same issue as well..hope they fix it soon
Hey @jenyangk, thank you for reaching out. We are currently actively tracking this on https://github.com/kirodotdev/Kiro/issues/22.
Hi @jenyangk , reopening this issue – thanks for bringing this up. Piped commands are expected to be handled so long as every command in them has been trusted. However, pipe characters within commands, such as the one in grep -B1 -A1 "no-unused-vars\|@typescript-eslint/no-unused-vars" will require the command to be verified.
We will also take into consideration the suggestion to have the option to trust the various parts of a piped command.
Thanks for the clarification! @jordanvn
Hi @jenyangk , reopening this issue – thanks for bringing this up. Piped commands are expected to be handled so long as every command in them has been trusted. However, pipe characters within commands, such as the one in
grep -B1 -A1 "no-unused-vars\|@typescript-eslint/no-unused-vars"will require the command to be verified.We will also take into consideration the suggestion to have the option to trust the various parts of a piped command.
That is not what your documentation says, but it is certainly the behavior I would want to see.
https://kiro.dev/docs/chat/terminal/#full-wildcard-matching--complex-commands states:
"The trust system only checks the beginning of the command string - if it matches, the entire command is trusted, including any chained commands, pipes, or redirects that follow."
That suggests that trusting grep * would also allow for grep foo ./bar.txt && rm -Rf /. Given the tendency of your agent to get creative when terminal commands don't work as expected, I could see it intentionally jailbreaking like this, which means any wildcarded command would become a huge risk.
Can you confirm that the documentation is incorrect and that every command in a chain must be on the approved list?
I can confirm that the documentation is correct, anything after a star is implicitly trusted.
On a fresh install and profile of Kiro, I trusted uv run * and nothing else. Commands like uv run pytest | tail -n 10 work without prompting.
Later, when the agent wanted to run tail -n 10, it came back to ask for permission.
This limitation, even if documented, makes the entire "command trust" system borderline useless. Adding a star to anything makes it possible for anything at all to come after. The alternative is to add a trust rule for every command and argument permutation which is just no feasible.
There seems to be a security risk in allowing "*" to run anything (including pipes) as @tejaycar has mentioned. I would expect that * indicates evaluating everything up to a pipe or another operator (&& or ||, etc). This would allow discrete chaining of trusted commands and provide confidence that the agent cannot just suddenly run something like grep foo ./bar.txt && rm -Rf / if grep * is a trusted command.
So, if Kiro encounters a command like uv run * and nothing else, a command like uv run pytest | tail -n 10 would prompt the user. However, if the tail * command is likewise trusted, the uv run pytest | tail -n 10 command would run just fine without prompt.
I agree that all commands' trust in piped scenarios should be evaluated separately.
I often see Kiro start commands with cd like: cd /my/project/folder && do-the-stuff command. The trust option suggests trusting the cd *, which basically makes everything allowed (globally), which is very dangerous and not desired.