Skip to content

[FEATURE]: Better execution permissions and sandboxing #48411

Open

Description

@xiesl97

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

OpenCode's current execution controls could be improved in three areas:

1. Make permission mode easier to access

The current permission settings are relatively hidden.

It would be useful to show the active permission mode directly in the conversation UI and allow quick switching during a session.

2. Add sandboxed execution

OpenCode has permission controls such as allow, ask, and deny, but lacks a built-in sandbox comparable to a restricted execution environment.

A sandbox could limit filesystem, network, and process access even when an action is approved.

3. Add optional model-assisted approval

For ask mode, an optional reviewer model could evaluate requested actions and decide whether to:

  • auto-approve
  • ask the user
  • deny

Ideally, the reviewer model could be configured separately from the main agent, so a small and inexpensive model can handle approval checks.

These three features would make OpenCode safer and more convenient for autonomous execution.

Activity

  1. github-actions commented on Sep 11, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

  2. andrewarrow commented on Oct 8, 2026

    @andrewarrow

    #53943 made this draft PR here is blog article about it https://mainbrella.com/blog/opencode-one-workspace/

  3. opencodejr commented on Oct 28, 2026

    @opencodejr
    Contributor

    Thanks for the detailed suggestions, @xiesl97! To sum up, you're asking for three things: show the active permission mode in the conversation and let you switch it quickly; a built-in sandbox that limits filesystem, network and process access even for approved actions; and an optional, separately configured reviewer model that can auto-approve, ask or deny requests in ask mode.

    On the third one: the v2 plugin API has a permission.evaluate hook that lets a plugin change a permission request's effect (allow / ask / deny) and attach a message. That could be a starting point for a reviewer-model plugin in the meantime.

    The maintainers will consider these. I couldn't search for existing issues just now, so this may be linked to related requests later.

  4. benjaminfrombe commented on Nov 15, 2026

    @benjaminfrombe

    Part 2 of this request is the main reason my team cannot move off Codex: without OS-level sandboxing we cannot give an agent unattended write access with any confidence, which is exactly what Codex's workspace-write + restricted network mode buys us today.

    There are now two implementation attempts on the table:

    • feat(core): add opt-in OS-level shell sandbox #63599 hand-rolls bubblewrap and Seatbelt profiles. No Windows backend, and the macOS profile is only string-tested.
    • feat(core): sandbox agent shell commands with MXC #64093 (draft) builds the feature on Microsoft MXC instead: one engine for all three platforms (Seatbelt, bubblewrap, ProcessContainer), fail-closed when the backend cannot enforce the policy, and a separate shell_unsandboxed permission so approving a sandboxed command never approves escaping it. It is verified against real backends on macOS, Linux (Debian 13 + bwrap 0.12) and Windows 11, including the platform gaps that are documented in the PR.

    The design question for maintainers, before either attempt is worth polishing further: is opencode open to taking @microsoft/mxc-sdk as a dependency at all? It is the only maintained engine covering all three desktop platforms, but it currently costs about 118 MB unpacked per install (per-platform packages are being requested upstream: microsoft/mxc#1781), and MXC release builds on Windows emit required Microsoft diagnostic telemetry. If that trade-off is acceptable, #64093 is ready for design review. If it is not, the hand-rolled route of #63599 is the fallback and it would help to know which direction you prefer.

    One more upstream limitation worth knowing during the review: MXC's process streams do not deliver under Bun yet (microsoft/mxc#1782), so sandboxed commands return captured output rather than streaming, which is also listed in the PR.

  5. supernecronomicon commented on Nov 15, 2026

    @supernecronomicon

    +1 to point 2. One useful requirement is to keep provider credentials accessible to OpenCode while making them inaccessible to model-controlled tools.

    In a synthetic Linux probe, we tested OpenCode 1.18.30 inside Anthropic's srt 1.0.0 with our test configuration, using a fake credential in OPENCODE_AUTH_CONTENT. The child command did not inherit that variable, but it could recover the fake credential from its parent's /proc/<pid>/environ. So clearing the child environment was insufficient in that setup.

    A tool-level sandbox seems useful here: OpenCode handles authentication, while model-controlled commands run with restricted filesystem, network, and process access. The boundary also needs to protect credential stores, including files or databases, rather than relying on a clean command environment alone. Model-controlled file-reading tools need equivalent protection.

    Regression checks should confirm that OpenCode can still authenticate while model-controlled tools cannot recover a fake provider credential through credential stores, ancestor process interfaces, or inherited descriptors.

  6. benjaminfrombe commented on Nov 16, 2026

    @benjaminfrombe

    @supernecronomicon - that requirement is exactly what we built into a standalone plugin in the meantime, no core changes needed: universal-opencode-sandbox (on npm, currently 0.4.1).

    What it covers today:

    • Agent shell commands (and optionally user ! commands and plugin shells) run in MXC sandboxes (Seatbelt / bubblewrap / ProcessContainer), fail-closed.
    • Credential stores are read-denied at the filesystem level by default - ~/.ssh, ~/.aws, ~/.gnupg, ~/.kube, provider auth.json files (~/.local/share/opencode/auth.json, ~/.codex/auth.json, ~/.claude/.credentials.json), ~/.npmrc, docker and gh configs - independent of the command environment. OpenCode itself keeps full access because only the spawned command is contained.
    • Escapes are a separate permission (shell_unsandboxed) that names the exact command and asks the user. (Can be disabled in config)

    What it does not cover yet, matching your regression list:

    • Model-controlled file-reading tools (read/grep/glob) run outside the shell sandbox, so they need equivalent protection in a core implementation - a fair requirement for feat(core): sandbox agent shell commands with MXC #64093.
    • We have not explicitly tested the /proc/<pid>/environ ancestor vector under MXC yet; your probe is a good regression case to adopt.

    The plugin reads its policy only from user-owned config outside the workspace, so a repository cannot loosen it.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions