|
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,29 @@ 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, also add it to `workerLimitsEnv()` and to |
| 78 | + `CLIENT_WORKER_ENV_KEYS` in `isolated-vm-host.cjs`, so a remote worker |
| 79 | + enforces 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 and the `isolated-vm-remote-workers` |
| 88 | +flag is on, as a WebSocket connection to `isolated-vm-host.cjs`, which runs the |
| 89 | +same worker in a dedicated service that holds no platform credentials. Every |
| 90 | +rule in this file applies in both modes. |
| 91 | + |
| 92 | +- `fetch()` and brokers always run in the app. The host only relays the |
| 93 | + worker's messages, so it needs no network access of its own and never gets |
| 94 | + a broker implementation. |
| 95 | +- A remote target never falls back to a local child process. An unreachable |
| 96 | + host fails executions with a system error; keep it that way. |
| 97 | +- Changes to the worker message protocol must stay compatible with the |
| 98 | + previous release: the host and its clients roll out independently. |
77 | 99 |
|
78 | 100 | ## What the worker *may* hold |
79 | 101 |
|
|
0 commit comments