Back to skill

Security audit

ClawSearch Ultra

Security checks for vulnerabilities and agentic risk

Overview

This search skill is not clearly malicious, but it needs review because its core runtime is incomplete and its monitor can write state files outside its intended temp folder.

Review before installing. Do not use sensitive queries or provider API keys until the missing core lib files and cache behavior are supplied and reviewed. Avoid passing untrusted values to --tag, and prefer a fixed simple tag such as letters, numbers, underscores, or hyphens only.

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

Warning
Location
scripts/watch.mjs:12
Finding

Path Traversal and Unsafe Temporary State File Handling

Content
View full analysis

Vulnerability Details

File Location: scripts/watch.mjs, lines 12–13, 33–36, 54–63
Vulnerability Type: User-controlled path traversal and unsafe temporary-file handling
Risk Level: Medium

Vulnerable Code

js
const STATE_DIR = path.join(os.tmpdir(), "clawsearch-watch");
fs.mkdirSync(STATE_DIR, { recursive: true });

const args = process.argv.slice(2);
if (args.length === 0) usage();

const query = args[0];
const tag = args.includes("--tag") ? args[args.indexOf("--tag") + 1] : query.replace(/\W+/g, "_").slice(0, 40);
const notify = args.includes("--notify") ? args[args.indexOf("--notify") + 1] : null;
const stateFile = path.join(STATE_DIR, `${tag}.json`);

// ...

let previous = new Set();
if (fs.existsSync(stateFile)) {
  try { previous = new Set(JSON.parse(fs.readFileSync(stateFile, "utf8"))); } catch {}
}

const fresh = results.filter(r => !previous.has(r.url));

// Gem baseline
fs.writeFileSync(stateFile, JSON.stringify([...current], null, 2));

Technical Analysis

The value supplied through --tag is incorporated directly into stateFile without validation or canonical containment checks. Although STATE_DIR is intended to constrain monitoring state to a temporary directory, path.join() does not prevent traversal components such as ../. A crafted tag can therefore resolve to a .json path outside clawsearch-watch.

The state directory is also predictable and created without explicitly restrictive permissions. The code separately checks existence and then reads or writes the path, and it does not reject symbolic links or use an exclusive, atomic file-creation strategy. In a shared temporary directory, these properties create additional local symlink and race-condition exposure.

The default tag generated from the query removes non-word characters and is comparatively constrained. The vulnerability specifically arises when an attacker or untrusted caller can control the explicit --tag argument.

Attack Path

  1. T ...[truncated 1796 chars]
Remediation
View remediation

Remediation Suggestions

  1. Validate explicit tags using a strict allowlist and length limit:

    js
    const TAG_PATTERN = /^[A-Za-z0-9_-]{1,40}$/;
    
    if (!tag || !TAG_PATTERN.test(tag)) {
      throw new Error("Invalid tag: use 1-40 letters, digits, underscores, or hyphens");
    }
    
  2. Resolve and verify the final path remains beneath the intended directory:

    js
    const root = path.resolve(STATE_DIR);
    const stateFile = path.resolve(root, `${tag}.json`);
    
    if (!stateFile.startsWith(`${root}${path.sep}`)) {
      throw new Error("State path escapes the state directory");
    }
    
  3. Create the state directory with restrictive permissions:

    js
    fs.mkdirSync(STATE_DIR, { recursive: true, mode: 0o700 });
    
  4. Reject symbolic-link targets by inspecting the destination with lstatSync() and using no-follow file-opening semantics where supported.

  5. Replace the direct write with an atomic operation:

    • Create a uniquely named temporary file inside STATE_DIR.
    • Open it with exclusive creation and mode 0600.
    • Write and flush the data.
    • Atomically rename it to the validated destination.
  6. Avoid a separate existence check followed by file access. Open the validated file directly and handle ENOENT to reduce time-of-check/time-of-use exposure.

  7. Treat tags as identifiers rather than path fragments. A robust alternative is to hash the tag and use the digest as the filename while storing the original tag only as data.

Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (9)

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
node scripts/watch.mjs "BTC price" --interval 1h --notify telegram

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
node scripts/watch.mjs "BTC price" --interval 1h --notify telegram

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
node scripts/watch.mjs "BTC price" --interval 1h --notify telegram

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
node scripts/answer.mjs "What is the DRT strategy?" --json

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
91% confidence
Finding

The skill advertises executable capabilities and references environment-based secrets/API keys, but it does not declare any explicit tool scope or permissions boundary. This weakens least-privilege controls and can cause an agent platform to grant broader execution or environment access than users expect, increasing the chance of unintended secret exposure or misuse of local runtime capabilities.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The skill promotes sending notifications via Telegram and Slack but provides no warning that search topics, results metadata, or monitoring activity may be transmitted to third-party services. In a search/monitoring skill, queries can contain sensitive business, personal, or investigative data, so silent forwarding to external platforms creates a meaningful privacy and data-leak risk.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

This command caches raw search queries and provider results to local storage via readCacheRecord/writeCacheEntry, but the CLI help and runtime flow shown here do not disclose that user prompts and returned content may be persisted. Search queries often contain sensitive terms, internal project names, credentials pasted by mistake, or investigative topics; silent persistence increases the risk of later disclosure to other local users, backup systems, or unrelated tooling that reads the cache directory.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
96% confidence
Finding

The usage text and examples are presented only in Danish, and the script branding/commentary indicate a Danish-first experience. While a --lang flag affects search behavior, the user-facing interface itself does not offer a language choice or opt-in, which can violate language/locale policy requirements.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
95% confidence
Finding

The usage text and examples are presented only in Danish, and the rest of the script also emits Danish status/error messages. This creates a locale-specific behavior without user opt-in or justification that the skill is intended only for Danish users.

Content

No source excerpt is available for this finding.