|
1 | 1 | # @cloudflare/sandbox |
2 | 2 |
|
| 3 | +## 0.3.0 |
| 4 | + |
| 5 | +### Minor Changes |
| 6 | + |
| 7 | +- [#59](https://github.com/cloudflare/sandbox-sdk/pull/59) [`b6757f7`](https://github.com/cloudflare/sandbox-sdk/commit/b6757f730c34381d5a70d513944bbf9840f598ab) Thanks [@ghostwriternr](https://github.com/ghostwriternr)! - Add process isolation for sandbox commands |
| 8 | + |
| 9 | + Implements PID namespace isolation to protect control plane processes (Jupyter, Bun) from sandboxed code. Commands executed via `exec()` now run in isolated namespaces that cannot see or interact with system processes. |
| 10 | + |
| 11 | + **Key security improvements:** |
| 12 | + |
| 13 | + - Control plane processes are hidden from sandboxed commands |
| 14 | + - Platform secrets in `/proc/1/environ` are inaccessible |
| 15 | + - Ports 8888 (Jupyter) and 3000 (Bun) are protected from hijacking |
| 16 | + |
| 17 | + **Breaking changes:** |
| 18 | + |
| 19 | + 1. **Removed `sessionId` parameter**: The `sessionId` parameter has been removed from all methods (`exec()`, `execStream()`, `startProcess()`, etc.). Each sandbox now maintains its own persistent session automatically. |
| 20 | + |
| 21 | + ```javascript |
| 22 | + // Before: manual session management |
| 23 | + await sandbox.exec("cd /app", { sessionId: "my-session" }); |
| 24 | + |
| 25 | + // After: automatic session per sandbox |
| 26 | + await sandbox.exec("cd /app"); |
| 27 | + ``` |
| 28 | + |
| 29 | + 2. **Commands now maintain state**: Commands within the same sandbox now share state (working directory, environment variables, background processes). Previously each command was stateless. |
| 30 | + |
| 31 | + ```javascript |
| 32 | + // Before: each exec was independent |
| 33 | + await sandbox.exec("cd /app"); |
| 34 | + await sandbox.exec("pwd"); // Output: /workspace |
| 35 | +
|
| 36 | + // After: state persists in session |
| 37 | + await sandbox.exec("cd /app"); |
| 38 | + await sandbox.exec("pwd"); // Output: /app |
| 39 | + ``` |
| 40 | + |
| 41 | + **Migration guide:** |
| 42 | + |
| 43 | + - Remove `sessionId` from all method calls - each sandbox maintains its own session |
| 44 | + - If you need isolated execution contexts within the same sandbox, use `sandbox.createSession()`: |
| 45 | + ```javascript |
| 46 | + // Create independent sessions with different environments |
| 47 | + const buildSession = await sandbox.createSession({ |
| 48 | + name: "build", |
| 49 | + env: { NODE_ENV: "production" }, |
| 50 | + cwd: "/build", |
| 51 | + }); |
| 52 | + const testSession = await sandbox.createSession({ |
| 53 | + name: "test", |
| 54 | + env: { NODE_ENV: "test" }, |
| 55 | + cwd: "/test", |
| 56 | + }); |
| 57 | + ``` |
| 58 | + - Environment variables set in one command persist to the next |
| 59 | + - Background processes remain active until explicitly killed |
| 60 | + - Requires CAP_SYS_ADMIN (available in production, falls back gracefully in dev) |
| 61 | + |
| 62 | +### Patch Changes |
| 63 | + |
| 64 | +- [#62](https://github.com/cloudflare/sandbox-sdk/pull/62) [`4bedc3a`](https://github.com/cloudflare/sandbox-sdk/commit/4bedc3aba347f3d4090a6efe2c9778bac00ce74a) Thanks [@ghostwriternr](https://github.com/ghostwriternr)! - Fix broken build due to bun lockfile not being used |
| 65 | + |
3 | 66 | ## 0.2.4 |
4 | 67 |
|
5 | 68 | ### Patch Changes |
|
0 commit comments