T05 · Unauthorized Access and Privilege Escalation
Error
- Location
- SKILL.md:40
- Finding
- Delegated Claude Code Agents Run with Permission Checks Disabled by Default<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md:44-47, 59, 239`; `agents/openai.yaml:16`; `references/claude-code-commands.md:7-13, 21-27, 42` **Vulnerability Type**: Permission-control bypass in delegated agent execution **Risk Level**: High ### Vulnerable Code `SKILL.md:40-47`: ```bash ### Claude Code - 不需要 PTY ```bash # ✅ 正确用法(使用 --print 模式) exec command:"claude --permission-mode bypassPermissions --print '你的任务描述'" # 后台执行 exec background:true command:"claude --permission-mode bypassPermissions --print '你的任务描述'" ``` `agents/openai.yaml:13-16`: ```yaml 规则: - Codex/OpenCode/Pi 需要 pty:true - Claude Code 使用 --print --permission-mode bypassPermissions - 始终指定 workdir ``` `references/claude-code-commands.md:5-13`: ```bash # 一次性执行(推荐) claude --permission-mode bypassPermissions --print "你的提示词" # 后台执行 claude --permission-mode bypassPermissions --print "你的提示词" & # 指定工作目录 cd /path/to/project && claude --permission-mode bypassPermissions --print "你的提示词" ``` `references/claude-code-commands.md:19-22`: ```markdown | `--print` | 非交互模式,输出到标准输出 | | `--permission-mode bypassPermissions` | 跳过权限确认 | | `--dangerously-skip-permissions` | 跳过权限确认(旧版,可能提前退出) | ``` ### Technical Analysis The Skill consistently presents `--permission-mode bypassPermissions` as the recommended and default way to launch Claude Code. This option removes per-operation authorization prompts that would otherwise provide a security boundary between an AI-generated action and its execution. A coding agent commonly receives repository files as context and may execute shell commands, edit files, install dependencies, or access network resources. Repository content is potentially attacker-controlled, especially during pull-request review or work on an unfamiliar project. Malicious instructions embedded in source files, documentation, tests, issue content, or build configuration can therefore influence the delegated agent. The instruction to specify `workdir` reduces accidental cont ...[truncated 2016 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. **Remove permission bypass from the default workflow** - Launch Claude Code with its normal permission controls. - Do not describe `bypassPermissions` as recommended behavior. - Require explicit, task-specific user consent before enabling any bypass mode. 2. **Use an isolated execution environment** - Run delegated agents in a disposable container, VM, or restricted OS account. - Mount only the required repository into the environment. - Make unrelated host paths unavailable. - Avoid forwarding the host SSH agent or credential stores. 3. **Restrict process capabilities** - Apply filesystem allowlists covering only the intended workspace. - Disable outbound network access by default or permit only required destinations. - Remove unnecessary environment variables, API tokens, cloud credentials, and Git credentials. - Enforce CPU, memory, process, and execution-time limits. 4. **Require approval for high-risk operations** - Require user confirmation for shell execution, writes outside expected files, dependency installation, network access, Git pushes, and destructive commands. - Display the exact command and affected paths before execution. 5. **Harden untrusted-repository workflows** - Treat repository instructions and generated commands as untrusted input. - Review untrusted pull requests in temporary worktrees or disposable environments. - Do not execute build or test commands until their scripts and configuration have been reviewed. 6. **Harden package installation** - Use lockfile-enforced installation. - Disable lifecycle scripts where feasible when auditing unfamiliar repositories. - Review dependencies and installation scripts before enabling them. 7. **Update all duplicated guidance** - Correct `SKILL.md`, `agents/openai.yaml`, and `references/claude-code-commands.md` together so that the unsafe invocation is not reintroduced through secondary documentat ...[truncated 10 chars]
