Kiro tries to run commands prefaced with commands that complicate trusted commands and kill the environment variables
Before opening, please confirm:
- [x] I have searched for duplicate or closed issues
Operating System
win32
Kiro Version
0.10.78
Bug Description
Kiro tries to run commands prefaced with unnecessary prefix commands like pwsh , powershell , & , . . These unnecessary prefixes cause trusted commands to be basically useless and they also invalidate environment variables that have been set up, such as AWS_PROFILE. I've created steering documents, hooks , and MCP servers to try to get Kiro to just execute commands in the same terminal without opening new terminals, and to stop prefixing commands with useless and unnecessary prefixes. The result is that Kiro wastes credits and requirese unnecessarily complex steering.
Here's the hook text:
{
"enabled": true,
"name": "Enforce PowerShell Execution Rules",
"description": "Blocks forbidden command patterns and enforces single terminal reuse.",
"version": "1",
"when": {
"type": "preToolUse",
"toolTypes": [
"shell"
]
},
"then": {
"type": "askAgent",
"prompt": "BLOCK if command starts with: powershell, pwsh, '& .', '. .', or contains ';'. BLOCK if controlPwshProcess action=start and a terminal already exists (check listProcesses first). Otherwise ALLOW and proceed immediately without comment."
}
}
I'd like for Kiro to just do this and not require the hook.
Steps to Reproduce
Get Kiro to start executing commands in the terminal window.
It will alternately try to run commands like pwsh pwd instead of just running pwd. When it runs into an error because pwsh isn't a valid command in the Kiro terminal, it then tries to run powershell pwd. If you steer it to avoid the wasted effort of running pwsh * and powershell * then it starts running commands with an & prefix or a . prefix. All of these do the same thing. They reset the environment. If I've just established AWS credentials by pasting environment parameters with my AWS credentials and Kiro turns around and invalidates the environment, that's not helpful.
Expected Behavior
I want Kiro to open a terminal and stick to it without opening new terminals out of whim.
I want Kiro to avoid unnecessarily prefixing commands with pwsh, powershell, & , . , or in code blocks just because it's a novel way of running commands.
I want Kiro to separate commands onto separate executable lines so Trusted Commands works instead of using ; to string multiple commands together in one line.
Conversation ID
893d7d94-8ecd-4827-8243-e3fad008f506 893d7d94-8ecd-4827-8243-e3fad008f506 893d7d94-8ecd-4827-8243-e3fad008f506 893d7d94-8ecd-4827-8243-e3fad008f506 893d7d94-8ecd-4827-8243-e3fad008f506
Additional Context
No response
🤖 Potential Duplicate Detected
This issue appears to be similar to:
- #6130: Kiro can get around untrusted command by chaining commands, if it starts with a trusted command (85% similar)
- #5536: Kiro does not wait for command completion (85% similar)
- #5376: Bug Report: execute_bash Tool Blocking All Commands (85% similar)
- #4969: executePwsh command forces Powershell syntax (85% similar)
- #4909: When a large command is executed in the bash terminal, Kiro never receives the results (85% similar)
- #4743: Trusted Commands is not working. (85% similar)
- #4694: Using WSL2 Terminals but Kiro is confused and has executePwsh errors all the time (85% similar)
- #4321: Kiro doesn't respect the current terminal shell (85% similar)
What happens next?
- ⏰ This issue will be automatically closed in 3 days
- 🏷️ If this is not a duplicate, you can prevent automatic closure by adding a comment or reacting with 👎 to this message.
- 💬 Comment on the original issue if you have additional information
Why is this marked as duplicate? Both issues deal with Kiro's command execution behavior bypassing trusted command restrictions - the new issue describes unwanted command prefixes that invalidate environment variables, while #6130 describes command chaining that gets around untrusted command restrictions. Both are fundamentally about Kiro's problematic command execution patterns that subvert intended security/control mechanisms.
While this reports certain issues that are indeed covered in other reports, it also reports issues that are not covered by any of the reports listed.
Specifically, this bug report calls out the use of pwsh *, powershell *, & * . *, and { * } syntax by Kiro when executing in a Powershell terminal. This is not called out in any of the listed bug reports and it does impact Trusted Commands directly by using different syntax to submit the same command.
Thank you for your feedback! 🙏
The duplicate label has been removed and this issue has been sent back for maintainer review.
A maintainer will review this issue shortly.
I have been mostly able to address this issue with a hook, but using a hook for this purpose wastes credits.
{
"enabled": true,
"name": "Enforce PowerShell Execution Rules",
"description": "Blocks forbidden command patterns and enforces single terminal reuse.",
"version": "1",
"when": {
"type": "preToolUse",
"toolTypes": [
"shell"
]
},
"then": {
"type": "askAgent",
"prompt": "BLOCK if command starts with: powershell, pwsh, '& .', '. .', or contains ';'. BLOCK if controlPwshProcess action=start and a terminal already exists (check listProcesses first). Otherwise ALLOW and proceed immediately without comment."
}
Hi @webbd-jabil — thanks for reporting this. Kiro has had significant updates since version 0.10.78, including major changes to terminal/command execution in 1.0.0.
Could you check if the unnecessary pwsh/powershell prefix issue still occurs on the latest version? If so, please reply with:
- Your current Kiro version
- Steps to reproduce
- A Conversation ID
If we don't hear back within 7 days, we'll close this as resolved. Thanks! 🙏
This issue has substantially changed in the new Kiro version V1.0.0. Instead of trying to chain commands using ";", input "& ", ". ", etc. in front of commands to destroy the environment context, etc. Now Kiro seems to just ignore my trusted commands and asks for approval or blocks without requesting approval even for trusted commands. I'm unable to set Kiro on a task and expect it to work until complete due to this.
Closing this issue as it was reported against an older version of Kiro (v0.x or early v1.x) and has had no activity in several months.
Kiro has shipped significant improvements since these versions, including stability fixes, new features, and major changes across v1.0, v1.1, v2.x, and the current v2.23.x releases. The behavior described here may already be resolved.
If this is still affecting you on the latest version, please open a new issue at https://github.com/kirodotdev/Kiro/issues/new with your current version (kiro-cli --version or Help > About in the IDE), your OS, and steps to reproduce. The latest version is available at https://kiro.dev/downloads/ or via kiro-cli update.
Thank you for taking the time to report this.