Each layer is independent — compromising one doesn't defeat the others. The bash security system uses tree-sitter AST analysis with regex fallback. An ML classifier (internal-only) adds context-aware decisions. Server-side killswitches can remotely disable bypass/auto mode.
@anthropic-ai/sandbox-runtime macOS native sandbox. Network domain allowlist. Filesystem read/write restrictions. Ripgrep path deny patterns. Policy allowManagedDomainsOnly cannot be overridden.Bash(git *), Write(**/.env). Allow/deny/ask per tool+pattern.Each validator targets a specific attack vector. Tree-sitter AST parsing when available; regex fallback when not. If unsure, defaults to 'ask' (safe default).
| Category | Validators | Example Attacks Blocked |
|---|---|---|
| Injection | COMMAND_SUBSTITUTION, SHELL_METACHARACTERS, NEWLINES | $(rm -rf /), unquoted $ / backticks, \n injection |
| Variable abuse | DANGEROUS_VARIABLES, IFS_INJECTION | IFS=/ cmd, LD_PRELOAD, BASH_ENV manipulation |
| Obfuscation | OBFUSCATED_FLAGS, BACKSLASH_ESCAPED_OPERATORS/WHITESPACE | - -rf (space in flags), \; / \| (escape desync) |
| Unicode | UNICODE_WHITESPACE, CONTROL_CHARACTERS | U+2003 em-space (zsh parsing bypass), invisible 0x00-0x1F bytes |
| Quoting | COMMENT_QUOTE_DESYNC, QUOTED_NEWLINE, MID_WORD_HASH | Unclosed quotes hiding code, newlines in "...", # comment desync |
| Expansion | BRACE_EXPANSION, HEREDOC_EXPANSION | {a,b} near metacharacters, heredoc with $() expansion |
| Zsh-specific | ZSH_DANGEROUS_COMMANDS (16 patterns) | zmodload, sysopen, sysread, ztcp, mapfile, emulate |
| Data exfil | JQ_SYSTEM_FUNCTION, JQ_FILE_ARGUMENTS, PROC_ENVIRON_ACCESS | jq @base64d+system(), jq file args, /proc/self/environ |
| Git | GIT_COMMIT_SUBSTITUTION | Code injection via git commit message $(cmd) |
| Structural | INCOMPLETE_COMMANDS, MALFORMED_TOKEN_INJECTION | Fragments, broken shell-quoting bypasses |
A context-aware classifier that can approve rm /tmp/test but deny rm /root/secret — understands intent, not just patterns.
Takes: command text + CWD + behavior descriptions (deny/ask/allow). Returns: { matches, confidence: high|medium|low, reason, matchedDescription }. Two-stage: Fast initial pass + Thinking reasoning if needed. Tracks API tokens for analytics.
isClassifierPermissionsEnabled() returns false. All functions return { matches: false, confidence: 'high', reason: 'disabled' }. External users rely on pattern-based validators only. Feature gate: TRANSCRIPT_CLASSIFIER.
..\HEAD), NTFS 8.3 short names (GIT~1), case-insensitive on Windows.symlink /tmp/safe → /etc/shadow caught because resolved path is checked.checkEditableInternalPath runs BEFORE working dir check.allowManagedDomainsOnly cannot be overridden by user rules or bypassPermissions mode.| Gate | Effect |
|---|---|
tengu_sessions_elevated_auth_enforcement | Disables bypassPermissions mode entirely. Checked on startup. Reverts to 'default' if flipped. |
tengu_auto_mode_config | Disables auto mode (ML classifier). Checked on model/fast-mode change. Can also disable fast mode via disableFastMode circuit breaker. |
code_verifier (crypto random) + code_challenge = SHA256(verifier)code_challenge + method=S256 sent to claude.ai