Back to skill

Security audit

AI内容创作助手

Security checks for vulnerabilities and agentic risk

Overview

This writing skill mostly matches its stated purpose, but it needs review because its topic search path can execute shell commands unsafely and sends user topics to an external search service without a clear privacy warning.

Review this skill before installing. Do not pass confidential topics or draft ideas unless you are comfortable with Tavily search receiving related query text. The publisher should replace shell-based execSync command construction with argument-array execution, limit inherited environment variables, validate topic input, and add a clear privacy notice and overwrite warning.

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/write.mjs:153
Finding

OS Command Injection Through the Article Topic Argument

Content
View full analysis

Vulnerability Details

File Location: scripts/write.mjs, lines 153-166
Vulnerability Type: OS command injection caused by unsafe shell command construction
Risk Level: High

js
async function searchHotTopics(topic) {
  if (!TAVILY_API_KEY) return null;
  
  const skillDir = path.dirname(path.dirname(new URL(import.meta.url).pathname));
  const tavilyScript = path.join(process.env.HOME, '.openclaw', 'skills', 'tavily-search', 'scripts', 'search.mjs');
  
  try {
    const cmd = `node "${tavilyScript}" "${topic} 热点 趋势 2024" -n 3 --topic news`;
    const result = execSync(cmd, { 
      encoding: 'utf-8',
      env: { ...process.env, TAVILY_API_KEY }
    });
    return result;
  ```

### Technical Analysis

The `topic` value originates from the user-controlled `--topic` or `-t` command-line argument. It is interpolated directly into a command string passed to `execSync()`.

Node.js executes a string supplied to `execSync()` through a shell by default. Placing the value inside double quotes does not make it safe: shell command substitution constructs such as `$(...)` and backticks remain active within double-quoted strings, while embedded quotes can alter the intended command structure.

The vulnerable path is reached when `TAVILY_API_KEY` is configured. No validation or shell escaping is applied before the topic is inserted into the command. Moreover, the spawned shell inherits the complete process environment through `{ ...process.env, TAVILY_API_KEY }`, potentially exposing credentials and other sensitive environment variables to an injected command.

### Attack Path

1. The application is run in its documented configuration with `TAVILY_API_KEY` set.
2. An attacker supplies a crafted value through `--topic`, including shell syntax such as command substitution.
3. `generateArticle()` passes the attacker-controlled topic to `searchHotTopics()`.
4. `searchHotTopics()` interpolates the topic in
...[truncated 1220 chars]
Remediation
View remediation

Remediation Suggestions

Eliminate shell interpretation by replacing execSync() with an API that accepts the executable and arguments separately, such as execFileSync() or spawnSync() with shell: false.

js
import { execFileSync } from 'child_process';

const result = execFileSync(
  process.execPath,
  [
    tavilyScript,
    `${topic} 热点 趋势 2024`,
    '-n',
    '3',
    '--topic',
    'news'
  ],
  {
    encoding: 'utf-8',
    shell: false,
    env: {
      PATH: process.env.PATH,
      HOME: process.env.HOME,
      TAVILY_API_KEY
    }
  }
);

Additional hardening should include:

  1. Validate that topic is a string and enforce a reasonable maximum length.
  2. Do not attempt to solve the issue solely through shell escaping; avoiding the shell is more reliable.
  3. Pass only environment variables required by the child process instead of copying all of process.env.
  4. Resolve and validate tavilyScript, confirming that it points to the expected regular file before execution.
  5. Apply a child-process timeout and output-size limit to reduce denial-of-service risks.
  6. Add regression tests using topics containing quotes, backticks, dollar signs, semicolons, newlines, and command-substitution syntax, verifying that they are passed as literal argument content.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (9)

Context-Inappropriate Capability

High
Category
Not specified by scanner
Confidence
94% confidence
Finding

The script invokes another local script through child_process using a shell command and passes user-controlled topic data into that command. Even though the topic is quoted, shell-based command construction is fragile and can lead to command injection or unsafe execution if quoting assumptions break; additionally, reading an API key from the environment and delegating to another skill expands trust boundaries beyond what users may expect from a writing assistant.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The README advertises automatic hotspot/topic searching and requires a Tavily API key, but it does not warn users that prompts or search terms may be transmitted to an external third-party service. In a writing assistant context, users may input unpublished drafts, business topics, or sensitive research subjects, so undocumented outbound data flow creates a real privacy and compliance risk.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
88% confidence
Finding

The skill declares access to an environment variable (TAVILY_API_KEY) but does not define an explicit tool scope such as permissions or allowed-tools. This can lead to over-broad execution capability or unclear trust boundaries, making it harder for users and platforms to understand what the skill may access or invoke.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
83% confidence
Finding

The script’s descriptive text and user-facing interface are written in Chinese, and generated timestamps are explicitly formatted for zh-CN/Asia-Shanghai. This imposes a specific language/locale behavior without documented opt-in or a configurable alternative.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

The manifest describes a writing assistant for generating and optimizing content across platforms, but this code also invokes a separate Tavily search skill to fetch external hot-topic/news data. External research may be a possible enhancement, but it is not disclosed in the stated feature set of generation, plagiarism checking, SEO optimization, and polishing.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
80% confidence
Finding

The README presents all instructions and usage guidance exclusively in Chinese, and there is no indication that users can opt into another language or that the skill is intentionally limited to a Chinese-language audience for a documented reason. This can violate a language/locale policy when a skill forces a specific language without user choice.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
90% confidence
Finding

This markdown file documents use of a Tavily API key and states it is used for hot-topic search, but it does not warn users that prompts or topic data may be sent to an external service. For markdown files, user-facing descriptions should disclose behaviors that may affect privacy or data handling.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
90% confidence
Finding

The script transmits the user's topic to an external search tool/API without an explicit privacy notice or consent mechanism. If users provide confidential draft topics, internal project names, or sensitive subjects, that data may be disclosed to a third party unexpectedly.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
87% confidence
Finding

This code performs a file write when --output is provided, but there is no prior disclosure, confirmation, or warning that an existing file at that path may be overwritten. The post-write success message appears only after the operation has already occurred, so it does not function as a safety warning.

Content

No source excerpt is available for this finding.