Terminal uses a configuration object to define command filtering policies. All settings are optional and merge with sensible defaults.
Important: Terminal is a command string filter, not a sandbox. It validates the command and arguments before spawning. Once a command is allowed, the OS controls what it can access. See Security for OS-level hardening.
Terminal.initialize({
workspaces: ['/safe/project'],
commands: {
allow: ['cd *', 'git *', 'npm *'],
deny: ['rm *', 'sudo *'],
maxArgs: 10,
strictArgs: true,
noShell: true,
killSignal: 'SIGTERM',
windowsHide: false,
windowsVerbatimArguments: false
},
env: {
allow: ['NODE_ENV', 'PATH'],
deny: ['HOME', 'SSH_*', 'LD_PRELOAD', 'LD_LIBRARY_PATH']
},
timeout: 30000,
uid: undefined,
gid: undefined
})Restrict command execution to specific directories:
workspaces: ['/home/user/projects', '/tmp/builds']Commands outside these paths will be rejected. Note: This only validates cwd. The spawned process can still access any path the OS allows.
Pattern-based allowlist. Empty array allows all (unless denied).
allow: ['git *', 'npm *', 'echo *']Warning:
allow: ['node *']orallow: ['python3 *']effectively allows arbitrary code execution via script files. Terminal does not inspect file contents.
Pattern-based denylist. Always checked first.
deny: ['rm -rf *', 'sudo *', 'mkfs.*', 'dd *']Maximum number of arguments allowed per command.
maxArgs: 10 // Rejects commands with more than 10 argumentsBlock shell metacharacters and path traversal in arguments:
strictArgs: true // Blocks ; | & ` $ ( ) { } [ ] < > and ../noShell: true // Always use direct execution (recommended)Signal sent when a process is aborted or times out. Defaults to SIGTERM.
killSignal: 'SIGKILL' // Use SIGKILL instead of SIGTERMValid signals: SIGTERM, SIGKILL, SIGINT, SIGHUP, and all POSIX signal names.
Hides the subprocess console window on Windows. Prevents UI hijacking.
windowsHide: true // Hide console window on WindowsDisables Node.js quoting and escaping of arguments on Windows. Prevents command-line injection via Windows shell parsing.
windowsVerbatimArguments: true // Pass arguments verbatim on Windowsallow: ['NODE_ENV', 'PATH']Supports wildcards. Always deny LD_PRELOAD and LD_LIBRARY_PATH:
deny: ['SSH_*', 'AWS_*', 'TOKEN*', 'LD_PRELOAD', 'LD_LIBRARY_PATH']Default timeout in milliseconds:
timeout: 30000 // 30 secondsSet to 0 to disable timeouts.
Run spawned processes as a different user or group via setuid/setgid. Requires the parent process to have sufficient privileges.
uid: 1000 // Run as user ID 1000
gid: 1000 // Run as group ID 1000Note:
uid/gidare applied at the OS level via Node.jsspawn(). The parent process must have permission to change to the target user/group. This is a defense-in-depth layer — combine with OS-level unprivileged users for real isolation.
Patterns use token matching with optional wildcards:
git *- Matches "git" followed by any argumentsnode *.js- Matches "node" with .js file argumentdeno run *- Matches exact prefix, allows suffix
- Security - OS-level hardening guide
- API Reference - Programmatic config updates