@erichll/pi-sandbox 0.22.1 → 0.23.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.
- package/CHANGELOG.md +17 -0
- package/README.md +46 -5
- package/package.json +2 -2
- package/src/config.ts +42 -7
- package/src/index.ts +8 -3
- package/src/policy.ts +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.23.0 - 2026-10-02
|
|
4
|
+
|
|
5
|
+
- Add opt-in `network.strictAllowlist` (default `false`) to deny unmatched
|
|
6
|
+
destinations without model or human approval. Forward the setting to Sandbox
|
|
7
|
+
Runtime for Bash and built-in workers, including persistent follow-up and
|
|
8
|
+
nested handoff.
|
|
9
|
+
- Merge global/project strict mode with logical OR while retaining domain-list
|
|
10
|
+
unions. Both files remain trusted policy sources: projects can add endpoints
|
|
11
|
+
but cannot disable globally required strict enforcement.
|
|
12
|
+
- Reject strict mode combined with Host-IPC `ask` after configuration merging
|
|
13
|
+
and embedding overrides. Keep non-strict approval and host forwarding behavior.
|
|
14
|
+
- Require `@erichll/pi-auto-review` `^0.23.0` for current-session review models
|
|
15
|
+
and full-command execution-context validation.
|
|
16
|
+
- Cover real Linux broker network enforcement, persistent worker lifecycle and
|
|
17
|
+
startup failures with synthetic endpoints; isolate configuration tests from
|
|
18
|
+
the developer's working directory.
|
|
19
|
+
|
|
3
20
|
## 0.22.1 - 2026-10-01
|
|
4
21
|
|
|
5
22
|
- Fix sandboxed Bash on Bun-compiled Pi: launching the Sandbox Runtime broker
|
package/README.md
CHANGED
|
@@ -157,6 +157,7 @@ Domain authorization can be configured globally at
|
|
|
157
157
|
```json
|
|
158
158
|
{
|
|
159
159
|
"network": {
|
|
160
|
+
"strictAllowlist": false,
|
|
160
161
|
"allowedDomains": [
|
|
161
162
|
"github.com",
|
|
162
163
|
"*.github.com",
|
|
@@ -179,14 +180,50 @@ The precedence is deterministic:
|
|
|
179
180
|
|
|
180
181
|
1. A matching `deniedDomains` entry rejects the connection.
|
|
181
182
|
2. Otherwise, a matching `allowedDomains` entry permits it without review.
|
|
182
|
-
3. Otherwise,
|
|
183
|
+
3. Otherwise, if `strictAllowlist` is `true`, the connection is denied without
|
|
184
|
+
invoking the Runtime ask callback, model review, or human approval.
|
|
185
|
+
4. Otherwise, the canonical public hostname and port enter the existing
|
|
183
186
|
one-shot auto-review or human approval flow.
|
|
184
187
|
|
|
185
|
-
Both arrays default to empty
|
|
186
|
-
|
|
187
|
-
|
|
188
|
+
Both arrays default to empty and `strictAllowlist` defaults to `false`, preserving
|
|
189
|
+
the existing per-connection approval behavior. The setting accepts only a boolean.
|
|
190
|
+
With strict mode and an empty allowlist, all proxied destinations are denied.
|
|
191
|
+
`deniedDomains: ["*"]` also blocks allowed entries because deny rules take priority.
|
|
192
|
+
The same network policy governs main-agent Bash, user Bash, built-in subagents, and the
|
|
188
193
|
sandboxed Bash tool loaded by protected native `pi-subagents` children.
|
|
189
194
|
|
|
195
|
+
For a worker restricted to explicitly approved inference endpoints:
|
|
196
|
+
|
|
197
|
+
```json
|
|
198
|
+
{
|
|
199
|
+
"subagents": { "provider": "builtin" },
|
|
200
|
+
"network": {
|
|
201
|
+
"strictAllowlist": true,
|
|
202
|
+
"allowedDomains": ["inference.example.com:443"],
|
|
203
|
+
"deniedDomains": []
|
|
204
|
+
},
|
|
205
|
+
"hostIPC": { "mode": "off" }
|
|
206
|
+
}
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
Replace the example hostname with your approved endpoint. Global and project
|
|
210
|
+
`strictAllowlist` values merge with logical OR: a project cannot disable strict
|
|
211
|
+
mode required globally. Domain lists still form unions, so a project **can add
|
|
212
|
+
allowed destinations**. Both files are trusted policy inputs; the global allowlist
|
|
213
|
+
is not an administrative upper bound on project permissions.
|
|
214
|
+
|
|
215
|
+
Strict mode cannot be combined with `hostIPC.mode: "ask"`, since host execution
|
|
216
|
+
would escape the network sandbox. The effective configuration is rejected before
|
|
217
|
+
tools or workers are created; set Host-IPC mode to `off`. This is checked after
|
|
218
|
+
global/project merging, and again after an embedding's Host-IPC override.
|
|
219
|
+
|
|
220
|
+
Configuration is loaded when the extension is registered. Existing persistent
|
|
221
|
+
workers keep their policy through follow-up, and handoff workers receive the same
|
|
222
|
+
configured policy. Reload the extension and create new workers to apply file
|
|
223
|
+
changes; there is no configuration hot reload. Broker startup failure never retries
|
|
224
|
+
the worker outside the sandbox, and unavailable approval services cannot relax a
|
|
225
|
+
strict network denial.
|
|
226
|
+
|
|
190
227
|
Domain allowlists are not a complete data-loss-prevention boundary. A
|
|
191
228
|
multi-tenant or user-uploadable destination such as `github.com` can itself be
|
|
192
229
|
an exfiltration channel; grant only the narrow domains and ports you intend.
|
|
@@ -229,7 +266,7 @@ approval warns that the first attempt may already have had partial side
|
|
|
229
266
|
effects. Successful, timed-out, or aborted commands are never retried.
|
|
230
267
|
|
|
231
268
|
Host forwarding is intentionally unavailable inside built-in subagents in
|
|
232
|
-
this version.
|
|
269
|
+
this version. It is also incompatible with `network.strictAllowlist: true`.
|
|
233
270
|
|
|
234
271
|
## Additional trusted read paths
|
|
235
272
|
|
|
@@ -269,8 +306,12 @@ In addition to user-level configuration at `~/.pi/agent/extensions/pi-sandbox/co
|
|
|
269
306
|
```
|
|
270
307
|
|
|
271
308
|
When present, project configuration is merged with global configuration:
|
|
309
|
+
|
|
272
310
|
- Array policies (`additionalAllowRead`, `allowedDomains`, `deniedDomains`, `preflightCommandPrefixes`) form a deduplicated union.
|
|
273
311
|
- Scalar settings (`provider`, `mode`, `retryOnUnixSocketError`) allow project-level overrides.
|
|
312
|
+
- `network.strictAllowlist` uses logical OR: `true` in either file enables it.
|
|
313
|
+
Both configuration files are trusted; project allowlist additions remain effective.
|
|
314
|
+
- The merged configuration must not enable both strict allowlist and Host-IPC `ask`.
|
|
274
315
|
|
|
275
316
|
**Read-only Security Guarantee**:
|
|
276
317
|
Project-level configuration is explicitly protected in the sandbox policy (`denyWrite`),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@erichll/pi-sandbox",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.0",
|
|
4
4
|
"description": "Linux (bubblewrap) and macOS (Seatbelt) process sandbox for Pi backed by Anthropic's @anthropic-ai/sandbox-runtime. Fail-closed static filesystem policy plus per-connection network approval from pi-auto-review; sandboxes main-agent Bash and built-in subagent process trees.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"@anthropic-ai/sandbox-runtime": "^0.0.77",
|
|
54
|
-
"@erichll/pi-auto-review": "^0.
|
|
54
|
+
"@erichll/pi-auto-review": "^0.23.0",
|
|
55
55
|
"jiti": "2.7.0"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
package/src/config.ts
CHANGED
|
@@ -23,6 +23,8 @@ export type HostIPCConfig = {
|
|
|
23
23
|
export type NetworkConfig = {
|
|
24
24
|
readonly allowedDomains: readonly string[];
|
|
25
25
|
readonly deniedDomains: readonly string[];
|
|
26
|
+
/** Deny unmatched destinations without review. Defaults to false. */
|
|
27
|
+
readonly strictAllowlist?: boolean;
|
|
26
28
|
};
|
|
27
29
|
|
|
28
30
|
export type PiSandboxConfig = {
|
|
@@ -34,7 +36,7 @@ export type PiSandboxConfig = {
|
|
|
34
36
|
filesystem: {
|
|
35
37
|
additionalAllowRead: readonly string[];
|
|
36
38
|
};
|
|
37
|
-
network: NetworkConfig;
|
|
39
|
+
network: NetworkConfig & { readonly strictAllowlist: boolean };
|
|
38
40
|
hostIPC: HostIPCConfig;
|
|
39
41
|
};
|
|
40
42
|
|
|
@@ -57,6 +59,7 @@ export const DEFAULT_PI_SANDBOX_CONFIG: Readonly<PiSandboxConfig> = Object.freez
|
|
|
57
59
|
network: Object.freeze({
|
|
58
60
|
allowedDomains: Object.freeze([]),
|
|
59
61
|
deniedDomains: Object.freeze([]),
|
|
62
|
+
strictAllowlist: false,
|
|
60
63
|
}),
|
|
61
64
|
hostIPC: Object.freeze({
|
|
62
65
|
mode: "off",
|
|
@@ -263,9 +266,15 @@ export function parsePiSandboxConfigRaw(value: unknown): PartialPiSandboxConfig
|
|
|
263
266
|
}
|
|
264
267
|
rejectUnknownKeys(
|
|
265
268
|
value.network,
|
|
266
|
-
["allowedDomains", "deniedDomains"],
|
|
269
|
+
["allowedDomains", "deniedDomains", "strictAllowlist"],
|
|
267
270
|
"network",
|
|
268
271
|
);
|
|
272
|
+
const strictAllowlist = value.network.strictAllowlist;
|
|
273
|
+
if (strictAllowlist !== undefined && typeof strictAllowlist !== "boolean") {
|
|
274
|
+
throw new Error(
|
|
275
|
+
"invalid pi-sandbox configuration: network.strictAllowlist must be a boolean",
|
|
276
|
+
);
|
|
277
|
+
}
|
|
269
278
|
const normalizeDomainList = (
|
|
270
279
|
key: "allowedDomains" | "deniedDomains",
|
|
271
280
|
): string[] | undefined => {
|
|
@@ -310,6 +319,7 @@ export function parsePiSandboxConfigRaw(value: unknown): PartialPiSandboxConfig
|
|
|
310
319
|
parsedNetwork = {
|
|
311
320
|
...(allowed !== undefined ? { allowedDomains: allowed } : {}),
|
|
312
321
|
...(denied !== undefined ? { deniedDomains: denied } : {}),
|
|
322
|
+
...(strictAllowlist !== undefined ? { strictAllowlist } : {}),
|
|
313
323
|
};
|
|
314
324
|
}
|
|
315
325
|
|
|
@@ -376,7 +386,24 @@ export function parsePiSandboxConfigRaw(value: unknown): PartialPiSandboxConfig
|
|
|
376
386
|
}
|
|
377
387
|
|
|
378
388
|
export function parsePiSandboxConfig(value: unknown): PiSandboxConfig {
|
|
379
|
-
const
|
|
389
|
+
const config = resolvePiSandboxConfig(parsePiSandboxConfigRaw(value));
|
|
390
|
+
validatePiSandboxConfig(config);
|
|
391
|
+
return config;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
/** Validate the effective policy, after merging configuration layers. */
|
|
395
|
+
export function validatePiSandboxConfig(
|
|
396
|
+
config: { network: NetworkConfig; hostIPC: HostIPCConfig },
|
|
397
|
+
): void {
|
|
398
|
+
if (config.network.strictAllowlist && config.hostIPC.mode === "ask") {
|
|
399
|
+
throw new Error(
|
|
400
|
+
'invalid pi-sandbox configuration: network.strictAllowlist=true cannot be combined with hostIPC.mode="ask"; set hostIPC.mode="off" to keep execution sandboxed',
|
|
401
|
+
);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
/** Apply defaults without validating conflicts in an intermediate layer. */
|
|
406
|
+
function resolvePiSandboxConfig(raw: PartialPiSandboxConfig): PiSandboxConfig {
|
|
380
407
|
const provider =
|
|
381
408
|
raw.subagents?.provider ?? DEFAULT_PI_SANDBOX_CONFIG.subagents.provider;
|
|
382
409
|
const isPiSubagents = provider === "pi-subagents";
|
|
@@ -400,6 +427,7 @@ export function parsePiSandboxConfig(value: unknown): PiSandboxConfig {
|
|
|
400
427
|
],
|
|
401
428
|
},
|
|
402
429
|
network: {
|
|
430
|
+
strictAllowlist: raw.network?.strictAllowlist ?? false,
|
|
403
431
|
allowedDomains: [
|
|
404
432
|
...(raw.network?.allowedDomains ??
|
|
405
433
|
DEFAULT_PI_SANDBOX_CONFIG.network.allowedDomains),
|
|
@@ -435,6 +463,7 @@ function defaultPiSandboxConfig(): PiSandboxConfig {
|
|
|
435
463
|
network: {
|
|
436
464
|
allowedDomains: [...DEFAULT_PI_SANDBOX_CONFIG.network.allowedDomains],
|
|
437
465
|
deniedDomains: [...DEFAULT_PI_SANDBOX_CONFIG.network.deniedDomains],
|
|
466
|
+
strictAllowlist: DEFAULT_PI_SANDBOX_CONFIG.network.strictAllowlist,
|
|
438
467
|
},
|
|
439
468
|
hostIPC: {
|
|
440
469
|
mode: DEFAULT_PI_SANDBOX_CONFIG.hostIPC.mode,
|
|
@@ -507,7 +536,7 @@ export function mergePiSandboxConfigs(
|
|
|
507
536
|
allowedNativeAgents = [...new Set([...trustedAgents, ...projectAgents])];
|
|
508
537
|
}
|
|
509
538
|
|
|
510
|
-
|
|
539
|
+
const merged: PiSandboxConfig = {
|
|
511
540
|
subagents: {
|
|
512
541
|
provider,
|
|
513
542
|
...(isPiSubagents
|
|
@@ -526,6 +555,10 @@ export function mergePiSandboxConfigs(
|
|
|
526
555
|
],
|
|
527
556
|
},
|
|
528
557
|
network: {
|
|
558
|
+
// Both configuration files are trusted policy inputs. Projects may add
|
|
559
|
+
// destinations, but cannot turn off strict enforcement required globally.
|
|
560
|
+
strictAllowlist:
|
|
561
|
+
trusted.network.strictAllowlist || (project.network?.strictAllowlist ?? false),
|
|
529
562
|
allowedDomains: [
|
|
530
563
|
...new Set([
|
|
531
564
|
...trusted.network.allowedDomains,
|
|
@@ -552,6 +585,8 @@ export function mergePiSandboxConfigs(
|
|
|
552
585
|
trusted.hostIPC.retryOnUnixSocketError,
|
|
553
586
|
},
|
|
554
587
|
};
|
|
588
|
+
validatePiSandboxConfig(merged);
|
|
589
|
+
return merged;
|
|
555
590
|
}
|
|
556
591
|
|
|
557
592
|
export function loadPiSandboxConfig(
|
|
@@ -572,9 +607,8 @@ export function loadPiSandboxConfig(
|
|
|
572
607
|
const globalPath = getPiSandboxConfigPath(options.home);
|
|
573
608
|
let globalConfig: PiSandboxConfig | undefined;
|
|
574
609
|
try {
|
|
575
|
-
globalConfig =
|
|
576
|
-
globalPath,
|
|
577
|
-
readPiSandboxConfigFile(globalPath),
|
|
610
|
+
globalConfig = resolvePiSandboxConfig(
|
|
611
|
+
parsePiSandboxConfigFileRaw(globalPath, readPiSandboxConfigFile(globalPath)),
|
|
578
612
|
);
|
|
579
613
|
} catch (error) {
|
|
580
614
|
if (!isNotFoundError(error)) {
|
|
@@ -599,5 +633,6 @@ export function loadPiSandboxConfig(
|
|
|
599
633
|
if (projectRaw) {
|
|
600
634
|
return mergePiSandboxConfigs(base, projectRaw);
|
|
601
635
|
}
|
|
636
|
+
validatePiSandboxConfig(base);
|
|
602
637
|
return base;
|
|
603
638
|
}
|
package/src/index.ts
CHANGED
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
} from "./approval.ts";
|
|
18
18
|
import {
|
|
19
19
|
loadPiSandboxConfig,
|
|
20
|
+
validatePiSandboxConfig,
|
|
20
21
|
type HostIPCConfig,
|
|
21
22
|
type NetworkConfig,
|
|
22
23
|
type SubagentProvider,
|
|
@@ -220,6 +221,8 @@ async function performRegistration(
|
|
|
220
221
|
let currentTurn = 0;
|
|
221
222
|
const cwd = process.cwd();
|
|
222
223
|
const config = loadPiSandboxConfig({ cwd });
|
|
224
|
+
const hostIPC = options.hostIPC ?? config.hostIPC;
|
|
225
|
+
validatePiSandboxConfig({ network: config.network, hostIPC });
|
|
223
226
|
const subagentProvider =
|
|
224
227
|
options.subagentProvider ?? config.subagents.provider;
|
|
225
228
|
const isNativeSubagentChild = process.env.PI_SUBAGENT_CHILD === "1";
|
|
@@ -237,7 +240,6 @@ async function performRegistration(
|
|
|
237
240
|
: undefined;
|
|
238
241
|
const additionalAllowRead = config.filesystem.additionalAllowRead;
|
|
239
242
|
const network = config.network;
|
|
240
|
-
const hostIPC = options.hostIPC ?? config.hostIPC;
|
|
241
243
|
const subagents =
|
|
242
244
|
subagentProvider === "builtin"
|
|
243
245
|
? (options.subagentManager ??
|
|
@@ -625,10 +627,13 @@ async function performRegistration(
|
|
|
625
627
|
return;
|
|
626
628
|
}
|
|
627
629
|
if (ctx.hasUI) {
|
|
630
|
+
const networkMode = network.strictAllowlist
|
|
631
|
+
? "strict network allowlist (unmatched destinations denied without review)"
|
|
632
|
+
: "per-connection network review";
|
|
628
633
|
ctx.ui.notify(
|
|
629
634
|
process.platform === "darwin"
|
|
630
|
-
? `${EXTENSION_NAME} enabled: macOS Sandbox Runtime with static filesystem/domain policy and
|
|
631
|
-
: `${EXTENSION_NAME} enabled: Linux Sandbox Runtime with static filesystem/domain policy and
|
|
635
|
+
? `${EXTENSION_NAME} enabled: macOS Sandbox Runtime with static filesystem/domain policy and ${networkMode}`
|
|
636
|
+
: `${EXTENSION_NAME} enabled: Linux Sandbox Runtime with static filesystem/domain policy and ${networkMode}`,
|
|
632
637
|
"info",
|
|
633
638
|
);
|
|
634
639
|
}
|
package/src/policy.ts
CHANGED
|
@@ -115,6 +115,7 @@ export type SandboxPolicy = {
|
|
|
115
115
|
network: {
|
|
116
116
|
allowedDomains: string[];
|
|
117
117
|
deniedDomains: string[];
|
|
118
|
+
strictAllowlist?: boolean;
|
|
118
119
|
allowLocalBinding: boolean;
|
|
119
120
|
allowAllUnixSockets: boolean;
|
|
120
121
|
allowUnixSockets: string[];
|
|
@@ -273,6 +274,7 @@ export function createDefaultPolicy(
|
|
|
273
274
|
network: {
|
|
274
275
|
allowedDomains: [...(options.network?.allowedDomains ?? [])],
|
|
275
276
|
deniedDomains: [...(options.network?.deniedDomains ?? [])],
|
|
277
|
+
strictAllowlist: options.network?.strictAllowlist ?? false,
|
|
276
278
|
allowLocalBinding: false,
|
|
277
279
|
allowAllUnixSockets: false,
|
|
278
280
|
allowUnixSockets: [],
|
|
@@ -296,6 +298,7 @@ export function toSandboxRuntimeConfig(
|
|
|
296
298
|
network: {
|
|
297
299
|
allowedDomains: [...policy.network.allowedDomains],
|
|
298
300
|
deniedDomains: [...policy.network.deniedDomains],
|
|
301
|
+
strictAllowlist: policy.network.strictAllowlist ?? false,
|
|
299
302
|
allowLocalBinding: policy.network.allowLocalBinding,
|
|
300
303
|
allowAllUnixSockets: policy.network.allowAllUnixSockets,
|
|
301
304
|
allowUnixSockets: [...policy.network.allowUnixSockets],
|