Repository navigation
feat(agent-core-v2): experimental OS sandbox, exec-policy engine, and network egress control - #4115
Ram-Pavith wants to merge 1 commit into
Conversation
🦋 Changeset detectedLatest commit: dea48b3 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
…twork egress Gate behind the sandbox, exec-policy, and network-egress experimental flags (all default off): - os/sandbox: SandboxedHostProcessService decorates IHostProcessService.spawn with macOS Seatbelt or Linux bwrap argv rewriting, [sandbox] config with mode/writable roots/deny lists/exclusions, denial fingerprint detection, sandboxed-command-approve policy, and fail-closed behavior under -p. - packages/exec-policy + agent/execPolicy: layered .rules files (managed/user/project/session) with prefix_rule and network_rule, AST-based segment extraction reusing the bash parser, and an ExecPolicyPermissionPolicyService that runs in nonInteractive mode. - agent/networkEgress + os/sandbox/networkProxy: loopback CONNECT/SOCKS5 egress proxy enforcing [sandbox.network] allowlists and network_rule entries, token-scoped proxy env injection, released on process settle.
9d077f5 to
dea48b3
Compare
|
Rebased onto latest The previous CI runs on this PR never executed — they sat in the fork-workflow approval queue for 30 days and then expired as failures. The fresh runs triggered by this push are back in the queue: could a maintainer please click Approve and run on the workflows so CI actually executes? Thanks! |
|
@sailist @7Sageer — bringing this to your attention since it touches the permission-policy / tree-sitter-bash area and the environment-binding layer you maintain. TL;DR: This PR (#4115) implements the OS-level sandbox + exec-policy rules + network egress control requested in #1864 (xuwenhao closed his earlier attempt #1934 in favor of this one). It's been rebased onto latest Quick orientation, if useful:
If either of you could approve the workflow runs — or point me to the right reviewer — that would unblock CI. Thanks! |
Requirement or Bug
Resolve #4114
Bug Reproduction Steps
N/A — feature work; see linked issue for the motivation (no OS sandbox, no parsed command policy, no network egress control beneath the permission-approval UX).
Root Cause
N/A
Code Changes
Three layered enforcement mechanisms for agent-initiated
Bashcommands, each behind its own experimental flag (all default off). The design follows the same containment stack Codex (permission profiles → Seatbelt/bwrap →execpolicyrules → network proxy) and Claude Code (sandbox-runtime, deny-by-default network) use.Runtime flow when flags are on:
Docs:
config-files.md,env-vars.md,data-locations.mdupdated in both locales;docs/config-manifest.tomlregenerated; changeset included.Behavior Changes and Affected Users
Bashcommand executionsandboxflag +mode != off: spawns inside Seatbelt/bwrap per[sandbox]; default off = identicalKIMI_CODE_EXPERIMENTAL_SANDBOX=0,[sandbox] mode = "off",excluded_commandskimi -pdangerous-command-askskipped; zero vettingexec-policyflag:.rulesevaluated per parsed segment;promptfails closed,forbiddendenieskimi -prules.dfilesBash(...)glob rules[[permission.rules]]sandbox+network-egressflags +mode = allowlist: only listed domains via loopback proxy;off: no network[sandbox.network] mode = "all"or flag offdangerous-command-askpolicysegmentExtractor; behavior pinned by 116 existing policy testsHostProcessOptions/IHostProcesssandbox/sandboxedfields; unset = previous pathsandbox,exec-policy,network-egress)[sandbox]config sectionKIMI_CODE_SANDBOX_MODE)[sandbox]table (unlikely — key is new)Affected modules & coverage:
os/sandbox— 37 tests (profile resolution, SBPL/bwrap argv, denial fingerprints, seatbelt/bwrap network rules, real loopback CONNECT + SOCKS5 round-trips);packages/exec-policy+agent/execPolicy— 30 tests (lexer/parser, evaluator layering, AST segment corpus incl. heredoc/subshell/quoting/nested-shell depth caps);agent/networkEgress— 12 tests (domain decisions, token lifecycle, config resolution); permission-policy chain — 116 tests;bashTool— 54 tests. Fullagent-core-v2suite: 6,984 pass; 1 pre-existing failure on cleanmain(tool.test.tsforeground-subagent timeout — reproduces without this branch).Known limitations (documented in docs): macOS+Linux only (Windows reports unsupported and follows
allow_unsandboxed_commands); Linuxallowlistegress is advisory proxy injection, not kernel-enforced (bwrapunshare-netwould cut off the proxy itself); sandbox covers process spawns — file tools keep existing permission rules.Checklist
gen-changesetsskill —.changeset/experimental-sandbox-exec-policy-egress.md(minor).gen-docsskill —config-files.md,env-vars.md,data-locations.mdindocs/en+docs/zh.