OpenCode permissions and sandboxing

OpenCode has built-in allow, ask and deny permission rules, but the project states that these prompts are not a security boundary and that it does not sandbox the agent. Real isolation has to come from a container or VM you run.

On this page

Does OpenCode permissions and sandboxing meet our control requirement?

OpenCode includes built-in permission rules with allow, ask and deny effects in its open-source release, but it does not sandbox the agent, and its own SECURITY.md states that permission prompts are not a security boundary. A security or platform lead approving a coding agent that edits code and runs shell commands should therefore treat the in-product rules as a usability and policy layer, not as the isolation control an audit or risk owner will expect. The requirement that the agent cannot reach what it should not reach is met only partially in software, and the remainder has to come from the organization's own isolation layer.

In practice, that means the organization must supply the boundary. The project's SECURITY.md recommends a Docker container or virtual machine for real isolation, and it lists sandbox escapes as out of scope for vulnerability reports, so the team owns that design. Before approval, confirm which host user the agent runs as, which directories and credentials that user can reach, and whether network egress is restricted at the container or VM level. The permissions documentation also warns that shell commands run with the host user's filesystem, process and network authority, so a narrow allowlist is safer than relying on pattern-based danger detection.

The Enterprise plan adds SSO, SCIM, budgets and policies, according to the OpenCode Enterprise page, but the sources reviewed for this topic do not show that it changes runtime sandboxing or enforces the permission model at the operating system level. Ask the vendor in writing whether any Enterprise or Console policy can enforce a sandbox, and confirm how managed policies interact with the project's default rules. Until that is answered, record the approval as conditional on a container or VM boundary that the organization operates itself.

Permission and sandbox capabilities by edition

This table compares the OpenCode permission and sandbox controls across the open-source release, the Console or Go plans and Enterprise. Read the open-source column as the baseline that ships in the tool, and confirm every Console, Go and Enterprise cell with the vendor before approval. The main takeaway is that permission rules govern what the agent asks about, while the project states that it does not sandbox the agent, so isolation must come from a container or virtual machine that your team operates.

ControlOpen-source release (built in)Console or GoEnterprise
Allow, ask and deny rulesRules have action, resource and effect fields. Effects are allow, ask and deny, and the last matching rule wins.Documented as part of the same permissions model. Confirm which rules apply to Go and Console sessions.Confirm with the vendor how rules are set centrally and whether members can override them.
Default when no rule matchesAsk. The agent prompts the user when no rule matches.Confirm the default with the vendor for hosted sessions.Confirm whether an organization can change the default for all members.
Default allow on most actionsThe base policy allows all actions on all resources except reading .env files.Confirm whether the same base policy applies to hosted sessions.Confirm whether the base policy can be replaced by an organization policy.
Reading .env filesReading .env files asks for approval by default.Confirm whether this prompt applies in Console or Go sessions.Confirm whether administrators can block .env reads outright.
Access outside the project directoryAllowed without a prompt by default under external_directory. Review this default before approval.Confirm the default for hosted sessions.Confirm whether administrators can require a prompt or deny this access.
Top-level policies arrayCan hard-deny after normal rules are applied. It cannot grant access.Confirm whether this array is honored in Console and Go sessions.Confirm whether administrators can manage this array centrally.
Global or Console policies over project configGlobal policies override project configuration according to the permissions docs.Console policies override project configuration according to the permissions docs. Confirm for Go.Enterprise adds policies. Confirm how they layer over Console and project settings.
Shell pattern rulesShell runs with the host user's filesystem, process and network authority. The project favors a narrow allowlist over pattern-based danger detection.Confirm whether shell rules are enforced identically in hosted sessions.Confirm whether administrators can require an allowlist-only shell policy.
OS-level sandboxNot provided. The project recommends a Docker container or virtual machine for real isolation and puts sandbox escapes out of scope for reports. Isolation must be built outside the tool.Not provided by the Console or Go plans in the supplied facts. Confirm with the vendor.Not described in the supplied facts. Confirm whether any Enterprise isolation exists before relying on it.

How the permission rules decide each action

Every OpenCode permission rule has three parts: an action, a resource and an effect. The effect is one of allow, ask or deny. When no rule matches a request, OpenCode asks, so the default for anything unlisted is a prompt to the user rather than a silent grant. Reviewers should read the rule set as a list of exceptions to that prompt, and confirm in their own test environment how each effect is written in the configuration before approving a team setup.

The base policy that applies to every agent is broad. It allows all actions on all resources, with one notable exception: reading .env files asks first. Access to directories outside the project, which the docs call external_directory, is allowed without a prompt by default. Security reviewers should treat that default as a decision they must make explicitly, because a project that keeps credentials or shared configuration in a neighboring directory will expose them without any prompt. Check what sits outside each project root on the machines where staff will run the tool.

Two precedence rules determine the final answer. The last matching rule wins, so order in the configuration matters. A top-level policies array can hard-deny an action after the normal rules run, but it cannot grant access that the rules withhold. Global or Console policies override project configuration, which means a developer cannot loosen a control set centrally by editing a repository file, but a central policy author may also be the only person who can change it. The docs warn that shell commands run with the host user's filesystem, process and network authority. For that reason they favor a narrow allowlist of commands over pattern-based detection of dangerous commands, since a pattern can miss a variant the author did not anticipate. Treat shell access as the highest-risk permission and confirm whether it is set to ask, allow or deny for each agent.

How a requested action is decided

An action the agent wants to take starts at the agent and passes to the permission engine, which checks the rules in order. The last matching rule sets allow, ask or deny, and if no rule matches, OpenCode asks. A top-level policies array can hard-deny after the normal rules, but it cannot grant access. Anything that is allowed then runs with the host user's authority, which is why the project says isolation must come from a container or VM around the tool, not from the permission check.

Permission decision path, with the host user layer where the project says isolation must be added.

Decisions to make before approving shell and file access

OpenCode's permission rules decide what the agent may read, edit and run, but the project states those prompts are not a security boundary. The decisions below set the policy layer, the shell scope, the file reach and the place where the agent runs, so each one should be settled before approval.

Who owns the policy layer

Global and Console policies override project config, so a rule set in a repository can be overridden by a layer the project team may not control. Decide which team owns the global policy, who can change project-level permission files, and whether developers can widen access locally. Check how a policy change reaches existing installs and confirm that answer with the vendor before rollout.

Permissions docs

Shell allowed or narrow allowlist

Shell runs with the host user's filesystem, process and network authority. The docs say a narrow allowlist is safer than pattern-based detection of dangerous commands. Decide whether shell is permitted at all for each use case, and if it is, list the exact commands permitted rather than relying on a deny list to catch risky ones.

External directories and deny rules

Access to directories outside the project is allowed without a prompt by default. Decide which paths outside the repository the agent must never touch, such as home directories, credential stores or shared mounts, and write explicit deny rules for them. Remember that the last matching rule wins, so order matters when reviewing the file.

Where the agent runs

OpenCode does not sandbox the agent, and the project recommends a Docker container or VM for real isolation. Decide whether developers run it on a laptop with their full user access, or inside a container or VM with only the project mounted and outbound network limited. Confirm which option your security team will accept before anyone uses it on client or regulated code.

OpenCode SECURITY.md

Denying .env and secret paths

The base policy asks before reading .env files, which means a developer can approve the read in the moment. Decide whether secret paths should be denied outright for all agents, and whether secrets should be kept out of the working tree entirely. Test that the deny rule applies to the paths your teams actually use, including variants such as .env.local.

How exceptions are reviewed

Developers will ask to widen access for a build, a migration or a new tool. Decide who approves an exception, how long it lasts, and where the approved rule is recorded so it can be removed later. Keep exceptions in version-controlled policy files where a reviewer can see each change and its owner.

How the answer changes by setup

On a developer laptop, OpenCode runs as the logged-in user, so it inherits that user's files, processes and network access. Permission rules can shape what the agent asks about, but they do not confine it. The project's own security policy states that OpenCode does not sandbox the agent and that permission prompts are not a security boundary.

  • Secret files: The base policy asks before reading .env files, but other files inside the project are allowed by default, so credentials stored under other names need explicit permission rules.
  • Outside the project: Access to directories outside the project is allowed without a prompt by default, so SSH keys, cloud CLI profiles and other home directory credentials may be reachable unless you add a deny rule.
  • Shell commands: Shell runs with the user's filesystem, process and network authority, so a narrow allowlist is safer than relying on pattern-based danger detection.
  • Isolation to add: For sessions touching sensitive repositories, run OpenCode in a Docker container or VM, or keep long-lived credentials out of the user's home directory.

Check which local credentials, tokens and configuration files the agent can read on a standard developer image before approving laptop use.

Order of work before production use

This sequence moves a team from an unreviewed OpenCode install to a documented, tested boundary: the scope of what the agent may reach is fixed first, then the rules, then the isolation layer that actually enforces it, and finally the review trigger that keeps the approval current.

  1. Define the threat model and in-scope assets

    The security lead and the engineering owner list the repositories, configuration files, credentials and environment variables the agent could reach on a developer machine or build host, and record which of them must never be read or sent to a model. They also decide which outbound destinations are acceptable. This is done when the list is written down, named by owner, and approved by security before any rule is written. Ask OpenCode's own threat model and the SECURITY.md statement that it does not sandbox the agent to frame what the team is accepting.

  2. Write project and global permission rules

    The engineering owner writes project-level and global rules that set allow, ask and deny effects for each action and resource on the in-scope list. Remember that OpenCode asks when no rule matches, that the last matching rule wins, and that the base policy asks before reading .env files and allows external_directory access without a prompt by default, so those defaults need explicit deny or ask rules. The check is a written rule file in version control, a reviewed diff, and a test session in which a deny rule blocks a read of a test secret.

  3. Build the container or VM isolation boundary

    The platform or infrastructure team runs OpenCode inside a Docker container or virtual machine that the project's SECURITY.md recommends for real isolation. The account inside the boundary should be least-privilege, with no access to host credentials, production networks or the wider home directory, and egress should be limited to the model endpoints and package sources the team has approved. The check is an inventory of mounted paths, the service account's permissions, and a network test showing that unapproved destinations fail.

  4. Test denials at the operating system layer

    The security engineer runs scripted tests that ask the agent to read a denied file, write outside the project, and reach a blocked host, then confirms that each action fails at the operating system or network layer even if the permission rule were removed. Because OpenCode warns that shell commands run with the host user's filesystem, process and network authority, pattern matching on commands should not be treated as the control. The test passes when every denied action fails inside the boundary and the results are saved as evidence.

  5. Confirm which policies Enterprise or managed config enforces

    The procurement and IT lead checks whether the chosen plan can enforce the rules centrally, and which settings can be locked on staff machines. OpenCode Enterprise is described as adding SSO, SCIM, budgets and policies, but the exact enforcement scope is on quoted terms, so ask the vendor in writing which policies apply to global or Console configuration and which can be overridden locally. The check is a written answer from the vendor and a test showing that a developer cannot override a centrally set deny rule.

  6. Set a re-review trigger for version changes

    The engineering owner records the OpenCode version approved for use and sets a rule that any upgrade, new install method or change to permission defaults reopens the review. The security team watches the project's published advisories and the repository's release notes, and reruns the denial tests from the previous step against each new version before rollout. The step is complete when the approved version, the test suite and the owner are recorded in the change process and a re-review is logged.

What a security reviewer asks to see

This table lists the evidence a reviewer should request before approving OpenCode permission settings, and the question each item answers. Read it as a checklist: each row names where the evidence should come from, either the OpenCode tool documentation or the organization's own systems. Items marked as the organization's own records are the ones the vendor cannot supply on your behalf.

EvidenceQuestion it answersWhere it comes from
Permission config files in each repositoryWhich allow, ask and deny rules apply to this project, and are they reviewed like other code?The project's own repositories, reviewed through the organization's version control
Global and Console policy settingsDo global or Console policies override project rules, and which ones are in force for each user?OpenCode permissions docs, plus the organization's own policy records
Isolation layer definitionWhat boundary actually contains the agent, such as a container or VM, given that permission prompts are not a boundary?The organization's own infrastructure documentation, checked against the OpenCode SECURITY.md recommendation
Test log showing denied reads and shell callsDo reads of .env files and blocked shell commands really fail in our environment?Generated by the organization during a controlled test in its own environment
SECURITY.md statement on sandboxingHas the project stated in writing that it does not sandbox the agent, and what does it recommend instead?OpenCode SECURITY.md in the anomalyco/opencode repository
Change record for permission editsWho changed a rule, when, why, and was the change approved?The organization's version control history and change management system

Questions buyers ask before approving OpenCode permissions

Is OpenCode sandboxed?

No. The OpenCode project states in its SECURITY.md that it does not sandbox the agent. The permissions docs warn that shell commands run with the host user's filesystem, process and network authority. For real isolation, the project recommends running OpenCode inside a Docker container or a virtual machine, and it lists sandbox escapes as out of scope for vulnerability reports. Plan the isolation layer as a separate project in your environment, and confirm with your security team which container or VM boundary, network egress rules and credential handling meet your policy before any staff member runs it on a workstation or shared host. See the OpenCode SECURITY.md for the project's exact wording.

Are OpenCode permission prompts a security control?

No, the project says they are not a security boundary. Permission prompts help a developer notice and approve an action, but they do not contain what the agent can do once approved. The permissions docs also say that a narrow allowlist is safer than pattern-based detection of dangerous shell commands, because pattern matching can be bypassed. Treat allow, ask and deny rules as a way to reduce accidental actions and to document intent, and pair them with an isolated environment and least-privilege credentials when the data or systems behind them matter.

What does the OpenCode agent read by default?

By default, the base policy allows all actions on all resources except reading .env files, which asks for approval. Access to directories outside the project, handled as external_directory, is allowed without a prompt. Because OpenCode uses ask when no rule matches, any action your rules do not name will prompt. Before rollout, list the paths that hold credentials, customer data or build secrets, then write explicit deny or ask rules for them and test them in a non-production repository. Confirm the current defaults in the OpenCode permissions docs for the version you deploy.

Can an admin enforce OpenCode rules centrally, and is that in Enterprise?

The permissions docs say that global or Console policies override project config, and that a top-level policies array can hard-deny after normal rules but cannot grant access. That gives an administrator a way to set outer limits that a project file cannot loosen. Whether this central control is available to your organization depends on the plan. OpenCode Enterprise adds SSO, SCIM, budgets and policies according to the OpenCode Enterprise page, but the terms are quoted. Ask the vendor in writing which policy features, managed configuration methods and device enforcement apply to your plan before you rely on them.

What does isolation work cost, and who pays for it?

The cost has three parts: the work to build a container or VM boundary, the work to define rules and test them, and the ongoing upkeep as OpenCode versions change. Your team pays its own staff time and the cloud or hardware used to run the boundary. OpenCode's own fees are separate: Console usage is pay-as-you-go, with a processing fee of 4.6% plus $0.31 on each credit purchase according to the OpenCode Console docs read in November 2026, and Go is a monthly subscription. Effort rises with the number of repositories, the number of toolchains and languages, how many network destinations must be allowed, and whether developers need local model access. Ask any vendor for a written scope that lists these drivers.

Can our own team configure this, or do we need outside help?

Many teams can set up the rules themselves if they already run containers, manage developer endpoints and review security tooling. Outside help is most useful for designing the isolation boundary, writing and testing deny rules against your real repositories, checking network egress, and producing evidence for internal reviews. DeployOpen plans, implements, hardens and documents self-hosted platforms inside your own infrastructure, runs security testing including AI and agent security, and works on fixed scopes agreed in writing before work starts. DeployOpen does not issue audit reports or certifications. Scope any outside work against your environment, not a generic template.

How do the last matching rule and the policies array interact?

The last matching rule wins among normal rules, so order matters when several rules match the same action. The top-level policies array is evaluated after normal rules and can hard-deny an action, but it cannot grant access that normal rules withheld. Use this to write a short list of absolute denials for sensitive paths and commands, and keep broad allow rules in the project file. Test the combined result with a sample session, because a mistaken ordering can leave an action open that you meant to block.

How DeployOpen helps set up OpenCode isolation safely

DeployOpen works on OpenCode permissions and sandboxing as a fixed-scope engagement inside your own infrastructure. The work starts from the project's own position that its permission prompts are not a security boundary, so the deliverables focus on isolation outside the agent, tested permission rules and documented evidence for your reviewers.

How we scope

  • Written scope lists which repositories, hosts and developer machines OpenCode may reach in your environment
  • Scope records the permission rules, shell patterns and external directory access your teams need
  • Scope names the isolation layer, such as a container or virtual machine, that you will approve
  • Engagements are fixed-scope, with deliverables and timelines agreed in writing before work begins

How we build

  • We configure project and managed permission files with explicit allow, ask and deny rules for each resource
  • We build isolated runtimes in your cloud accounts or data centers, with network egress limited to approved destinations
  • We test whether rules and sandbox boundaries hold, including attempts to read .env files and run unlisted commands
  • We document each rule, its reason and the residual risk that remains outside the sandbox

How we hand over

  • Handover includes configuration files, runtime definitions and a written record of tested permission behavior
  • Your security and platform teams receive instructions to reproduce the setup and review changes to rules
  • Evidence is organized so your internal reviewers or independent auditors can assess the controls directly
  • Knowledge transfer covers how to update rules when the OpenCode version or your policy changes

How we support

  • Ongoing support, upgrades and continuous testing are available as retainers after handover
  • Retained work can re-test permission rules and sandbox boundaries when OpenCode releases change behavior
  • Support can review new security advisories from the project against your deployed configuration
  • Confirm with DeployOpen the exact retainer scope, response expectations and fees in your written quote

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.