|
1 | 1 | --- |
2 | 2 | description: "Isolated-vm sandbox worker security policy. Hard rules for anything that lives in the worker child process that runs user code." |
3 | | -globs: ["apps/sim/lib/execution/isolated-vm-worker.cjs","apps/sim/lib/execution/isolated-vm.ts","apps/sim/lib/execution/sandbox/**","apps/sim/sandboxes/**"] |
| 3 | +globs: ["apps/sim/lib/execution/isolated-vm-worker.cjs","apps/sim/lib/execution/isolated-vm-host.cjs","apps/sim/lib/execution/isolated-vm-remote.ts","apps/sim/lib/execution/isolated-vm.ts","apps/sim/lib/execution/sandbox/**","apps/sim/sandboxes/**"] |
4 | 4 | --- |
5 | 5 |
|
6 | 6 | <!-- Generated from .claude/rules/sim-sandbox.md by `bun run skills:sync`. Edit the source, not this file. --> |
@@ -73,7 +73,31 @@ payload or `ivm.Reference` wrapper in the worker: |
73 | 73 | - [ ] Does the worker read a new env var? Add it to the `buildWorkerEnv()` |
74 | 74 | allowlist in `isolated-vm.ts` **and** to the allowlist regression test in |
75 | 75 | `isolated-vm.test.ts` — the worker does not inherit the app environment, |
76 | | - so an un-allowlisted var is simply absent in the child. |
| 76 | + so an un-allowlisted var is simply absent in the child. If the app owns |
| 77 | + its value, put it in `appWorkerEnv()` and add it with its accepted shape |
| 78 | + to `CLIENT_WORKER_ENV` in `isolated-vm-host.cjs`, so a remote worker |
| 79 | + gets the same value. |
| 80 | +- [ ] Does the host send the worker a new message type? Add it to |
| 81 | + `ALLOWED_INBOUND_TYPES` in `isolated-vm-host.cjs`, or remote workers |
| 82 | + never receive it. |
| 83 | + |
| 84 | +## Where the worker runs |
| 85 | + |
| 86 | +The pool in `isolated-vm.ts` opens each worker either as a local child process |
| 87 | +or, when `IVM_REMOTE_WORKER_URL` is set (with `IVM_REMOTE_WORKER_TOKEN`; a URL |
| 88 | +without a valid token fails executions rather than falling back) and the |
| 89 | +`isolated-vm-local-workers` kill switch is off, as a WebSocket connection to |
| 90 | +`isolated-vm-host.cjs`, which runs the |
| 91 | +same worker in a dedicated service that holds no platform credentials. Every |
| 92 | +rule in this file applies in both modes. |
| 93 | + |
| 94 | +- `fetch()` and brokers always run in the app. The host only relays the |
| 95 | + worker's messages, so it needs no network access of its own and never gets |
| 96 | + a broker implementation. |
| 97 | +- A remote target never falls back to a local child process. An unreachable |
| 98 | + host fails executions with a system error; keep it that way. |
| 99 | +- Changes to the worker message protocol must stay compatible with the |
| 100 | + previous release: the host and its clients roll out independently. |
77 | 101 |
|
78 | 102 | ## What the worker *may* hold |
79 | 103 |
|
|
0 commit comments