Back to skill

Security audit

CLI Worker Skill (Kimi CLI)

Security checks for vulnerabilities and agentic risk

Overview

This appears to be a real coding-delegation tool, but it gives delegated CLI agents broad access that is not fully disclosed in the Kimi-focused skill description.

Review before installing. Use it only for repositories and prompts you are comfortable sending to the selected external CLI provider, pin the intended provider explicitly, and run it with a minimal environment that excludes unrelated secrets. Avoid using it from non-git directories unless you accept direct workspace modification, and check for an existing AGENTS.md before running tasks or cleanup.

Vulnerability Patterns
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
  • 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
Findings (2)

T05 · Unauthorized Access and Privilege Escalation

Error
Location
src/spawn/run.ts:34
Finding
Delegated CLI Agents Inherit the Complete Parent Process Environment<![CDATA[ ## Vulnerability Details **File Location**: `src/spawn/run.ts:34-38`, `src/providers/claude.ts:137-141`, `src/providers/opencode.ts:178-182` **Compiled Copies**: `bin/spawn/run.js:17-21`, `bin/providers/claude.js:105-109`, `bin/providers/opencode.js:148-152` **Vulnerability Type**: Excessive environment-variable exposure and violation of least privilege **Risk Level**: High ### Vulnerable Code Kimi provider: ```ts const child = spawn(kimiCmd, args, { cwd, env: { ...process.env, KIMI_NO_BROWSER: "1" }, stdio: ["pipe", "pipe", "pipe"], }); ``` Claude provider: ```ts const child = spawn(claudeCmd, args, { cwd, env: process.env, // Uses ANTHROPIC_API_KEY from environment stdio: ["pipe", "pipe", "pipe"], }); ``` OpenCode provider: ```ts const child = spawn(opencodeCmd, args, { cwd, env: process.env, stdio: ["pipe", "pipe", "pipe"], }); ``` ### Technical Analysis All supported delegated CLI agents receive the complete environment of the parent OpenClaw process. Provider authentication may require selected variables, such as `ANTHROPIC_API_KEY`, but passing every environment variable is not necessary for the declared task. The inherited environment can contain unrelated credentials, including cloud access keys, database passwords, CI/CD tokens, package registry tokens, internal service endpoints, and session secrets. The delegated tools are autonomous coding agents capable of invoking local commands. Consequently, any secret inherited by the subprocess may be inspected by commands generated during task execution. Using `spawn()` with an argument array prevents shell injection in the prompt, but it does not mitigate disclosure through an unnecessarily broad subprocess environment. This behavior exceeds the minimum privileges required to delegate a coding task. ### Attack Path 1. A user or upstream untrusted source supplies or influences a delegated coding prompt. 2. `cli-worker execute` starts Kimi, Claude Code, or OpenCode. 3 ...[truncated 1270 chars]
Remediation
<![CDATA[ ## Remediation Suggestions Construct a minimal, explicit environment for each provider instead of forwarding `process.env`. 1. Allow only essential operating-system variables, such as: - `PATH` - `HOME` - `TMPDIR` - required locale variables - narrowly selected proxy or certificate variables when explicitly needed 2. Add only the authentication and configuration variables required by the selected provider: - Kimi-specific variables for Kimi - `ANTHROPIC_API_KEY` and documented Claude variables for Claude - documented OpenCode variables for OpenCode 3. Do not propagate unrelated variables matching sensitive patterns such as `*_TOKEN`, `*_SECRET`, `*_PASSWORD`, and unrelated `*_KEY` values. 4. Maintain separate provider allowlists and document every permitted variable. 5. Where supported, use provider credential files with restrictive permissions rather than broadly inherited environment credentials. 6. Add tests that place unrelated sentinel secrets in `process.env`, spawn each provider through a test executable, and verify that the sentinel variables are absent. ]]>

T09 · Insecure Skill Coding Practices

Warning
Location
src/cli/execute.ts:139
Finding
Non-Git Execution Silently Loses Worktree Isolation and Overwrites AGENTS.md<![CDATA[ ## Vulnerability Details **File Location**: `src/cli/execute.ts:139-152` and `src/cli/execute.ts:174-179` **Compiled Copy**: `bin/cli/execute.js:112-137` **Vulnerability Type**: Unsafe fallback to direct workspace execution and uncontrolled file replacement **Risk Level**: Medium ### Vulnerable Code Workspace selection: ```ts let worktreePath: string; if (isGitRepo(repoPath)) { try { worktreePath = await createWorktree(repoPath, taskId); } catch (err) { console.error( "Failed to create worktree:", err instanceof Error ? err.message : err ); return 1; } } else { worktreePath = cwd; } ``` Task-file creation: ```ts try { writeManifest(taskId, task, worktreePath, reportPath); // Use provider-specific AGENTS.md title const agentsMd = generateAgentsMd(task, provider.agentsMdTitle()); fs.writeFileSync(path.join(worktreePath, AGENTS_MD), agentsMd, "utf-8"); } catch (err) { console.error( "Could not write task files:", err instanceof Error ? err.message : err ); return 1; } ``` ### Technical Analysis The Skill is described as delegating tasks in isolated Git worktrees. However, if `repoPath` is not recognized as a Git repository, the implementation silently assigns `process.cwd()` to `worktreePath`. The delegated provider then runs directly in that directory. The implementation also writes `AGENTS.md` with `writeFileSync()` without checking whether that file already exists. Existing project or agent instructions are therefore replaced rather than preserved. No backup or restoration is performed after execution. This fallback has two related security consequences: 1. The delegated autonomous agent receives direct write access to the caller's working directory rather than a disposable isolated worktree. 2. Existing `AGENTS.md` security constraints, project rules, or operational instructions can be destroyed before the provider starts. The fallback also ignores `repoPath` when the supplied `-- ...[truncated 1352 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Refuse execution when an isolated worktree cannot be created unless the user supplies an explicit option such as `--allow-direct-execution`. 2. For non-Git inputs, create a dedicated temporary workspace and copy only explicitly selected files into it. 3. If direct execution is explicitly authorized: - Display a clear warning. - Require confirmation in interactive contexts. - Use the resolved `repoPath`, not `cwd`. - Clearly document that the operation is not isolated. 4. Never unconditionally replace an existing `AGENTS.md`. Prefer one of these designs: - Use a provider-specific temporary instruction file. - Abort if `AGENTS.md` already exists. - Back up the original file and restore it atomically in a `finally` block. - Merge generated instructions without removing existing constraints, if the provider supports this safely. 5. Improve repository detection to handle Git worktrees and repositories where `.git` is a file. Prefer a no-shell command such as: ```ts spawnSync("git", ["rev-parse", "--is-inside-work-tree"], { cwd: repoPath, encoding: "utf-8", shell: false, }); ``` 6. Add regression tests covering non-Git directories, existing `AGENTS.md` files, Git worktrees whose `.git` entry is a file, and non-Git paths supplied through `--repo`. ]]>
Vulnerability Patterns
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (50)

Credential Access

High
Category
Privilege Escalation
Content
- **Allowed:** Single segment only: alphanumeric and hyphens (e.g. UUIDs like `550e8400-e29b-41d4-a716-446655440000`). No path separators (`/`, `\`), no `..`, no leading hyphen.
- **Resolution:** Paths are resolved with `path.resolve(basePath, taskId)` and checked to remain under `basePath` before reading files or running `git worktree remove`. Invalid `taskId` is rejected with an error.

This prevents arbitrary file read (e.g. `status ../../../../etc/passwd`) and destructive worktree remove in arbitrary directories.

## Credentials and environment variables
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding
A generic provider interface is broader than a Kimi-only delegation skill and should be treated as such for review and permissions. Broad abstractions increase the chance of future capability creep without corresponding manifest updates.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding
A generic provider interface is broader than a Kimi-only delegation skill and should be treated as such for review and permissions. Broad abstractions increase the chance of future capability creep without corresponding manifest updates.

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding
A generic provider interface is broader than a Kimi-only delegation skill and should be treated as such for review and permissions. Broad abstractions increase the chance of future capability creep without corresponding manifest updates.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding
A generic provider interface is broader than a Kimi-only delegation skill and should be treated as such for review and permissions. Broad abstractions increase the chance of future capability creep without corresponding manifest updates.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding
A generic provider interface is broader than a Kimi-only delegation skill and should be treated as such for review and permissions. Broad abstractions increase the chance of future capability creep without corresponding manifest updates.

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding
A generic provider interface is broader than a Kimi-only delegation skill and should be treated as such for review and permissions. Broad abstractions increase the chance of future capability creep without corresponding manifest updates.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding
A generic provider interface is broader than a Kimi-only delegation skill and should be treated as such for review and permissions. Broad abstractions increase the chance of future capability creep without corresponding manifest updates.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding
A generic provider interface is broader than a Kimi-only delegation skill and should be treated as such for review and permissions. Broad abstractions increase the chance of future capability creep without corresponding manifest updates.

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding
A generic provider interface is broader than a Kimi-only delegation skill and should be treated as such for review and permissions. Broad abstractions increase the chance of future capability creep without corresponding manifest updates.

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding
A generic provider interface is broader than a Kimi-only delegation skill and should be treated as such for review and permissions. Broad abstractions increase the chance of future capability creep without corresponding manifest updates.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding
A generic provider interface is broader than a Kimi-only delegation skill and should be treated as such for review and permissions. Broad abstractions increase the chance of future capability creep without corresponding manifest updates.

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding
A generic provider interface is broader than a Kimi-only delegation skill and should be treated as such for review and permissions. Broad abstractions increase the chance of future capability creep without corresponding manifest updates.

Tp4

High
Category
MCP Tool Poisoning
Confidence
94% confidence
Finding
A generic provider interface is broader than a Kimi-only delegation skill and should be treated as such for review and permissions. Broad abstractions increase the chance of future capability creep without corresponding manifest updates.

Tp4

High
Category
MCP Tool Poisoning
Confidence
93% confidence
Finding
A generic provider interface is broader than a Kimi-only delegation skill and should be treated as such for review and permissions. Broad abstractions increase the chance of future capability creep without corresponding manifest updates.

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding
A generic provider interface is broader than a Kimi-only delegation skill and should be treated as such for review and permissions. Broad abstractions increase the chance of future capability creep without corresponding manifest updates.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding
A generic provider interface is broader than a Kimi-only delegation skill and should be treated as such for review and permissions. Broad abstractions increase the chance of future capability creep without corresponding manifest updates.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding
A generic provider interface is broader than a Kimi-only delegation skill and should be treated as such for review and permissions. Broad abstractions increase the chance of future capability creep without corresponding manifest updates.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding
A generic provider interface is broader than a Kimi-only delegation skill and should be treated as such for review and permissions. Broad abstractions increase the chance of future capability creep without corresponding manifest updates.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding
A generic provider interface is broader than a Kimi-only delegation skill and should be treated as such for review and permissions. Broad abstractions increase the chance of future capability creep without corresponding manifest updates.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding
A generic provider interface is broader than a Kimi-only delegation skill and should be treated as such for review and permissions. Broad abstractions increase the chance of future capability creep without corresponding manifest updates.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding
A generic provider interface is broader than a Kimi-only delegation skill and should be treated as such for review and permissions. Broad abstractions increase the chance of future capability creep without corresponding manifest updates.

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding
A generic provider interface is broader than a Kimi-only delegation skill and should be treated as such for review and permissions. Broad abstractions increase the chance of future capability creep without corresponding manifest updates.

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding
A generic provider interface is broader than a Kimi-only delegation skill and should be treated as such for review and permissions. Broad abstractions increase the chance of future capability creep without corresponding manifest updates.

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding
A generic provider interface is broader than a Kimi-only delegation skill and should be treated as such for review and permissions. Broad abstractions increase the chance of future capability creep without corresponding manifest updates.