Back to skill

Security audit

Code Archaeology

Security checks for vulnerabilities and agentic risk

Overview

The skill is mostly aligned with legacy-code analysis, but one included utility can write outside its intended workspace if given a crafted project name.

Review before installing. Use this skill only on codebases and archaeology-result directories you intend to analyze, keep outputs in a dedicated workspace, and avoid passing untrusted or path-like project names until the path traversal issue is fixed.

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
process-file-manager.cjs:25
Finding

Path Traversal Allows Filesystem Writes Outside the Configured Workspace

Content
View full analysis

Vulnerability Details

File Location: process-file-manager.cjs:25-29, process-file-manager.cjs:37-48, and process-file-manager.cjs:108-110
Vulnerability Type: Unsanitized path construction and directory traversal
Risk Level: Medium

Vulnerable Code

js
const projectDir = path.join(this.baseDir, projectName);

// Create project directory
fs.mkdirSync(projectDir, { recursive: true });
js
// Task decomposition location
const tasksDir = path.join(projectDir, 'task-decomposition');
fs.mkdirSync(tasksDir, { recursive: true });
this.processFiles.tasks = {
  json: path.join(tasksDir, 'tasks.json'),
  markdown: path.join(tasksDir, 'tasks.md'),
  clawteam: path.join(tasksDir, 'clawteam-tasks.json')
};

// Context document location
const contextDir = path.join(projectDir, 'context-documents');
fs.mkdirSync(contextDir, { recursive: true });
js
const report = this.generateProcessFileReport();
const reportPath = path.join(this.baseDir, projectName, 'process-files-report.json');
fs.writeFileSync(reportPath, JSON.stringify(report, null, 2));
return reportPath;

Technical Analysis

The projectName argument is incorporated directly into filesystem paths without validation, normalization followed by containment verification, or rejection of traversal components. An attacker-controlled value containing sequences such as ../ can cause the resulting path to escape baseDir.

The affected methods subsequently pass the constructed paths to fs.mkdirSync() and fs.writeFileSync(). Consequently, this is not merely path disclosure: it provides a concrete filesystem write primitive. The report writer also overwrites an existing process-files-report.json because fs.writeFileSync() uses truncating write behavior by default.

The written report content is generated by the application rather than being completely attacker-selected. Nevertheless, the attacker can con ...[truncated 1410 chars]

Remediation
View remediation

Remediation Suggestions

  1. Restrict project names to a conservative allowlist before using them in paths:

    js
    function validateProjectName(projectName) {
      if (
        typeof projectName !== 'string' ||
        !/^[A-Za-z0-9._-]+$/.test(projectName) ||
        projectName === '.' ||
        projectName === '..'
      ) {
        throw new Error('Invalid project name');
      }
    }
    
  2. Resolve the destination and verify that it remains beneath the configured base directory:

    js
    function resolveWithinBase(baseDir, projectName) {
      validateProjectName(projectName);
    
      const base = path.resolve(baseDir);
      const destination = path.resolve(base, projectName);
    
      if (!destination.startsWith(base + path.sep)) {
        throw new Error('Project path escapes the configured base directory');
      }
    
      return destination;
    }
    
  3. Use the verified project directory consistently for every subsequent directory creation and file write. Do not reconstruct the destination from the original untrusted projectName.

  4. Reject absolute paths, path separators, null bytes, and . or .. path components explicitly.

  5. Before writing the report, repeat the containment check on the final resolved file path as defense in depth.

  6. If overwriting is unnecessary, use exclusive creation flags such as { flag: 'wx' } and return a controlled error when the destination already exists.

  7. Run the utility with a least-privileged operating-system account and limit write permissions to the intended workspace.

  8. Add automated tests covering traversal attempts such as ../target, ../../target, mixed separators, encoded separators after upstream decoding, and valid names that share a textual prefix with baseDir.

Vulnerability Patterns
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • 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
Findings (13)

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The example invocations are very broad and can be triggered by generic natural-language requests without stating scope limits, approval boundaries, or exclusions. In an agent setting, this increases the chance of over-broad execution, unintended analysis targets, or use in contexts the user did not clearly authorize, especially when paired with persistent output behavior.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The file states that analysis artifacts are written to a .code-archaeology/ directory in the workspace, but the examples do not clearly warn users that invoking the skill causes persistent file writes. Undisclosed persistence can expose sensitive code-derived information, create data retention issues, or interfere with repositories and downstream tooling if users expect read-only analysis.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
87% confidence
Finding

All user-facing instructions and descriptions in this file are written in Chinese, and the document does not state that language selection is optional or region-specific. This can violate language/locale policy when a skill effectively forces a specific language without user opt-in.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The skill’s descriptive strings and generated artifacts are written exclusively in Chinese, and the code returns Chinese-titled rules, specifications, and validation standards by default. There is no indication that the user can choose locale or that the Chinese-only behavior is limited to a justified region-specific deployment.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The manifest describes a skill for analyzing legacy codebases to extract business rules, technical specifications, and migration requirements. This file goes further by creating a new output directory and writing multiple AI Plan Generator context documents, which is a conversion/generation workflow rather than analysis itself.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The file header states it manages all process file locations for an AI Plan Generator workflow, and the constructor defaults to a specific workspace path under /Users/admin/.openclaw/workspace. That workflow-orchestration capability is not an obvious requirement of a code-archaeology skill whose stated role is legacy code analysis for modernization planning.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
83% confidence
Finding

The file's human-readable descriptions and comments are written entirely in Chinese, including the title and operational annotations, with no indication that this skill is intentionally region-specific or that alternative language support exists. Under the language/locale policy, hard-coding a single language without opt-in or justification can be a policy violation.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

The manifest frames the skill as analyzing legacy codebases, which suggests inspection and extraction of information from source code. This module goes beyond analysis by creating project directories and managing output artifact locations, and later persists reports to disk, which is workflow/file-management behavior rather than code-archaeology analysis itself.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

A skill described as extracting business rules and technical specifications from legacy systems does not inherently imply writing workflow reports into a local workspace. Persisting a process-files report is an operational capability not reflected in the manifest's analysis-focused description.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
92% confidence
Finding

The example states that analysis results are stored in the user's workspace under .code-archaeology/ but does not clearly warn the user that invoking the skill may create or modify files. Silent or unexpected filesystem writes can violate user expectations, overwrite prior artifacts, or persist sensitive derived data in the workspace.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
76% confidence
Finding

This code performs filesystem reads of externally supplied analysis-result files and silently ingests their contents into memory. Although file reads are less severe than writes, the applicable rule for code files asks for user disclosure around data-affecting operations, and there is no prompt, logging, or user-facing comment indicating that local files will be accessed.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
87% confidence
Finding

This code creates an output directory and writes multiple files to disk, which can overwrite prior contents in the target location. Although success is logged afterward, there is no pre-action warning, confirmation prompt, or explicit disclosure comment/docstring that the script will modify the filesystem at the provided output path.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
77% confidence
Finding

At L107-L110, the code generates and writes a JSON report to a file using fs.writeFileSync, which is a file-write operation. Although the method name suggests saving, there is no user-facing confirmation, log output, or explicit warning comment indicating that a report containing filesystem paths and workflow metadata will be persisted to disk.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.