Skip to content

fix(opencode): enforce read-only bash permissions in plan mode#24110

Open
kzekiue wants to merge 2 commits intoanomalyco:devfrom
kzekiue:issue-24102-plan-mode-bash-allowlist
Open

fix(opencode): enforce read-only bash permissions in plan mode#24110
kzekiue wants to merge 2 commits intoanomalyco:devfrom
kzekiue:issue-24102-plan-mode-bash-allowlist

Conversation

@kzekiue
Copy link
Copy Markdown

@kzekiue kzekiue commented Apr 24, 2026

Issue for this PR

Closes #24102

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Plan mode could still run mutating bash commands because it inherited the default broad tool permissions and only denied edit tools.

This PR makes the native plan agent enforce bash as read-only by default. It denies bash commands unless they match a small allowlist of inspection commands such as git status, git log, git diff, git show, git branch, git stash list, ls, cat, grep, rg, find, wc, head, and tail.

It also adds Agent.permissions(...) so plan-mode rules remain authoritative when session-level permissions are merged in. That prevents session/config permissions from re-allowing mutating commands in plan mode while preserving the existing merge behavior for other agents.

How did you verify your code works?

  • bun test test/agent/agent.test.ts
  • bun typecheck
  • bun test test/session/llm.test.ts test/session/prompt.test.ts

The session tests were run outside the sandbox because their local HTTP test servers could not bind ephemeral ports inside it.

Screenshots / recordings

Not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions
Copy link
Copy Markdown
Contributor

Hey! Your PR title Enforce read-only bash permissions in plan mode doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

@github-actions
Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Based on my search results, I found a related PR that may be relevant:

Related PR:

The other results are related to permissions and bash command handling but appear to be either older historical changes or addressing different aspects (like sandboxing, auto-approval, and subagent restrictions).

The most relevant connection is with PR #23985, which is also addressing plan mode tool permissions, though it focuses on allowing specific CLI tools rather than restricting bash commands.

@kzekiue kzekiue changed the title Enforce read-only bash permissions in plan mode fix(opencode): enforce read-only bash permissions in plan mode Apr 24, 2026
@kzekiue kzekiue mentioned this pull request Apr 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[plan mode] LLM executes dangerous git commands (rebase, reset --hard, force-push) without permission

1 participant