fix(cli): critical security fixes for subagent permissions, writeFile boundary, and policy bypass
Summary
Addresses three critical/high security findings from the 2026-04-28 AI Tooling Security Audit:
-
Subagent bypasses permissions (Critical) — Removed the hard-coded
policies: [{ tool: "*", permission: "allow" }]override inextensions/cli/src/subagent/executor.tsso subagents now inherit the main agent's tool permission policies instead of unconditionally allowing all tools. -
writeFile no boundary (High) — Added
throwIfFileIsSecurityConcernchecks to both thepreprocessandrunfunctions inextensions/cli/src/tools/writeFile.ts, aligning it with the security posture ofreadFileandedittools. -
Policy bypass (High) — Fixed
extensions/cli/src/permissions/permissionChecker.tsso that dynamic tool policy evaluation (e.g., terminal command security analysis) is respected rather than being overridden by static userallowpolicies. The fix takes the most restrictive of the static policy and the dynamically evaluated policy, and gracefully handles invalid evaluator responses.
Test Results
- All existing CLI tests pass (1,848 passed, 29 skipped).
permissionChecker.test.tsandpermissionChecker.integration.test.tsupdated and passing.
Summary by cubic
Fixes three critical/high security issues in the CLI: subagents now inherit tool permissions, writeFile enforces path safety checks, and dynamic tool policy evaluation can’t be bypassed.
- Bug Fixes
- Subagent permissions: removed the allow-all override so subagents inherit the main agent’s tool policies.
writeFileboundary: addedthrowIfFileIsSecurityConcernin both preprocess and run to matchreadFile/editposture.- Policy evaluation:
permissionCheckernow takes the most restrictive result between static policy and dynamic evaluation, and safely handles invalid evaluator outputs. - Tests: updated
permissionCheckerunit/integration tests; all CLI tests pass.