T05 · Unauthorized Access and Privilege Escalation
Error
- Location
- scripts/run-session.sh:26
- Finding
- Autonomous headless sessions bypass permission checks by default<![CDATA[ ## Vulnerability Details **File Location**: `scripts/run-session.sh:26`, `scripts/run-session.sh:38-40`, and `scripts/run-session.sh:243-249` **Vulnerability Type**: Default permission bypass and removal of nested-session protection **Risk Level**: High ### Vulnerable Code ```bash DEFAULT_PERMISSION_MODE="bypassPermissions" ``` ```bash # Allow spawning claude -p from within an interactive Claude Code session. # Without this, Claude Code refuses to launch nested sessions. unset CLAUDECODE 2>/dev/null || true ``` ```bash build_claude_args() { local -a args=() args+=(--output-format stream-json --verbose) args+=(--model "$opt_model") args+=(--effort "$opt_effort") args+=(--max-budget-usd "$opt_max_budget") args+=(--permission-mode "$opt_permission_mode") args+=(--no-session-persistence) [ -n "$opt_fallback_model" ] && args+=(--fallback-model "$opt_fallback_model") [ -n "$opt_add_dir" ] && args+=(--add-dir "$opt_add_dir") echo "${args[@]}" } ``` ### Technical Analysis The headless runner defaults to Claude Code's `bypassPermissions` mode. This removes interactive authorization checks from autonomous tool operations rather than requiring users to opt into that behavior explicitly. The script also unsets `CLAUDECODE`, which disables the environment-based protection that ordinarily prevents a Claude Code process from launching another nested Claude Code session. Each resulting child session may receive up to 100 turns, and the outer session loop is unlimited unless the caller explicitly supplies a limit. These behaviors combine to create an execution environment in which task instructions can cause commands and file operations to run repeatedly without user approval. This is especially dangerous when the task incorporates untrusted repository content, issue descriptions, generated tracking files, or other prompt-injection-capable material. The documented behavior is inconsistent with the implementation: `SKI ...[truncated 1849 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Change the default to a restrictive permission mode, such as the documented `auto` mode: ```bash DEFAULT_PERMISSION_MODE="auto" ``` 2. Require an explicit, prominently documented opt-in flag before permitting `bypassPermissions`. 3. Display a clear warning and request interactive confirmation when bypass mode is selected. 4. Do not unset `CLAUDECODE` automatically. If nested execution is essential, require a separate explicit opt-in and explain the security consequences. 5. Apply a finite default session limit and require an explicit flag for unlimited operation. 6. Constrain accessible directories and tools to the minimum needed for the task. 7. Avoid exposing secrets in the runner's environment, and execute autonomous sessions inside a sandbox or isolated container where possible. 8. Update `SKILL.md` so its documented default permission mode exactly matches the implementation. 9. Add tests that verify the safe permission mode and finite session limit remain the defaults. ]]>
