feat: run sandbox transports in disposable workers

The control plane opened ssh connections itself, so a malicious ssh
server attacked the process that held the database, the master key, and
every room's keys. It now starts one worker per target and workspace.
The worker gets one target key on stdin, binds loopback behind a random
token, and serves exec, files, the pty, and the preview proxy. It has no
database and no master key, and a closed stdin ends it.

The preview HTTP client moved into the worker too. The app sees a typed
response, and the worker caps bodies, output tails, handshakes, and
transport waits.

Direct targets now reject loopback, private, link-local, multicast,
unspecified, carrier-grade NAT, and documentation addresses when a
target is created and again when its worker starts.
TOGETHER_ALLOW_PRIVATE_TARGETS=1 lifts the check for a server that runs
on one private network.
This commit is contained in:
vhaudiquet committed 2026-11-29 18:22:44 +01:00
1 parent a8f7e74ba0
commit fc684115b5
16 files changed
+1355 -208

No files matched your search

+8 -2
View File
@@ -32,6 +32,11 @@ Rules:
loop), and the spec says where.
- The sandbox is the security boundary. Approval is always `AllowAll`;
never add an approval prompt in the room.
- The control plane never opens an ssh connection and never parses ssh,
HTTP, or terminal bytes from a sandbox. `src/worker.rs` owns the data
plane: one disposable process per target, one room's key on stdin, a
loopback route behind a random token, no database, no master key.
Keep new sandbox parsing there, not in `src/api` or `src/room`.
- Every path into the sandbox goes through `rhema_sandbox::Sandbox` or
`ShellSandbox` (agent tools, files, terminal, preview). Do not spawn a
command on the host for room work.
@@ -52,8 +57,9 @@ src/room/agent.rs per-turn config, ssh sandbox, HostAgent assembly
src/room/runner.rs one task per room; mention -> turn; steering
src/room/message_tool.rs the agent's voice in the room
src/room/preview_tool.rs the agent's preview target
src/ssh.rs russh client, PTY terminal, direct-tcpip
src/preview.rs signed preview hosts, ssh proxy, static reads
src/worker.rs disposable data plane: loopback HTTP, PTY, forward, worker spawn
src/ssh.rs russh client and PTY pump, used only by the worker
src/preview.rs signed preview hosts, worker forward, static reads
web/app/ Nuxt 4 SPA (no SSR)
```