Repository navigation
Conversation
|
Good instincts here: moving enforcement out of the model and into the runtime is the right call, the no-global-policy-state design is correct for an embeddable SDK, the symlink-aware Three things that need work before this is portable as-is:
Given the size (+1337/-10) and that it rewrites a security-critical dispatch path in |
04b37d5 to
3cf2370
Compare
canonicalizePath now walks up only for genuinely-missing paths (ENOENT/ENOTDIR) and rethrows permission errors and symlink loops. Replace the root-unsafe slice with path.basename. guardFileSystem refuses strict confinement when a custom adapter lacks a compatible canonicalizer. handleToolCall resolves file-path targets again and refuses an unverifiable mutating target under --project-only. Exempt the audited CLI ask_user UI override from the external-tool gate while keeping MCP/custom name collisions external. Document that projectOnly is not an OS boundary. Tests cover root-boundary canonicalization, fail-closed realpath errors, the adapter refusal, and ask_user under all four permission modes.
Add a top-level regression that goes through CodebuffClient.run with a restricted policy, spawns a child through the real spawn_agents handler, and proves the child's inherited requestToolCall denies shell and writes. This is the end-to-end inheritance check requested in review, beyond the handler-level unit tests.
|
Re-review requested for This revision keeps #1506 to the SDK execution-policy foundation and addresses the three portability concerns from the Oct 12 review. 1. 2. 3. Sub-agent policy inheritance — confirmed and fixed. Additional hardening in this head:
Split. The Local evidence: 56 pass / 0 fail across the affected SDK suites; changed-file typecheck clean. |
SDK execution policy foundation
Adds per-run execution permissions to the SDK. Each run captures its own policy, checks tool calls before dispatch, and guards filesystem reads and writes through the run's filesystem adapter.
The policy classifies the registered built-in tool set. Unknown tools remain fail-closed while restrictions are active. Dispatch authorization follows the resolved destination, so MCP calls that reuse built-in names and host overrides require external-tool trust. Trusted built-in overrides still retain built-in permission checks, and both direct
read_filesoverride paths check trust before calling the host. Spawned and nested agents inherit the parent's policy callback.--read-onlyand--project-onlydeny unrestricted shell execution until an OS-enforced sandbox can enforce those limits. A separate follow-up adds validation for the nested target path inapply_patch.PR branch and scope
mainsecurity/1450-execution-permissions3cf2370efebb951527139963ec3501d208f9003csecurity/1450-sdk-core-review-r2f823c975epolicy model,7c9b22fe7SDK enforcement,f5516ba36policy types,55b23d6fedispatch-origin authorization, and3cf2370eftyped regression fixtures.main: 7 files, +1,437 / -13.Verification
The complete stacked suite passed 98 tests across 9 files. It includes 38 SDK policy, inheritance, and read-filter tests in this PR. The SDK typecheck reports existing provider metadata incompatibilities in untouched upstream files; no changed file reports a type error.
Inference for this contribution was provided by FreeInference.org. FreeInference did not review, direct, approve, or otherwise participate in this work; all implementation, testing, and publication decisions are the contributor's own. If you find this useful, consider donating to FreeInference.org — they provide a useful and vital service.