You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add process isolation and persistent sessions for all commands (#59)
* Add process isolation for sandbox commands
Implements PID namespace isolation to protect control plane processes (Jupyter, Bun)
from sandboxed code. Commands executed via exec() now run in isolated namespaces.
Key changes:
- Sandboxed commands can no longer see or kill control plane processes
- Platform secrets in /proc/1/environ are inaccessible
- Ports 8888 (Jupyter) and 3000 (Bun) are protected from hijacking
- Commands within sessions now maintain state (pwd, env vars)
- Graceful fallback when CAP_SYS_ADMIN not available (dev environments)
BREAKING CHANGE: Commands within the same session now share state. Previously each
command was stateless. Use createSession() for isolated command execution.
* Stop information exposure through stack trace
* Implement secure streaming execution with ExecutionSession support
- Fix streaming security hole by routing through SessionManager instead of direct spawn()
- Add ExecutionSession.execStream() method for secure real-time command streaming
- Maintain backward compatibility by bridging sessionId API to ExecutionSessions
- Extend SessionManager with streaming capabilities using isolated control processes
* Remove sessionId
* Make file ops session-aware too
* Remove duplicate code paths
* Fix streaming and corresponding abort
* Fix log fetch endpoint
* Minor fixes
* Rename back to sessionId
* Fix pending name references
* Move control script into separate file
* Fix type errors
* fix biome lint errors
* Prevent shell command injection
* Move code around
* Reorganise code
* Update changeset
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.
8
+
9
+
**Key security improvements:**
10
+
- Control plane processes are hidden from sandboxed commands
11
+
- Platform secrets in `/proc/1/environ` are inaccessible
12
+
- Ports 8888 (Jupyter) and 3000 (Bun) are protected from hijacking
13
+
14
+
**Breaking changes:**
15
+
16
+
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.
2.**Commands now maintain state**: Commands within the same sandbox now share state (working directory, environment variables, background processes). Previously each command was stateless.
27
+
28
+
```javascript
29
+
// Before: each exec was independent
30
+
awaitsandbox.exec("cd /app");
31
+
awaitsandbox.exec("pwd"); // Output: /workspace
32
+
33
+
// After: state persists in session
34
+
awaitsandbox.exec("cd /app");
35
+
awaitsandbox.exec("pwd"); // Output: /app
36
+
```
37
+
38
+
**Migration guide:**
39
+
- Remove `sessionId` from all method calls - each sandbox maintains its own session
40
+
- If you need isolated execution contexts within the same sandbox, use `sandbox.createSession()`:
41
+
```javascript
42
+
// Create independent sessions with different environments
43
+
constbuildSession=awaitsandbox.createSession({
44
+
name:"build",
45
+
env: { NODE_ENV:"production" },
46
+
cwd:"/build"
47
+
});
48
+
consttestSession=awaitsandbox.createSession({
49
+
name:"test",
50
+
env: { NODE_ENV:"test" },
51
+
cwd:"/test"
52
+
});
53
+
```
54
+
- Environment variables set in one command persist to the next
55
+
- Background processes remain active until explicitly killed
56
+
- Requires CAP_SYS_ADMIN (available in production, falls back gracefully in dev)
0 commit comments