barebox 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,418 +0,0 @@
1
- # PRD: Lightweight local sandbox for AI agents
2
-
3
- > Working name: TBD (see Open questions).
4
- > Status: M0 done + red-teamed Oct 26 (main 14/14, red-team 8/8 detections); M1 next. Scopes the idea note `agent-sandbox.md` in this folder.
5
- > Build window: Meta Global AI Developer Hackathon, Oct 26 – Nov 4 2026 (10 days). Built to be the seed of a real product, not a throwaway.
6
-
7
- This PRD follows the minimum content from AGENT_RULES.md "Operating Flow": Problem & goal, Go/no-go, Out of scope, Modules, Open questions. Every POC result updates this file. A result that flips the go/no-go or a module's assumption is a spec change.
8
-
9
- ## 1. Problem & goal
10
-
11
- ### Problem
12
-
13
- Agents need real access to be useful: shell, files, network. Today a developer picks one of two bad options.
14
-
15
- - **Approve everything.** About forty prompts per task. People stop reading them, or switch prompts off.
16
- - **Heavy isolation.** Docker or a VM. Images, a daemon, root, and the agent can't use the installed toolchain. Most people skip it.
17
-
18
- Neither matches where the risk is. Reads are mostly harmless. File writes can be fixed. Only a few actions can't be undone: paying, sending, publishing, pushing.
19
-
20
- The existing lightweight sandboxes (for example Anthropic's sandbox-runtime, srt) block well but cost memory. Measured below: about 100 MB per sandbox, because each one starts its own proxy. That does not scale to many agents on one small machine.
21
-
22
- ### Goal
23
-
24
- A lightweight local sandbox for running AI agents with guardrails. Two jobs: damage control (mistakes and prompt-injected agents) and controlled governance (who may do what, with an audit log).
25
-
26
- The one-line version: **an agent runs on your machine with your real tools, every write is undoable, and nothing leaves the machine without passing a doorman. You're asked only when something irreversible is about to happen.**
27
-
28
- ### Priorities, in order
29
-
30
- 1. **Low memory.** Primary.
31
- 2. **Local or a cheap VPS.** Never needs a cloud. Zero cost.
32
- 3. **Many agents per machine.** One shared proxy, many thin sandboxes. Not a cluster.
33
- 4. **Cross-platform.** Later.
34
-
35
- ### First users
36
-
37
- Solo devs and small teams. They want maximum control and freedom at zero cost.
38
-
39
- ### Why now
40
-
41
- The hackathon gives a fixed 10-day window and a demo audience. The memory measurements already show a clear gap against the current prior art, so the idea can be tested quickly.
42
-
43
- ### What it is and isn't
44
-
45
- - **Is:** a strong guardrail against mistakes and prompt-injected agents. No root, no daemon, no image. Millisecond-scale start for the walls (measured below).
46
- - **Isn't:** a security boundary against a determined attacker. The kernel is shared. A kernel exploit escapes. Use a VM for that.
47
-
48
- ## 2. How it works (same model as the idea note)
49
-
50
- Three letters, each handled differently. Same letters as rwxmap and bareguard.
51
-
52
- | Letter | Meaning | What the sandbox does | You're asked? |
53
- |---|---|---|---|
54
- | **r** | reads, changes nothing | lets it through (except locked paths) | never |
55
- | **w** | changes things, can be set back | records it on an undo layer | once, at the end (review the diff) |
56
- | **x** | can't be undone: send, pay, publish, push, delete remote | holds it at the door until you decide | at the moment it happens |
57
-
58
- The agent works in your house:
59
-
60
- 1. **Tracing paper (w).** The agent sees the real files. Every change lands on tracing paper laid over them. At the end you press it down (commit) or throw it away (rollback).
61
- 2. **Locked drawers (r).** It reads most things. Some drawers can't be opened: `~/.ssh`, `~/secrets`, browser profiles, password stores.
62
- 3. **One front door with a doorman (x).** The agent has no network of its own. The only way out is the doorman. It waves lookups through and holds anything that sends, pays or publishes until you say yes.
63
-
64
- ### Picture
65
-
66
- ```
67
- agent process (real node, python, git)
68
- |
69
- +-----+--------------- bwrap sandbox (unprivileged) ---------------+
70
- | files: overlay lower = real project (read only) |
71
- | upper = per-run tracing paper |
72
- | locked paths (~/.ssh etc.) -> empty tmpfs |
73
- | network: none of its own |
74
- | socat inside: 127.0.0.1:3128 -> per-agent unix socket |
75
- +-----+------------------------------------------------------------+
76
- | per-agent unix socket (the connection = the agent's identity)
77
- v
78
- ONE shared proxy (Node, in-process: rwxmap + bareguard)
79
- |-- r -> forward
80
- |-- x -> hold, ask the human, forward or 403
81
- '-- unknown -> per-mode default
82
- ```
83
-
84
- ### The doorman's deterministic x-rules (strongest first)
85
-
86
- The proxy sees requests, not intent, and sites use `POST` for both searching and paying. So `GET = r, POST = x` is too crude. The rules, strongest first:
87
-
88
- 1. **Card data in the body: always x.** Any 13–19 digit number that passes the Luhn check, or a CVV/expiry field.
89
- 2. **Payment destinations: always x.** Known payment domains and paths such as `/checkout`, `/payment`, `/orders`, `/purchase`.
90
- 3. **Known APIs: rwxmap labels.** For example, search = r, create order = x.
91
- 4. **Unknown POST: mode default.** Strict: ask once per new domain, then remember for the run. Normal: allow and log.
92
-
93
- The idea note's "personal data leaving" rule is out of scope.
94
-
95
- ### Capability without custody
96
-
97
- The agent never holds the card or API keys. It types a placeholder. The proxy puts the real value in only after the human approves that specific request. In v1 this works for **request headers only** (see M5).
98
-
99
- ## 3. Go / no-go
100
-
101
- The product stands or falls on three things, all on Linux.
102
-
103
- | # | Capability | Proof |
104
- |---|---|---|
105
- | a | The proxy is the only way out, fails closed, and can read inside HTTPS. | A request that skips the proxy fails. A request through it is visible in full (method, URL, headers, body) for curl, node, python requests, git over https. |
106
- | b | The proxy holds one x request for human approval while the agent keeps working. | One request parked; other requests from the same agent complete meanwhile; approve forwards it, deny or timeout returns a clear 403. |
107
- | c | Per-agent memory and the shared proxy stay within the memory targets. | Measured with 20 concurrent sandboxes (see Memory targets). |
108
-
109
- M0, M1 and M2 are the go/no-go modules. If any of a, b or c fails, stop and take it back to this PRD as a spec change. M3 onward is not started until M0–M2 pass.
110
-
111
- ### Memory targets
112
-
113
- These are targets, not results. They get measured in M0, M1 and M6.
114
-
115
- | Item | Target |
116
- |---|---|
117
- | Shared proxy | <= 80 MB |
118
- | Each extra sandbox, on top of the agent itself | <= 10 MB |
119
- | Agents on a 2 GB VPS | 20 |
120
-
121
- ## 4. Evidence so far
122
-
123
- Measured on the dev machine: Fedora, kernel 7.2, bubblewrap 0.12.0, Node 22, ext4 home. These came from throwaway POCs. They are evidence, not the product.
124
-
125
- ### Baseline
126
-
127
- | Item | Measured |
128
- |---|---|
129
- | Idle Node process | 49 MB RSS |
130
-
131
- ### srt 0.0.81, one sandboxed command
132
-
133
- | Item | Measured |
134
- |---|---|
135
- | srt Node process | 82 MB |
136
- | 3 socat relays | ~12 MB |
137
- | 3 bash wrappers | ~8 MB |
138
- | Total per sandbox | ~100 MB |
139
- | Start time (3 runs) | 1.87 / 2.05 / 1.98 s |
140
-
141
- srt starts a proxy per sandbox, so that is about 1 GB for 10 agents and about 2 GB for 20. Its blocks worked: allowed domain returned 200, other domain blocked, `~/.ssh` empty, write outside the allowed area blocked (read-only).
142
-
143
- ### Own walls POC (bwrap + overlay)
144
-
145
- - Agent edited `a.txt` and created `b.txt`. The agent saw its own changes.
146
- - The real folder was untouched. Both files landed in the upper layer.
147
- - `~/.ssh` showed empty (tmpfs). A write outside the project was blocked.
148
- - No network of its own.
149
- - Start plus exit: 0.02–0.03 s. Peak about 3.8 MB.
150
-
151
- ### Front door POC
152
-
153
- - Per-agent unix socket bind-mounted into the sandbox. `socat` inside bridges `127.0.0.1:3128` to the socket. A tiny Node CONNECT proxy runs on the host.
154
- - `example.com` allowed (200). `github.com` denied. Bypassing the proxy (`--noproxy`) fails closed.
155
- - `socat` inside the sandbox: 4.1 MB.
156
- - Bare test proxy: 55 MB RSS. It has no TLS inspection and no libraries loaded yet. **Real proxy memory is unmeasured.**
157
-
158
- ### Rough sum
159
-
160
- | Setup | 20 agents |
161
- |---|---|
162
- | Own walls: 55 MB once + 20 x ~8 MB | ~215 MB |
163
- | srt | ~2 GB |
164
-
165
- The own-walls figure will grow. The proxy still has to load TLS handling, rwxmap and bareguard, and none of that is measured. Treat 215 MB as a floor to check, not a promise.
166
-
167
- ### M0 measured run (Oct 26, PASS 14/14)
168
-
169
- Harness `/tmp/sbx-m0/run-m0.sh` (throwaway POC, not shipped): dumb Node forward+CONNECT proxy on 22 per-agent unix sockets; bwrap launcher (ro-bind `/usr` `/etc` `$HOME` `$PROJ`, tmpfs locked paths, unshare-net/pid/uts/ipc, socat bridge to `127.0.0.1:3128`). 20× idle sandboxes (`sleep` + `socat`) concurrent.
170
-
171
- | Item | Measured | Target | Verdict |
172
- |---|---|---|---|
173
- | Walls-only overhead per sandbox (2×bwrap + socat, no agent) | mean 7.7 MB, max 7.9 MB | ≤ 10 MB each | PASS |
174
- | Bare proxy RSS, 22 sockets, no TLS | 52.1 MB | ≤ 80 MB with TLS (M1) | recorded, TLS unmeasured |
175
- | Cold start + exit, single sandbox | 10 ms (17 ms prior run) | ms-scale walls | PASS |
176
- | Through-proxy HTTP | 200 | works | PASS |
177
- | CONNECT tunnel mechanics | 2 tunnels in log | works | PASS (opaque; inspection is M1) |
178
- | `~/.ssh` masked (host has 6 entries, non-vacuous) | 0 visible | empty | PASS |
179
- | Project + home read-only | BLOCKED | blocked | PASS |
180
- | Bypass set: `--noproxy`, env-unset, direct IP, host localhost | all fail (curl exit 6/7), 0 default routes | fail closed | PASS |
181
- | Per-agent identity (fx, fy probes) | attributed correctly, no cross-attribution | connection = identity | PASS |
182
-
183
- Caveats: the tool shell had no outbound internet, so the upstream was a local `python3 -m http.server`; the real-internet client matrix (curl, node, python requests, git) is M1's job. One baseline `socat` on the box (origin unconfirmed, left running) was excluded via baseline subtraction; per-sandbox RSS comes from exact `/proc` tree walks of the 20 bwrap PIDs, not name matching.
184
-
185
- ### M0 red-team (Oct 26, 8/8 detections across 5 breaks)
186
-
187
- Ritual `/tmp/sbx-m0/redteam.sh`: each wall broken on purpose via `SBX_BREAK=` hooks in the throwaway launcher; PASS iff every break is DETECTED.
188
-
189
- | Break | Expected detection | Observed |
190
- |---|---|---|
191
- | `nonet` (no net namespace) | B3 exit 0 (host-localhost leak) | DETECTED, B3=0; door still 200, B4=2 routes |
192
- | `nolock` (no tmpfs masks) | T3 == host count (6) | DETECTED |
193
- | `rw` (writable binds) | T4a + T4b ALLOWED | DETECTED; canary in real `$HOME` created + removed, verified clean |
194
- | Miswired socket (marker alpha via socket bravo) | identity assertion fails; attributed to bravo | DETECTED both |
195
- | Fat sandbox (50 MB anon alloc) | meter reports over the 10 MB bar | DETECTED, 69.5 MB total |
196
-
197
- Notes: in `nonet` mode all file walls stayed green — only the network leaked, as designed. The hooked launcher's default path is proven unchanged (T1=200 with no `SBX_BREAK`). B1 stayed exit 6 even with host networking: this machine itself has no outbound internet/DNS, so M1's client matrix needs a local HTTPS upstream or a machine with internet.
198
-
199
- ### Gotchas found
200
-
201
- - Unix socket paths have a limit of about 108 characters. Use a short runtime dir.
202
- - Mounting the proxy socket needs a tmpfs over its target dir.
203
- - The bwrap root needs a `/lib64 -> usr/lib64` symlink or every dynamic binary fails with `No such file or directory` (the ELF interpreter path). Proven by red/green minimal repro in the M0 run.
204
- - Each sandbox holds 2 bwrap processes (supervisor + ns child) plus socat; count RSS per-PID-tree, and never `pgrep -f` the bridge string (bwrap parents match their own command line).
205
-
206
- ## 5. Decisions
207
-
208
- Signed off by the user.
209
-
210
- | Area | Decision |
211
- |---|---|
212
- | Platforms | Linux first (hackathon). macOS and Windows (via WSL2, which reuses the Linux build) come after. |
213
- | Stack | Node. bareguard (action gate: allow / ask / deny + audit log) and rwxmap (labels API operations r/w/x) run in-process in the proxy. mitmproxy (Python) is dropped. |
214
- | Walls | Our own thin walls on bubblewrap, not Anthropic's sandbox-runtime. See "Why own walls" below. |
215
- | Dropped for v1 | Landlock and custom seccomp. bwrap's own isolation is enough for a guardrail. They can return later. |
216
- | Undo layer (Linux) | bwrap overlay. Lower = real project, read-only. Upper = per-run tracing paper. Commands: diff, commit, rollback. |
217
- | Approvals | Second-terminal CLI (`sbx pending`, `sbx approve <id>`, deny) over a local unix socket. Timeout means deny. No web UI. |
218
- | Governance v1 | Single operator, one policy file per agent, one audit log. |
219
- | Secrets v1 | Injected in request headers only, after approval. A placeholder sits inside the sandbox. Body placeholder swap (for example `{{CARD}}` in a form body) is not v1. |
220
- | Localhost sockets (M0) | Blocked entirely. The net namespace isolates localhost; revisit treat-as-x in M3 only if a demo needs a local DB. |
221
- | Locked paths (M0) | `~/.ssh`, `~/secrets`, `~/.mozilla`, `~/.config/chromium`, `~/.gnupg`. More later without changing the walls. |
222
- | Browser agents + Jev | Out of v1. Demo A uses an API, not a browser. |
223
- | M0 harness | 20× idle sandboxes (`sleep` + `socat`, no real agent) for walls-only overhead ≤ 10 MB each; bypass set = unset proxy env, `--noproxy`, direct curl to IP. Real-agent and TLS memory come in M1/M6. |
224
-
225
- ### Why own walls (option B)
226
-
227
- | | srt (measured) | Own walls (measured) |
228
- |---|---|---|
229
- | Memory per sandbox | ~100 MB (Node 82 + socat ~12 + bash ~8) | ~8 MB (socat 4.1 + walls peak ~3.8) |
230
- | Proxy | one per sandbox | one shared |
231
- | Start time | 1.87 / 2.05 / 1.98 s | 0.02–0.03 s (walls only) |
232
- | 20 agents | ~2 GB | ~215 MB rough sum, proxy unmeasured |
233
- | Blocks work | yes | yes |
234
-
235
- Memory is priority 1, and the per-sandbox proxy is the cost. We build the thin walls ourselves (a launcher of about 50 lines). srt stays as prior art. We borrow these ideas from it:
236
-
237
- - An async per-request filter.
238
- - Credential masking.
239
- - `node-forge` for certificates (must pass the dependency checklist; see Open questions).
240
-
241
- Cost of this choice: we own the walls code and its upkeep.
242
-
243
- ## 6. Out of scope
244
-
245
- For the whole build. Core foundations first, all else is out of scope.
246
-
247
- - Not a defence against kernel exploits. Use a VM for that.
248
- - No Docker or VM.
249
- - No native Windows.
250
- - No cluster or k8s orchestration.
251
- - No cloud control plane.
252
- - No phone agents (baremobile).
253
- - No GraphQL or gRPC body parsing in v1.
254
- - No cert-pinned apps.
255
- - Non-HTTP egress is denied.
256
- - UDP is denied.
257
- - No web UI in v1.
258
- - No multi-user approvals, org roles or phone push in v1.
259
- - No Landlock or custom seccomp in v1.
260
- - No body placeholder swap in v1.
261
- - No personal-data-leaving rule (passport, date of birth, address).
262
- - No browser agents or on-screen action classifier (Jev) in v1.
263
-
264
- ## 7. Modules
265
-
266
- Order is dependency order. Each module is a POC aimed at its riskiest assumption. A module is done when it works alone and still works connected to everything built before it. Do not start N+1 while N is unproven.
267
-
268
- **M0, M1, M2 are the go/no-go.**
269
-
270
- ### M0. Walls + front door (Linux) [go/no-go]
271
-
272
- | | |
273
- |---|---|
274
- | Goal | An agent runs with locked paths, no network of its own, and one way out: a per-agent socket into the proxy. |
275
- | We use | bubblewrap, `socat`, Node. |
276
- | We build | bwrap launcher (about 50 lines). Locked paths. Per-agent unix socket into the proxy. The connection is the agent's identity, not a header it could fake. `socat` bridge inside. `HTTP_PROXY` / `HTTPS_PROXY` env. |
277
- | Riskiest assumption | Per-agent overhead stays <= 10 MB with N agents running at once. |
278
- | Done when | 20× idle sandboxes (`sleep` + `socat`) measured: walls-only overhead ≤ 10 MB each, bare proxy RSS recorded. Bypass set (unset proxy env, `--noproxy`, direct curl) all fail closed. |
279
- | Estimate | 0.5 day (mostly proven by the POCs above). |
280
-
281
- **Result (Oct 26): PASS.** 14/14 harness checks; max walls-only overhead 7.9 MB; bypass set fails closed. Go/no-go (a) part 1 met, (c) met for walls. POC stays throwaway; graduation rewrite deferred until M2 passes (M1 is the make-or-break).
282
-
283
- ### M1. Proxy sees inside HTTPS [go/no-go]
284
-
285
- | | |
286
- |---|---|
287
- | Goal | The proxy can read method, URL, headers and body of HTTPS requests. |
288
- | We use | `node-forge` (must pass the dependency checklist), Node `tls`. |
289
- | We build | A local CA that exists only inside the sandbox. Per-host certificates. Trust env vars: `SSL_CERT_FILE`, `NODE_EXTRA_CA_CERTS`, `REQUESTS_CA_BUNDLE`. Non-HTTP and UDP denied. |
290
- | Riskiest assumption | This is the hardest piece. Common clients must work through it, and proxy memory with TLS must stay <= 80 MB. |
291
- | Done when | curl, node, python requests and git over https all work through the proxy and the proxy can see inside. Proxy RSS with TLS is measured and compared with the 80 MB target. |
292
- | Estimate | 2 days. |
293
-
294
- ### M2. Hold and ask [go/no-go]
295
-
296
- | | |
297
- |---|---|
298
- | Goal | Park one x request, ask the human, keep everything else running. |
299
- | We use | Node, a local unix socket. |
300
- | We build | A hold queue. A notification. `sbx pending`, `sbx approve <id>`, `sbx deny <id>` over a unix socket. Timeout means deny, with a clear 403 reason (for example `403 denied by user: payment`). |
301
- | Riskiest assumption | Held requests don't break clients or servers on slow approvals. |
302
- | Done when | One request is held for a long approval while other requests from the same agent complete. Approve forwards it. Deny and timeout return the 403 with the reason. Tested with the M1 client set. |
303
- | Estimate | 1 day. |
304
-
305
- ### M3. Decide
306
-
307
- | | |
308
- |---|---|
309
- | Goal | The proxy decides r / w / x deterministically and logs every decision. |
310
- | We use | rwxmap (labels), bareguard (allow / ask / deny + audit log). |
311
- | We build | The glue and the deterministic rules from section 2: Luhn card numbers, CVV/expiry, payment domains and paths, unknown POST by mode (strict / normal). One policy file per agent. One audit log. |
312
- | Riskiest assumption | rwxmap labels and bareguard run in-process in the proxy without breaking the memory target. |
313
- | Done when | A scripted request set gets the expected decision for each rule, including a case that should not match. The audit log shows each decision. Proxy RSS re-measured with both libraries loaded. |
314
- | Estimate | 1–1.5 days. |
315
-
316
- ### M4. Undo layer
317
-
318
- | | |
319
- |---|---|
320
- | Goal | Every file write is reviewable and reversible. |
321
- | We use | bwrap overlay. |
322
- | We build | An overlay upper per run. `sbx diff`, `sbx commit`, `sbx rollback`. Handling of deletions (overlay whiteouts). Detection of files the user changed meanwhile: on conflict, refuse or flag. |
323
- | Riskiest assumption | Commit applies the upper layer to the real folder correctly, including deletions and files changed meanwhile. |
324
- | Done when | A run that edits, creates and deletes files commits to the correct result. Rollback leaves the folder as it was. A file changed by the user mid-run is flagged, not overwritten. |
325
- | Estimate | 1 day. |
326
-
327
- ### M5. Keys the agent never holds
328
-
329
- | | |
330
- |---|---|
331
- | Goal | The agent works with a placeholder. The real key never enters the sandbox. |
332
- | We build | A placeholder inside the sandbox. The real value is added to request headers only after approval. Per-agent credentials. |
333
- | Riskiest assumption | The key is never visible inside the sandbox (env, files, process list), and a denied request carries only the placeholder. |
334
- | Done when | An approved request reaches an API with the real header value. A denied one carries only the placeholder. A search of the sandbox for the real value finds nothing. |
335
- | Estimate | 0.5 day. |
336
-
337
- ### M6. Scale run
338
-
339
- | | |
340
- |---|---|
341
- | Goal | Check the memory targets at the real scale. |
342
- | What | 20 agents plus the shared proxy on one box, and on a 2 GB VPS if one is available. Compare with the memory targets. |
343
- | Note | If M0 and M1 measurements already cover this, fold it into them and record the numbers there. It is then not a separate step. |
344
- | Estimate | No separate estimate. It is part of the 9–10 day total. |
345
-
346
- ### M7. Demos, numbers, README
347
-
348
- | | |
349
- |---|---|
350
- | Demo A | Flight booking. Search runs free. Payment stops for approval. The key is never in the agent. Use an API whose key goes in a header, for example Stripe test mode. |
351
- | Demo B | A prompt-injected agent tries to read `~/.ssh` and push it out. Blocked. Good work is committed. Bad edits are rolled back. |
352
- | Numbers | Start time. Memory per agent. Prompts per task versus a stock agent setup. Blocked exfiltration attempts. |
353
- | Also | README. |
354
- | Estimate | 1.5 days. |
355
-
356
- ### Total
357
-
358
- About 9–10 days on Linux. This is tight for the hackathon.
359
-
360
- ## 8. Day-by-day plan (Oct 26 – Nov 4)
361
-
362
- This is a plan, not a result. It shifts as POCs return.
363
-
364
- | Day | Date | Work | Gate |
365
- |---|---|---|---|
366
- | 1 | Oct 26 | M0 (and M6 numbers for 20 sandboxes if trivial) | Go/no-go (a) part 1: bypass fails closed; per-agent overhead measured |
367
- | 2 | Oct 27 | M1 start: CA, per-host certs | |
368
- | 3 | Oct 28 | M1 finish: client matrix, proxy memory with TLS | Go/no-go (a) and (c) |
369
- | 4 | Oct 29 | M2: hold and ask | Go/no-go (b). All three pass, or stop. |
370
- | 5 | Oct 30 | M3: labels, gate, rules | |
371
- | 6 | Oct 31 | M3 finish. M4 start. | |
372
- | 7 | Nov 1 | M4 finish. M5. | |
373
- | 8 | Nov 2 | M6 scale run. M7 start (demo A). | Memory targets measured |
374
- | 9 | Nov 3 | M7: demos A and B, numbers | |
375
- | 10 | Nov 4 | M7: README, final checks, submission | |
376
-
377
- Nov 2 has room to spare and absorbs slips from earlier days. Nov 4 is the last day.
378
-
379
- ## 9. Later (after the hackathon)
380
-
381
- Not sorted into the 10 days.
382
-
383
- | Item | Note |
384
- |---|---|
385
- | macOS walls | `sandbox-exec` profile plus APFS clone (`cp -c`) for undo. No Mac available; needs a test machine (borrowed Mac or macOS CI runner) before it can start. About 1–1.5 days. |
386
- | Windows | Via WSL2. A test run of the Linux build. |
387
- | Body placeholder swap | For cards, for example `{{CARD}}` in a form body. |
388
- | Per-step snapshots | Per-step undo of the upper layer. |
389
- | Phone push approvals | |
390
- | Landlock / seccomp hardening | |
391
- | GraphQL / gRPC parsing | |
392
- | Llama end-of-run summary | Plain-language summary of the diff and audit log, flags off-task changes; model output treated as untrusted. Optional, not required for the hackathon. |
393
- | Go proxy rewrite | See the verdict below. |
394
-
395
- **Go verdict, verbatim:**
396
-
397
- > Verdict: Node, with no real contest. Go wins on memory and shipping. Node wins on reuse, and that reuse turns out to be large. Go could come back later as a rewrite of just the proxy, if measurements ever show memory is the bottleneck.
398
-
399
- ## 10. Known gaps
400
-
401
- - **Writes over sockets escape the overlay.** A local Postgres or Docker daemon is not a file. See Open questions.
402
- - **Commit conflicts.** If the user edits the same files during a run, M4 flags the conflict. It does not merge.
403
- - **Held requests can time out on the server side.** Holding happens before forwarding, so only the agent's client waits.
404
- - **Certificate pinning breaks inspection.** Out of scope.
405
- - **The proxy sees traffic, not intent.** Every API needs a mapping. File edits and local stdio MCP servers never touch the network. The undo layer and locked paths cover files. An MCP server running outside the sandbox with its own credentials is a hole.
406
-
407
- ## 11. Open questions
408
-
409
- None of these block M0. Nothing here is silently assumed.
410
-
411
- | # | Question | Decides |
412
- |---|---|---|
413
- | 1 | What is the real proxy memory with TLS, rwxmap and bareguard loaded? M0: bare proxy 52.1 MB (22 sockets, no TLS). TLS still unmeasured. | The <= 80 MB target. Measured in M1 and M3. |
414
- | 2 | `node-forge` or shelling out to `openssl` for certificates? | Dependency checklist, decided in M1. |
415
- | 3 | How should the undo layer handle large untracked dirs (`node_modules`) and build output? | M4 design. |
416
- | 4 | Localhost sockets (Postgres, Docker daemon) are writes the overlay can't see. Decided Oct 26 for M0: block. | M3 revisits only if a demo needs a local DB. |
417
- | 5 | Server-side timeouts while a request is held. How long can a hold last in practice? | The approval timeout value in M2. The idea note's sketch used 120 s; that is not tested. |
418
- | 6 | Working name. | Repo and CLI naming (`sbx` is a placeholder). |
@@ -1,218 +0,0 @@
1
- # Lightweight sandbox for agents
2
-
3
- > Working name: TBD. Status: idea / hackathon candidate (Meta Global AI Developer Hackathon, Oct 26 – Nov 4 2026).
4
- > One line: **an agent runs on your machine with your real tools, every write is undoable, and nothing leaves the machine without passing a doorman. You're asked only when something irreversible is about to happen.**
5
-
6
- ## Application pitch
7
-
8
- Agents are only useful when they get real access to your shell, files, network and wallet. Today developers pick between approving every action, which means forty prompts per task until they stop reading them or switch prompts off, and heavy isolation in Docker or a VM, which most people skip. Neither fits where the risk actually is. Reads are harmless, file writes can be fixed, and only a few actions can't be undone: paying, sending, publishing, pushing. We're building a lightweight sandbox that handles each of these differently. It runs on the developer's own Linux machine with no root, no daemon and no image, and the agent uses its real tools. Every file write lands on an undo layer that is committed or rolled back at the end. Secrets folders are locked. The agent has no internet of its own; its only way out is an egress proxy. The proxy lets lookups through, holds anything irreversible, and asks the human at that moment, while the rest of the agent keeps working. If an agent is asked to "find and book a flight under £450", it searches and compares freely and stops only twice: to pay, and to send the itinerary.
9
-
10
- The core idea is capability without custody. The agent never holds the card or the API keys. It types placeholders, and the proxy fills in the real values only after the human approves that specific request. A hijacked or mistaken agent therefore has nothing to leak or spend. Decisions are deterministic: detected card numbers, known payment services, and operation labels from rwxmap. A fast classifier labels on-screen actions for browser and phone agents. Meta's Llama reads the full set of changes at the end of each run and explains in plain language what changed and what looks off-task. We'll measure prompts per task against standard agent setups, start-up time, and blocked exfiltration attempts. We'll ship it as an open-source tool any agent framework can run inside.
11
-
12
- ## The problem
13
-
14
- Agents need real access to be useful: your shell, your files, the network. Today you choose between:
15
-
16
- - **Approve everything.** 40 prompts per task, so people stop reading them, or turn them off (`--dangerously-skip-permissions`).
17
- - **Heavy isolation.** Docker or a VM: images to build, a daemon, root, and the agent can't use your installed toolchain.
18
-
19
- Neither matches what's actually risky. Reading is mostly harmless. Writing files is risky but *fixable*. Sending, paying, publishing and pushing are the only things that *can't be taken back*.
20
-
21
- ## The idea: r / w / x, each handled differently
22
-
23
- Same three letters as rwxmap and bareguard:
24
-
25
- | Letter | Meaning | What the sandbox does | You're asked? |
26
- |---|---|---|---|
27
- | **r** | reads, changes nothing | lets it through (except locked paths) | never |
28
- | **w** | changes things, can be set back | records it on an undo layer | once, at the end (review the diff) |
29
- | **x** | can't be undone: send, pay, publish, push, delete remote | holds it at the door until you decide | **at the moment it happens** |
30
-
31
- So the agent is **not** blocked on every action. It runs freely, and you're interrupted only when an x is triggered. Everything else is either harmless (r) or reversible (w).
32
-
33
- ## How it works, in simple terms
34
-
35
- Picture the agent working in your house:
36
-
37
- 1. **Tracing paper (w).** The agent sees your real files, but everything it changes goes on tracing paper laid over them. At the end you look at the tracing paper and press it down (**commit**) or throw it away (**rollback**).
38
- 2. **Locked drawers (r).** It can read most things. Some drawers are locked and can't even be opened: `~/.ssh`, `~/secrets`, browser profiles, password stores.
39
- 3. **One front door with a doorman (x).** The agent has no internet of its own. The only way out is through the doorman, who waves through lookups and holds anything that sends, pays or publishes until you say yes.
40
-
41
- ## How it's built (Linux, no root, no Docker)
42
-
43
- ```
44
- agent process (your real node, python, git, browser)
45
- │
46
- ┌─────┴──────────────── user namespace (unprivileged) ─────────────┐
47
- │ files: overlayfs lower = real ~/project (read only) │
48
- │ upper = /scratch/run-42 (all writes land) │
49
- │ Landlock: ~/.ssh, ~/secrets, browser profiles → unreadable │
50
- │ seccomp: no ptrace, mount, kernel modules │
51
- │ network: own namespace, no internet; only route = the proxy │
52
- └─────┬─────────────────────────────────────────────────────────────┘
53
- │ (unix socket bridged in, HTTP_PROXY / HTTPS_PROXY set)
54
- ▼
55
- egress proxy (mitmproxy + policy script → bareguard)
56
- ├── r → forward
57
- ├── x → hold the request, ask the human, forward or reject
58
- └── unknown → per-mode default (see Policy)
59
- ```
60
-
61
- | Piece | Job | Off-the-shelf part |
62
- |---|---|---|
63
- | Namespaces + overlay | tracing paper, private network | `bubblewrap` (`bwrap`) |
64
- | Landlock | locked drawers | `landrun` or a Python binding |
65
- | seccomp | no escaping via kernel tricks | `bwrap` seccomp filter |
66
- | Egress proxy | the doorman | `mitmproxy` (scriptable, sees inside HTTPS) |
67
- | Decision | allow / ask / deny + audit log | bareguard |
68
- | Labels | what an operation does | rwxmap (APIs), Jev (fast UI/text labels) |
69
- | Review | commit / rollback the diff | new code |
70
- | Model | end-of-run plain-language summary of the diff, flags off-task changes | Llama via Meta Model API |
71
-
72
- **The egress proxy, briefly.** The network namespace has no route out except the proxy, so anything that ignores the proxy settings simply fails (fails closed). The proxy trusts a CA certificate that exists *only inside the sandbox* (`SSL_CERT_FILE`, `NODE_EXTRA_CA_CERTS`, `REQUESTS_CA_BUNDLE`), so it can see method, URL and body of HTTPS requests. Your real system never trusts that CA. Non-HTTP traffic (`git push` over SSH, raw TCP) is denied by default, or allowed through a SOCKS rule as an x. UDP is blocked, which forces HTTP/3 clients back to HTTP/2 where the proxy can see them.
73
-
74
- ## When does it stop and ask?
75
-
76
- **Only when an x is triggered.** The proxy holds that one request open, sends you an approval prompt (terminal, or a push to your phone), and waits:
77
-
78
- - **Approve** → the request goes out unchanged; the agent gets the real response.
79
- - **Deny / timeout** → the agent gets a clear refusal (e.g. `403 denied by user: payment`) and can carry on or stop.
80
-
81
- While one request is held, the rest of the agent keeps running.
82
-
83
- ## Walkthrough: "find and book me a flight to Barcelona under £450"
84
-
85
- | Step | What the agent does | Network | Letter | You see |
86
- |---|---|---|---|---|
87
- | 1 | Reads your saved travel prefs file | none | r | nothing |
88
- | 2 | Searches flights (API or website) | `GET`/search `POST` to airline, aggregator | r | nothing |
89
- | 3 | Compares fares, writes `notes/barcelona.md` | none (file write → tracing paper) | w | nothing yet |
90
- | 4 | Selects a fare, fills passenger details | `POST` form / offer request | w-ish (see below) | nothing, or one ask per new site in strict mode |
91
- | 5 | **Pays** | `POST` to `/orders`, a checkout endpoint, or a payment processor | **x** | **"Pay £412.30 to Vueling — LHR→BCN 12 Nov, 1 adult. Approve?"** |
92
- | 6 | Emails you the itinerary | `POST` to mail API / SMTP | **x** | "Send email to you@… — subject 'Your Barcelona flight'. Approve?" |
93
- | 7 | Run ends | — | — | Diff review: `notes/barcelona.md` added. Commit / rollback. Llama summary of what changed. |
94
-
95
- So for this task you'd be interrupted **twice** (pay, send), not forty times.
96
-
97
- ### The hard part: telling "search" from "pay" at the network level
98
-
99
- The proxy sees requests, not intent, and websites use `POST` for both searching and paying. So `GET = r, POST = x` is too crude. The doorman uses layered, deterministic rules, strongest first:
100
-
101
- 1. **Card data in the body → always x.** Any 13–19 digit number that passes the Luhn check, or a CVV/expiry field, in an outgoing request. No guessing needed.
102
- 2. **Payment destinations → always x.** `api.stripe.com`, `*.adyen.com`, `*.paypal.com`, `*.braintreegateway.com`, `checkout.*`, paths like `/checkout`, `/payment`, `/orders`, `/purchase`.
103
- 3. **Known APIs → rwxmap labels.** e.g. for a flight API: create offer request / search = r, create order = x.
104
- 4. **Your personal data leaving → ask.** Passport number, date of birth, home address (from a local profile) appearing in a request body to a new destination.
105
- 5. **Unknown POST → mode default.** Strict: ask once per new domain, then remember for the run. Normal: allow and log. (Jev can classify an unknown endpoint + body summary as r/w/x in milliseconds when you want a smarter default.)
106
-
107
- For browser agents (barebrowse / baremobile), a second signal comes from the screen: Jev labels the button about to be pressed ("Pay now" = x). The network rule is the backstop that can't be fooled by a misleading button label.
108
-
109
- ### Better: the agent never holds the card
110
-
111
- Capability without custody: the agent fills payment fields with a **placeholder** (`{{CARD}}`). The proxy swaps in the real card details **only after you approve**, at the moment the request leaves. The agent can't leak, misuse or be tricked into spending a card it never had. A denied payment can't happen by accident, because without approval the request carries only a placeholder the merchant rejects.
112
-
113
- Same trick works for other secrets: API keys and tokens live in the proxy, not in the agent's environment.
114
-
115
- ## Per-agent access: roles at the door, not in every tool
116
-
117
- A common pattern today is one MCP server per agent, each loaded with roles, or a policy engine checking tool calls. The proxy can do the same job at finer detail, and in a place the agent can't get around.
118
-
119
- ### How the proxy does fine-grained access
120
-
121
- 1. **It knows which agent is calling.** Each agent runs in its own sandbox with its own private connection to the proxy. The proxy knows who's calling from *which connection the request arrived on*, not from a header the agent could fake.
122
- 2. **Rules can be as narrow as you want:**
123
-
124
- ```yaml
125
- agent: support-bot
126
- github.com:
127
- r: issues, comments # allow
128
- w: comment on issues # allow
129
- x: close issue # ask
130
- x: merge, delete, admin # deny
131
- repos: [acme/helpdesk] # only this repo
132
- agent: travel-bot
133
- payments:
134
- x: pay # ask, ≤ £500, merchants: airlines only
135
- ```
136
-
137
- 3. **rwxmap is the vocabulary.** It turns a raw request like `PUT /repos/acme/x/pulls/12/merge` into "merge a pull request = x". Without that mapping, people end up writing rules about URL patterns, which is where policy setups get unwieldy.
138
- 4. **The proxy holds the keys.** Each agent's credentials live in the proxy and are added to the request on the way out. An agent can't use another agent's credentials, and one shared token (e.g. GitHub) can be narrowed per agent beyond what the token itself allows.
139
-
140
- ### Compared with MCP-per-agent and policy-based setups
141
-
142
- | | MCP per agent with roles | Policy-based (OPA/Cedar, MCP gateways) | Egress proxy with r/w/x |
143
- |---|---|---|---|
144
- | Where it's checked | inside each MCP server | in a central policy engine, usually at the tool-call layer | at the network exit the agent can't get around |
145
- | **Can the agent bypass it?** | **Yes**, if it also has a shell or HTTP (it can just `curl` the API) | **Usually yes**, for the same reason | **No.** Its sandbox has no other route out |
146
- | Covers | only traffic that goes through MCP | only traffic that goes through the gateway | everything: MCP, SDKs, `curl`, browsers |
147
- | Detail level | which tools the agent can see; arguments rarely checked | depends on hand-written rules per tool | operation, resource and limits (amount, repo, recipient) |
148
- | Credentials | often sit in each MCP server, shared across agents | varies | held by the proxy, one set per agent, added only on approval |
149
- | Sprawl | agents × servers × roles | one policy engine, but rules per tool | one proxy, one policy file, one audit log |
150
- | Ask a human mid-task | rare | rare | built in: the request is held at that moment |
151
-
152
- **The key point:** an MCP role check only means something if the agent has *no other way* to reach the API. When the role lives in the tool but the agent's network stays open, the check works like a suggestion. The proxy works because the sandbox's network makes it the only way out.
153
-
154
- ### Where the proxy is weaker
155
-
156
- - **It sees HTTP traffic, not what the agent meant to do.** Every API needs a mapping. rwxmap covers REST well. GraphQL and gRPC need the request body parsed, since one endpoint does many things.
157
- - **It needs to see inside HTTPS.** That relies on the sandbox-only certificate; apps that pin their certificates break.
158
- - **It can't see local actions.** File edits and local MCP servers talking over stdio never touch the network. The sandbox's file layer (undo layer, locked folders) covers those.
159
- - **An MCP server running *outside* the sandbox with its own credentials is a hole.** Run it inside the sandbox so its traffic goes through the proxy too.
160
-
161
- ### Combine them
162
-
163
- - **The proxy** is where rules are enforced.
164
- - **A policy engine (Cedar or OPA)** can make the decisions if a company already uses one.
165
- - **rwxmap** supplies the labels.
166
- - **MCP** stays as the convenient way agents call tools, with the real enforcement at the door.
167
-
168
- ## Policy (sketch)
169
-
170
- ```yaml
171
- mode: strict # strict | normal | relaxed
172
- locked_paths: [~/.ssh, ~/secrets, ~/.mozilla, ~/.config/chromium, ~/.gnupg]
173
- network:
174
- always_x:
175
- domains: [api.stripe.com, "*.adyen.com", "*.paypal.com"]
176
- paths: ["/checkout", "/payment", "/orders", "/purchase"]
177
- body: [card_number_luhn, cvv]
178
- allow_r:
179
- domains: [api.duffel.com, "*.skyscanner.net"]
180
- unknown_post: ask_once_per_domain # strict
181
- non_http: deny
182
- udp: deny
183
- secrets:
184
- CARD: from_keyring # injected by proxy after approval
185
- approval:
186
- channel: terminal # or phone push
187
- timeout: 120s → deny
188
- end_of_run:
189
- diff_review: true
190
- summary_model: llama # Meta Model API
191
- ```
192
-
193
- ## What it is and isn't
194
-
195
- - **Is:** a strong guardrail against mistakes and prompt-injected agents, with near-zero setup and millisecond start.
196
- - **Isn't:** a security boundary against a determined attacker. The kernel is shared; a kernel exploit escapes. Use a VM for that.
197
- - **Prior art:** the blocking part exists (bubblewrap, firejail, Claude Code's and Codex's sandboxes). New here: **undo layer + r/w/x-aware doorman + held-request approval + secrets injected only on approval + end-of-run diff review.**
198
-
199
- ## Known gaps
200
-
201
- - **Writes over sockets escape the overlay.** A local Postgres or Docker daemon isn't a file. Treat localhost sockets as x, or block them.
202
- - **Commit conflicts** if you edited the same files while the agent ran → needs a 3-way merge.
203
- - **Held requests can time out** on the server side if you approve slowly. Holding happens *before* forwarding, so only the agent's client waits; set a long client timeout.
204
- - **Certificate pinning** breaks inspection for some clients (rare for CLIs, common for mobile apps).
205
- - **Linux only.** macOS has no overlayfs or Landlock.
206
-
207
- ## 10-day plan (modules, each a POC)
208
-
209
- 1. `bwrap` + overlay run; commit / rollback of the upper layer.
210
- 2. Landlock locked paths.
211
- 3. Network namespace + mitmproxy as the only route out; fails closed.
212
- 4. Policy script → bareguard: always-x rules, held-request approval (terminal first).
213
- 5. Placeholder secrets injected on approval.
214
- 6. Per-step snapshots of the upper layer (per-step undo).
215
- 7. End-of-run diff review + Llama summary.
216
- 8. Demo A: flight booking — search runs free, payment stops for approval, card never in the agent.
217
- 9. Demo B: prompt-injected agent tries to read `~/.ssh` and push it out — both blocked; useful work committed, bad edits rolled back.
218
- 10. README, numbers (start time, prompts per task vs. stock), video.
package/poc/m0/README.md DELETED
@@ -1,20 +0,0 @@
1
- # M0 POC: walls + front door (+ red-team)
2
-
3
- Throwaway spike, not shipped. Proves the go/no-go for M0: per-agent overhead
4
- ≤ 10 MB with 20 concurrent sandboxes, and bypass attempts fail closed.
5
- Full results: [agent-sandbox-prd.md](../../docs/product/agent-sandbox-prd.md).
6
-
7
- - `proxy.js` — dumb forward + CONNECT proxy on per-agent unix sockets (allow-all)
8
- - `launch.sh` — bwrap launcher: ro binds, tmpfs locked paths, net/pid/uts/ipc
9
- namespaces, socat bridge to `127.0.0.1:3128`. `SBX_BREAK=nonet|nolock|rw`
10
- are red-team-only hooks
11
- - `measure.js` — exact RSS per sandbox process tree from `/proc`
12
- - `run-m0.sh` — main harness, 14 checks, exits nonzero on failure
13
- - `redteam.sh` — breaks each wall on purpose; passes iff every break is detected
14
- - `measure.txt`, `proxy.log`, `func-*.txt`, `red-*.txt` — evidence from the passing runs
15
-
16
- Run: `npm run poc:m0`, `npm run redteam:m0`. Both need an unsandboxed shell
17
- (listening sockets, namespaces) and print PASS/FAIL with evidence.
18
-
19
- Runtime dir stays `/tmp/sbx-m0` by design: unix socket paths cap at ~108 chars.
20
- Only code, docs, and evidence live here.