vtcode-safety
September 12, 2026 · View on GitHub
Root AGENTS.md | Command safety detection, execution policies, and sandboxing. Layer 1 crate — depends on vtcode-commons.
Module Groups
| Area | Modules |
|---|---|
| Command Safety | command_safety/ — dangerous command detection, shell parsing |
| Execution Policy | exec_policy/ — policy management, approval workflows, command validation |
| Sandboxing | sandboxing/ — sandbox policy, permissions, execution environments |
Rules
exec_policy::managerimportscommand_safety::command_might_be_dangerousandsandboxing::SandboxPolicy— these form a tightly coupled safety subsystem.- Re-export facades in vtcode-core (
command_safety/mod.rs,exec_policy/mod.rs,sandboxing/mod.rs) must stay in sync. SandboxPermissions::normalized_foris the canonical boundary for additional-permission mode normalization; callers must not duplicate that rule.- The
BashParsersingleton (once_cell::Lazy) is safe across crates — read-after-init pattern.
Gotchas
exec_policy/parser.rsimportsvtcode_commons::fs::{parse_json_with_context, read_file_with_context};command_validation.rsimportspaths::{canonicalize_workspace, normalize_path}and delegates workspace containment toensure_path_within_workspace_resolved(symlink-aware walk lives in commons, tests included).sandboxing/uses tree-sitter for Bash AST analysis — pinned to specific versions.command_safety::shell_parsermust extract nested simple commands from loops/conditionals so safety checks and approval caching see loop bodies, not just top-level shell syntax; preserve raw and ANSI-quoted arguments in that extraction.command_safety::shell_parserowns dynamic-shell-syntax detection;findexpansion must fail closed before preflight or learned approval. Static shell classification permits literal escapes inside double-quoted arguments (e.g.,rgregexes) but rejects unquoted escapes; keep the scanner quote-aware.- Keep hard rejection (
command_might_be_dangerous) separate from inline-code admission (command_requires_approval); interpreter-c/-eforms may proceed only under enforceable sandbox policy or explicit approval. - Sandboxed pipe/PTY and MCP stdio launches rebuild allowlisted env vars after overrides; macOS hostname allowlists reject unenforceable policies, Windows restrictions fail closed, and
SensitivePathmatching is case-insensitive with component-boundary semantics. Linux enforcement (sandboxing/linux.rs,linux_seccomp.rs) runs inside the binary's hiddenvtcode sandbox-execlauncher (LinuxSandboxLauncher::resolve): build the Landlock ruleset at the exact probed ABI, keep the two seccomp filters (EPERM blocklist + ENOSYS clone3) separate, leave exec/IOCTL_DEV unhandled, and keepsyscall_numbermappings in sync withBLOCKED_SYSCALLS. - Keep
exec_policy_command_validationfuzzing and traversal/symlink regression cases aligned with workspace containment or command validation changes. - Windows-only
command_safetyDB builders (windows_cmdlet_db.rs,windows_com_analyzer.rs,windows_registry_filter.rs) use module-level#![expect(unused_results)]— one-shot builders deliberately discardinsertresults; cross-check withcargo check --target x86_64-pc-windows-msvcsince Linux CI never compiles#[cfg(windows)]code.