Skip to content

bash deny rules don't apply through wrappers (time, env, bash -c) on v2 #62513

Closed as duplicate

Description

@Project579

Description

Follow-up to #54008, which was closed as v1-only. On v2 a shell deny rule is matched against the full command text, so any wrapper in front of the command gets past it. Only a bare rm (also inside ; / && chains) is blocked.

With "rm *": "deny", all of these run and delete the file without a prompt:

  • time rm x, command rm x, env rm x, nohup rm x, timeout 5 rm x
  • FOO=1 rm x
  • bash -c 'rm x', sh -c 'rm x'
  • echo x | xargs rm
  • find . -name x -exec rm {} \;

"Allow always" on these saves the wrapper pattern instead (time *, env *, bash *, find *), which then allows any command behind that wrapper.

I reproduced it by running the shell tool directly against the real permission service (no model), on v2.2.5 and current dev with the same result.

Plugins

none

OpenCode version

2.2.5 (also current dev)

Steps to reproduce

  1. Config:
    { "permission": { "shell": { "rm *": "deny" } } }
  2. touch x
  3. Ask the agent to run env rm x (or any form above).
  4. x is deleted. rm x on its own is correctly denied.

Screenshot

No response

Operating System

Linux (Arch, kernel 7.2.14)

Terminal

wezterm

Activity

  1. opencodejr commented on Nov 7, 2026

    @opencodejr
    Contributor

    Thanks for testing this on v2 and for the full list of wrappers.

    I think this is a duplicate of #58775. That issue reports the same thing on v2: shell deny rules are matched against the literal command text, so env …, command …, FOO=1 … or a path-qualified binary gets past the deny. It has been reproduced on dev, and a contributor has proposed a fix there that would also check deny rules against the command with its wrapper removed.

    Possible duplicates and related issues, ordered from most to least likely:

    Some of your cases aren't listed in #58775 yet: time, nohup, timeout, the command inside bash -c / sh -c, xargs, find -exec, and "Allow always" saving the wrapper pattern (time *, bash *, find *). Adding them there would help make sure the fix covers them.

    The bot will close this issue as a duplicate in 1 day unless you reply explaining how your problem is different.

  2. Project579 commented on Nov 7, 2026

    @Project579
    Author

    Duplicate of #58775, closing. I'll add the extra cases there.

  3. opencodejr commented on Nov 7, 2026

    @opencodejr
    Contributor

    Thanks for confirming, and for moving the extra cases (time, nohup, timeout, bash -c, xargs, find -exec, and the "Allow always" wrapper pattern) over to #58775. Having them there should help make sure the fix covers them.

  4. opencodejr commented on Nov 8, 2026

    @opencodejr
    Contributor

    Closing this as a duplicate of #58775, as you suggested. The extra wrapper cases (time, nohup, timeout, bash -c, xargs, find -exec) and the "Allow always" wrapper pattern are best tracked there, alongside the fix being discussed. Thanks again for the thorough report.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions