GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat: configurable sandboxing for bash commands and local MCP servers on linux/macos by kyuz0 · Pull Request #20316 · anomalyco/opencode

Conversation

@kyuz0

@kyuz0 kyuz0 commented Mar 31, 2026

Copy link
Copy Markdown

Issue for this PR

Closes none

Type of change

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

What does this PR do?

Adds bash sandboxing to OpenCode via Anthropic's Sandbox Runtime (srt). This executes agent commands in an isolated environment (bubblewrap on Linux, sandbox-exec on macOS).

The architecture is built around an abstract SandboxProvider interface so that other sandbox backends (like native bubblewrap, nsjail, or gVisor) can be easily implemented and selected in the configuration file in the future.

The sandbox is configured in opencode.json and supports:

  • Network Isolation: Blocks outbound requests except for explicit domains.
  • Environment Scrubbing: Clears process.env and injects only the env_whitelist.
  • Workspace Constraints: Restricts access to cwd and /tmp. Matches in deny_workspace_patterns are bind-mounted to /dev/null allowing neither read nor write access.
  • Binary Blocklisting: Prevents execution of binaries in deny_binaries.

Example Configuration (opencode.json):

{
  "$schema": "https://opencode.ai/config.json",
  "bash_sandbox": {
    "enabled": true,
    "provider": "srt",
    "domains": ["github.com", "registry.npmjs.org"],
    "env_whitelist": ["PATH", "HOME", "USER", "SHELL", "TERM"],
    "deny_workspace_patterns": [
      "**/*.env",
      "**/*.secret",
      "**/*_rsa"
    ],
    "deny_binaries": ["terraform", "aws", "docker"]
  }
}

How did you verify your code works?

Ran local tests (bun test test/sandbox/srt.test.ts) that check:

  • Unapproved network requests fail.
  • Environment variables are dropped.
  • Out-of-workspace reads (e.g. ~/.bash_history) fail.
  • Matches against .env block read, write, rm, and chmod syscalls, including files created dynamically by the agent.

Note for reviewers: I am not sure if the tests as written fit the repository's standard CI flow, as they require srt to be installed on the host machine to pass.

Screenshots / recordings

If this is a UI change, please include a screenshot or recording.

Checklist

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

80avin reacted with thumbs up emoji reneleonhardt reacted with heart emoji
All reactions
  • 👍 1 reaction
  • ❤️ 1 reaction
@github-actions github-actions Bot added needs:title needs:compliance This means the issue will auto-close after 2 hours. labels Mar 31, 2026
@github-actions

github-actions Bot commented Mar 31, 2026

Copy link
Copy Markdown
Contributor

Hey! Your PR title Configurable sandboxing for Bash commands on linux/macos 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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@kyuz0 kyuz0 changed the title Configurable sandboxing for Bash commands on linux/macos feat: configurable sandboxing for bash commands on linux/macos Mar 31, 2026
@github-actions github-actions Bot removed needs:title needs:compliance This means the issue will auto-close after 2 hours. labels Mar 31, 2026
@github-actions

github-actions Bot commented Mar 31, 2026

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@kyuz0 kyuz0 changed the title feat: configurable sandboxing for bash commands on linux/macos feat: configurable sandboxing for bash commands and local MCP servers on linux/macos Apr 1, 2026
This was referenced Apr 2, 2026
Fix: Config Get returns stale data after Patch #20636
Closed
feat(opencode): add experimental macOS bash command sandboxing #21538
Closed
Donato Capitella added 8 commits April 15, 2026 10:08
Donato Capitella
feat: implement bash command sandboxing using the srt provider and ad…
0a2b7b1
…d configuration support
Donato Capitella
refactor: enforce read and write restrictions for deny_workspace_patt…
a6120e0
…erns and update tests to verify full file access blocking
Donato Capitella
test: update srt sandbox test to verify read permission denial for ne…
7a5dff2
…wly created files
Donato Capitella
feat: adding sandboxing for local MCPs
b1d40aa
Donato Capitella
refactor: remove externalOutputMode from Tui renderer configuration
0e97608
Donato Capitella
test: skip MCP sandbox tests when srt is unavailable or on Windows
7b33d96
Donato Capitella
refactor: rename project to SecureCode and implement securecode.json …
6e50d3d
…configuration overlay for sandbox management
Donato Capitella
feat: implement interactive sandbox elevation prompts and harden conf…
b8c24e9
…iguration security with absolute directory blocks
@kyuz0
kyuz0 force-pushed the sandboxing branch from 22a4c49 to b8c24e9 Compare April 15, 2026 15:17
Donato Capitella added 2 commits April 15, 2026 17:12
Donato Capitella
refactor: remove internationalized README files and update logo path …
9de5b03
…in README.md
Donato Capitella
docs: add project logo to README
ffa9b61
@opencode-agent
opencode-agent Bot force-pushed the dev branch from 2f2ed11 to 9f201d6 Compare April 16, 2026 21:55
@rekram1-node

rekram1-node commented May 15, 2026

Copy link
Copy Markdown
Member

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rekram1-node rekram1-node closed this May 15, 2026
@rekram1-node rekram1-node added the automated-pr-cleanup label May 15, 2026
@80avin 80avin mentioned this pull request Jun 14, 2026
Is there a way to sandbox the agent ? #2242
Closed
@Bearmancer Bearmancer mentioned this pull request Oct 8, 2026
docs(opencode): document shell advisory gap for sandbox #53937
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

automated-pr-cleanup

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@kyuz0 @rekram1-node
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.