Back to skill

Security audit

codebuddy-cli-delegation

Security checks for vulnerabilities and agentic risk

Overview

The skill has a legitimate delegation purpose, but it needs review because it runs unattended CodeBuddy jobs with auto-approval while loading repository project settings that may execute hooks.

Install only if you intentionally want CodeBuddy to run unattended coding batches. Use it in repositories you trust or in a sandboxed/containerized copy, inspect project-level CodeBuddy settings and hooks before using auto-approval, keep secrets out of prompts, and exclude `.cli-runs/` plus CodeBuddy session logs from commits and backups when they may contain sensitive data.

Vulnerability Patterns
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (1)

T09 · Insecure Skill Coding Practices

Error
Location
scripts/codebuddy-cli.js:271
Finding

Repository-controlled project hooks can execute during unattended permission-bypassed runs

Content
View full analysis

Vulnerability Details

File Location: scripts/codebuddy-cli.js:271-283; supporting workflow instructions in SKILL.md:430-445 and SKILL.md:586-601
Vulnerability Type: Unsafe loading of repository-controlled executable configuration
Risk Level: High

Vulnerable Code

javascript
const args = ['--setting-sources', 'project', ...passthrough];

const bootstrap = path.join(__dirname, 'skills-bootstrap.md');
if (fs.existsSync(bootstrap)) {
  args.push('--append-system-prompt', fs.readFileSync(bootstrap, 'utf8'));
}

const r = spawnSync(process.execPath, [entry, ...args], {
  stdio: 'inherit',
  env: cleanEnv,
});

The documented unattended workflow additionally directs callers to use:

sh
--permission-mode bypassPermissions

SKILL.md:586-589 states that unattended write runs must use this automatic-approval mode, while only requiring conversational authorization for specifically identified dangerous operations.

Technical Analysis

The launcher unconditionally adds --setting-sources project, causing CodeBuddy to load project-level settings from the target repository. The Skill documentation establishes that CodeBuddy settings can contain hooks and recommends project-only settings as the way to avoid problematic user-level hooks.

In a repository obtained from or writable by an independent contributor, project settings are not necessarily trusted. Loading them crosses a trust boundary from repository content into executable agent configuration. This becomes particularly dangerous when the documented workflow also enables bypassPermissions, suppressing the interactive approval controls normally available during an unattended write run.

The script does not inspect project settings, reject hook definitions, constrain hook commands, or require approval before loading them. Its environment filtering removes selected inherited variables, but it does not prevent commands defined by ...[truncated 1792 chars]

Remediation
View remediation

Remediation Suggestions

  1. Do not load repository hooks by default. Use a generated, trusted settings file stored outside the target repository, or invoke CodeBuddy with a mode that disables hooks while retaining only the project settings required for the task.
  2. Separate settings from executable hooks. If project configuration is needed, parse it and reject hook-related fields before starting CodeBuddy.
  3. Do not combine unreviewed project settings with bypassPermissions. Require an explicit opt-in after displaying the exact project configuration and hook commands that will be activated.
  4. Apply an allowlist. Permit only documented, non-executable project settings unless the user separately approves each hook.
  5. Use sandboxing for unattended runs. Run the delegated CLI in a container or restricted account with a narrowly scoped workspace, minimal credentials, restricted network access, and no access to unrelated user files.
  6. Fail closed. If the launcher cannot prove that project hooks are absent or disabled, terminate unattended permission-bypassed runs with a clear diagnostic.
  7. Update the documentation. Clarify that project settings are a trust boundary and require review before operating on third-party or contributor-controlled repositories.
Vulnerability Patterns
  • Rogue AgentSelf-Modification, Session Persistence
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
Findings (5)

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
70% confidence
Finding

Without declared permissions the skill's intent is opaque and cannot be validated.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The trigger list includes broad natural-language phrases like '批量改造', '交给 CLI 做', and '前台会超时', which can overlap with ordinary user requests. That raises the chance of unintended activation of a high-impact delegation workflow that launches unattended CLI runs, uses permissive execution modes, and writes logs/sessions, expanding the attack surface unexpectedly.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

L003 的整体描述与触发词均以中文为主,且文件中未说明输出语言可由用户选择,也未提供明确的语言切换或 opt-in 机制。按规则,若技能在自然语言层面默认强制特定语言/locale 而无选择,属于语言策略风险。

Content

No source excerpt is available for this finding.

Session Persistence

Medium
Category
Rogue Agent
Confidence
90% confidence
Finding

The skill instructs users to persist prompts and execution logs under .cli-runs/, and elsewhere references session logs in ~/.codebuddy/projects/. Those artifacts can contain sensitive prompts, code context, file paths, credentials accidentally echoed by tools, or internal operational data; long-lived local retention increases exposure to other local users, malware, backups, or accidental commits.

Content

Scanner excerpt · SKILL.md (reported line 596)May include surrounding context.

  • 统一日志落盘,便于事后审计:
sh
mkdir -p .cli-runs
LOG=".cli-runs/$(date +%H%M%S)-<任务名>.log"
timeout 1500 node .workbuddy/bin/codebuddy-cli.js \
  -p "$(cat .cli-runs/<任务名>.prompt.md)" \

Rp1

Medium
Category
MCP Rug Pull
Confidence
70% confidence
Finding

npx commands without a version suffix (e.g. @1.0.0) create a rug-pull risk if the upstream server is compromised and publishes a malicious update.

Content

No source excerpt is available for this finding.