Skip to content
This repository was archived by the owner on May 15, 2026. It is now read-only.
This repository was archived by the owner on May 15, 2026. It is now read-only.

[ENHANCEMENT] Provide auto-execute for EXACT commands (prefix is inherently unsafe) #11095

Open

Description

@nh2

Problem (one or two sentences)

Provide a way to make auto-execute approvals require exact matches of the commands.

With the current way (command prefix) thi auto-execute feature is very unsafe.

For example, if you have approved git show, Roocode also permits

git show > ~/.ssh/my_id_rsa

thus easily wiping your SSH private key.

This could be easily prompt-injected. For example, a website the user tells the model to read (whose contents are under somebody else's control), could prompt-inject Roocode to compel the model to run the above.

Beyond just destroying files like in my example, it can also lead to easy prompt-injected code execution, because it could > .git/hooks/pre-commit to write to a file that gets executed automatically, such as a git pre-commit hook.

So it is already very unsafe to use any benign command like git show with prefix approval, because shell redirection can destroy any file, including outside of the vscode workspace.

So auto-execution things like git or other benign commands is impossible for security-conscious users.

Thus the request: Make it possible to allow exact comands.

Allowing git show exactly means allowing only exactly those characters, e.g. git show > or git show would not be permitted.

This could be implemented as a bool flag "require exact match" (or better, an explicit "allow prefix match") stored along with each entry in the list of allowed commands. Alternatively (and probably better, because easier to search through), there'd be 2 lists: Allowed Auto-Execute Commands (exact) and Allowed Auto-Execute Commands (prefix). The description text under Allowed Auto-Execute Commands (prefix) should also explain that prefixes are not as safe as exact matches due to the above issue, giving e.g. git show > ~/.ssh/my_id_rsa as an example of caution.

In the Running ... Auto-approved commands GUI in the prompt window where the user can retrospectively click the buttons use Add to allowed list or Add to denied list, the single Add to allowed list button would be replaced with two buttons Add to allowed list (exact) and Add to allowed list (prefix).

This would be especially useful because that way one can without fear add commands such as ./run_my_tests.sh to the exact-match list.

Better, but slightly more complicated way to do this

Limiting to fixed commands might be too rigid, because it allows e.g. git show but not git show 123123ef.

The real problem so far with the prefix commands is that they allow arbitrary shell stuff at the end.

This problem could be avoided by not using the shell, but controlling what arguments get passed into execv().

So I think as the best solution (and replacement of the "exact" commands approach above, because it includes that) would be this list of auto-execute rules: "Allowed Auto-Execute Commands (with args)". These would not be allowed to be run as shell scripts, but instead as execv() calls.

For each rule entry, it would be stored as a JSON object; here some examples:

{
  "argv_matcher": ["git","show", { "tag": "1-argument" }]
}

The above would allow invoking ["git","show", ...] with exactly 1 additional positional argument.

{
  "argv_matcher": ["git","show", { "tag": "0-or-more-arguments" }]
}

The above would allow invoking ["git","show", ...] with 0 or more arbitrary additional positional arguments.

{
  "argv_matcher": ["git","show", { "tag": "optional", "value": "--short" } , { "tag": "0-or-more-arguments" }]
}

The above would allow git show abc123, git show --short abc123, and so on.

{
  "argv_matcher": ["git","show", { "tag": "optional", "value": ["--format", { "tag": "one-of": "value": ["short", "pretty"] } ] } , { "tag": "0-or-more-arguments" }]
}

The above would allow git show abc123, git show --format short abc123, git show --format pretty abc123, and so on.

So the representation would be a JSON-serialised grammar of what's allowed.

Optionally, for the user, we could also make up a language to make this shorter to read or write, such as git show (--format=(short|pretty))? **, but maybe that is not necessary and the user could read the JSON directly for the beginning.

Since producing suggestions to add to the allow-list isn't as easy as with command prefixes or exact command maches (simple yes/no answer for a string so far), and it would be a more complicated suggestion such as "do you want to allow to add { "tag": "optional", "value": ["--format", { "tag": "one-of": "value": ["short", "pretty"] } ] } to the existing git show rule?", we would then let the LLM itself suggest such modifications to the rules, which the user can then approve (checkmark) or reject (cross).

This would allow users to build exactly approved commands that they can run safely.

It would also unlock for the user another way to do things: To allow a single command ./my-command-checker ** as the only approved command, where they can write that program ./my-command-checker themselves in an arbitrary language, that checks the commands given and executes them. This is a bit like an MCP server but much easier, because the user does not have to build a full MCP server including protocol and so on.

Context (who is affected and when)

Any user who wants some bening commands to be executed automatically.

Desired behavior (conceptual, not technical)

Add more restricted ways to auto-approve command exeuction.

Constraints / preferences (optional)

No response

Request checklist

  • I've searched existing Issues and Discussions for duplicates
  • This describes a specific problem with clear context and impact

Roo Code Task Links (optional)

No response

Acceptance criteria (optional)

No response

Proposed approach (optional)

No response

Trade-offs / risks (optional)

No response

Activity

  1. nh2 commented on Jan 30, 2026

    @nh2
    Author

    @roomote I approve this plan, but I think exact commands should not be "case-insensitive, trimmed", but "case-sensitive, not trimmed", to make them truly exact. For example, git and giT can be different programs on Linux.

  2. robertjmcintyre commented on Feb 1, 2026

    @robertjmcintyre
    Contributor

    I came across this issue (in a benign manner) today as well, and it is concerning. The model being able (via Roo) to redirect output of auto-approve commands into sensitive files risks possible system issues.

    Would performing validation on the output/target path be sufficient, do you think, @nh2? There's already that ability for file reads. While not a long-term implementation of your feature suggestion, it might be a useful mitigation.

  3. nh2 commented on Feb 7, 2026

    @nh2
    Author

    Would performing validation on the output/target path be sufficient? There's already that ability for file reads.

    @robertjmcintyre What exactly are you suggesting? That Roocode analyses the string that's in the > outputpath part (that sounds like hacky shell script parsing to me, probably unreliable), or that Roocode provides a direct API for the LLM to write to files, in the same way as it has an API for reasing files?

    The latter sounds like a great idea to me. Then Roocode could also ensure constraints such as "the file must be within the VSCode workspace" or similar.

    Note that this would be a bit of a different feature request than what I'm asking though: I'm asking for restrictions on auto-execution, while you're asking for a controlled/sandboxed way to write files via pipes from commands.

    I think implementing this issue would be a requirement for what you want to be safe.

    Example

    For example, consider that we want Roocode to run git log and pipe it into log.txt.

    Right now Roocode would do that with git log > log.txt -- very insecure and uncontrollable.

    Instead, the LLM could tell Roocode to use a new tool such as run_command_redirect_output(["git", "log"], target_root=constants.WORKSPACE, output_path="log.txt"), so that Roocode can exactly inspect where the output shall go, and deny based on user settings.

    One can then use a very restricted set of commands (what this issue is about) to execute, because the commands no longer need to be able to write to files with >, but instead just stdout/stderr, or perhaps some temp files or FIFOs that Roocode passes in as placeholders (for commands that cannot interact with stdout/stderr but only files, similar to shell <(...)/`>(...) substitution).

    (Note a key difference to Roocode's normal Write tool is that that one seems to write text that is LLM output, while such a run_command_redirect_output() would not process LLM output, but output of other programs, that can be e.g. 10 GB which cannot sensibly be pushed through the LLM.)

    Another, separate idea is that Roocode could use a tool like pledge that can reliably restrict what the commands can do, e.g. if they can connect to the Internet or which files they can read or write (e.g. contained to a specific folder).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    EnhancementNew feature or request

    Type

    No type

    Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions