A sandbox wraps only the terminal client while the OpenCode agent service on port 49374 runs outside it

OpenCode 2.0, the new version of Anomaly’s open-source coding agent, no longer lives in the terminal: it runs as a background service on port 49374 on macOS, Linux and WSL, and the terminal, web interface, desktop app and scripts all connect to it. In a piece for Towards AI, engineer Najam Us Saqib shows that this change leaves many of the sandboxes teams built around OpenCode 1.x wrapped around the wrong process.

Key points on OpenCode 2.0 and agent sandboxing in 20 seconds

  • OpenCode 2.0 turns the agent into a shared service that listens on localhost only, on port 49374 (45278 on Windows).
  • In a test, a client inside a read-only sandbox created a file on the host through the service API.
  • Running with –standalone, or giving each sandbox its own service, avoids the problem.

According to Anomaly’s announcement on 12 October, version 2.0 moves the agent into “a single background process” on the user’s machine, rebuilds the API from scratch and adds hot-reloadable plugins, to the point that the agent can write a plugin for itself mid-session and use it right away. The company says OpenCode has millions of daily users, without giving a figure. Saqib, who notes that he uses Claude Code rather than OpenCode day to day, calls the design better engineering, but one that moves the security boundary.

The sandbox is wrapped around the wrong process

In OpenCode 1.x, server mode was optional. When a researcher reported a command injection bug in that mode early in 2026, the maintainers replied that server mode was opt-in and securing it was the user’s responsibility. Many teams responded by wrapping the opencode command in a sandbox, using Landlock on Linux, a container or a tool such as Fence, because the agent’s tools ran inside that process.

In 2.0, the command you launch is a client that attaches to the shared service, and that is where sessions and tools run. TNG’s sandbox wrapper for coding agents has already run into this: its Linux sandbox only allows explicitly granted ports, so the client could not reach the service. The issue rules out granting port 49374 as a fix, because the sandboxed client would attach to the host’s service and run tools outside the sandbox. TNG instead gives each sandboxed launch its own private service on a fresh loopback port, with its own configuration directory.

Saqib reproduced the situation with OpenCode 2.0.29 in a throwaway Linux container, without connecting any model. Inside a bubblewrap sandbox with the whole filesystem mounted read-only, touch failed as expected; but an API call to the service from the same sandbox created the file in the project on the host. No exploit was involved: the client found the service, read the password from the user’s OpenCode files and made a normal call. The CLI includes a --standalone flag that starts a private server instead of using the shared service, and in his test it brought up its own server on a random port.

Remote access, plugins and defaults

According to the v2 documentation cited by the author, the service listens only on localhost by default. opencode pair connects other apps and browsers through single-use links that expire after five minutes, and a paired session lasts 30 days. opencode pair --remote exposes the service through an end-to-end encrypted tunnel that still requires the server password. The first time, a warning says the server will be exposed to the internet, and a script with no terminal needs --yes; once accepted, later runs skip the prompt, even after remote access has been switched off. The service can also listen on every interface with opencode service set hostname 0.0.0.0.

The feature Saqib would watch most closely is plugins: they run inside the service with its permissions, and the agent can write one and load it in the same session. A Hacker News commenter called this a security misalignment; the author does not go that far, but argues that the plugin directory deserves the same review as any other code path into production. Version 1.19.0, which points users to opencode upgrade --major, no longer installs updates automatically and validates terminal connection origins. As Capital and Compute notes, 2.0 also changes the plugin API, the server API and terminal settings, and no longer runs language servers (LSP).

Six checks for teams running OpenCode

The author acknowledges that the defaults are sensible: the service rejected his unauthenticated request, the generated password sits in files only the user can read, and the model resembles what VS Code Server and Jupyter have done for years. His advice is to check where the isolation now sits:

  • Run opencode service status on every upgraded machine and confirm it listens on 127.0.0.1, not 0.0.0.0.
  • Do not grant port 49374 into the sandbox or mount the OpenCode config into it; use --standalone or one service per sandbox.
  • Search scripts and dotfiles for pair --remote and --yes, because acceptance is sticky.
  • Change the password with opencode service set password, which signs out every paired session.
  • Put the plugin directory under version control or file monitoring.
  • Pin the version in team setups and plan opencode upgrade --major, since 1.x plugins do not work in 2.0.

Minimalist, tightly scoped agents are a recurring theme on this site, from Pi Agent’s minimalist approach to coding agents to tools that limit what an agent can touch. For OpenCode 2.0, Saqib’s conclusion is simple: a sandbox only protects the process it wraps, and that process is no longer the terminal.

Frequently asked questions

Is OpenCode 2.0 exposed to the network by default?

No. According to the documentation, the service listens only on localhost unless the hostname is changed or remote access is enabled.

What port does OpenCode 2.0 use?

49374 on macOS, Linux and WSL, and 45278 on Windows.

Does a sandbox built for OpenCode 1.x still work?

Only if the tools run inside it. In Najam Us Saqib’s test, a client in a read-only sandbox created a file on the host through the shared service.

How should OpenCode 2.0 be sandboxed?

Run the agent with –standalone inside the sandbox, or give each sandbox its own service and configuration directory, as TNG did.

Sources:

Scroll to Top