Skip to content

Commit 207a59a

Browse files
committed
docs: add comprehensive security threat model and architecture documentation
1 parent b3ae193 commit 207a59a

1 file changed

Lines changed: 68 additions & 0 deletions

File tree

‎SECURITY.md‎

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,71 @@
1+
# Security
2+
3+
## Threat Model
4+
5+
### Overview
6+
7+
OpenCode is an AI-powered coding assistant that runs locally on your machine. It provides an agent system with access to powerful tools including shell execution, file operations, and web access.
8+
9+
### No Sandbox
10+
11+
OpenCode does **not** sandbox the agent. The permission system exists as a UX feature to help users stay aware of what actions the agent is taking - it prompts for confirmation before executing commands, writing files, etc. However, it is not designed to provide security isolation.
12+
13+
If you need true isolation, run OpenCode inside a Docker container or VM.
14+
15+
### Out of Scope
16+
17+
| Category | Rationale |
18+
| ------------------------------- | ----------------------------------------------------------------------- |
19+
| **Server access when opted-in** | If you enable server mode, API access is expected behavior |
20+
| **Sandbox escapes** | The permission system is not a sandbox (see above) |
21+
| **LLM provider data handling** | Data sent to your configured LLM provider is governed by their policies |
22+
| **MCP server behavior** | External MCP servers you configure are outside our trust boundary |
23+
24+
### Architecture
25+
26+
```
27+
┌─────────────────────────────────────────────────────────────────┐
28+
│ User's Machine │
29+
│ ┌───────────────────────────────────────────────────────────┐ │
30+
│ │ OpenCode Process │ │
31+
│ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────────┐ │ │
32+
│ │ │ Agent │ │ Permission │ │ Storage │ │ │
33+
│ │ │ (LLM + │ │ System │ │ (~/.local/share │ │ │
34+
│ │ │ Tools) │ │ │ │ /opencode) │ │ │
35+
│ │ └─────────────┘ └─────────────┘ └─────────────────┘ │ │
36+
│ │ │ │ │
37+
│ │ ▼ │ │
38+
│ │ ┌─────────────────────────────────────────────────────┐ │ │
39+
│ │ │ Project Directory (cwd) │ │ │
40+
│ │ └─────────────────────────────────────────────────────┘ │ │
41+
│ └───────────────────────────────────────────────────────────┘ │
42+
│ │ │
43+
│ ┌──────────────────┼──────────────────┐ │
44+
│ ▼ ▼ ▼ │
45+
│ ┌────────────┐ ┌─────────────┐ ┌─────────────┐ │
46+
│ │ External │ │ LLM │ │ MCP │ │
47+
│ │ Filesystem │ │ Providers │ │ Servers │ │
48+
│ └────────────┘ └─────────────┘ └─────────────┘ │
49+
└─────────────────────────────────────────────────────────────────┘
50+
51+
Optional (user must opt-in):
52+
┌─────────────────────────────────────────────────────────────────┐
53+
│ HTTP Server Mode │
54+
│ ┌─────────────────────────────────────────────────────────┐ │
55+
│ │ Server (localhost:port) │ │
56+
│ │ - REST API endpoints │ │
57+
│ │ - WebSocket PTY │ │
58+
│ │ - SSE event stream │ │
59+
│ └─────────────────────────────────────────────────────────┘ │
60+
└─────────────────────────────────────────────────────────────────┘
61+
```
62+
63+
### Server Mode
64+
65+
Server mode is opt-in only. When enabled, set `OPENCODE_SERVER_PASSWORD` to require HTTP Basic Auth. Without this, the server runs unauthenticated (with a warning).
66+
67+
---
68+
169
# Reporting Security Issues
270

371
We appreciate your efforts to responsibly disclose your findings, and will make every effort to acknowledge your contributions.

0 commit comments

Comments
 (0)