Back to skill

Security audit

Skill Runner

Security checks for vulnerabilities and agentic risk

Overview

This skill is a disclosed runner for other skills, but it accepts a skill name from a message and dynamically loads local code without enough path or authorization controls.

Review this before installing. It should only be used in a tightly controlled environment with an allowlist of permitted skill names, strict path validation, caller authorization, and a restricted delegated context; otherwise a crafted message could cause it to load unintended local skill code with the runner's privileges.

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

T05 · Unauthorized Access and Privilege Escalation

Error
Location
index.js:6
Finding

Path Traversal Enables Unauthorized Skill Execution with Inherited Agent Privileges

Content
View full analysis

Vulnerability Details

File Location: index.js, lines 6-39
Vulnerability Type: Path traversal and missing authorization for dynamic module execution
Risk Level: High

Vulnerable Code

javascript
function getSkillPath(skillName) {
  return path.join('/home/bosunjung/.openclaw/workspace/skills', skillName, 'index.js');
}

// Main skill entry point
export async function skill(args, context) {
  const message = args.message;

  if (!message || typeof message !== 'string' || !message.startsWith('run ')) {
    console.warn('[Skill Runner] Invalid message format. Expected "run <skill-name>".');
    return { status: 'error', reason: 'invalid_message_format' };
  }

  const skillToRun = message.substring(4).trim();
  const skillFilePath = getSkillPath(skillToRun);

  if (!fs.existsSync(skillFilePath)) {
    console.error(`[Skill Runner] Target skill "${skillToRun}" not found at ${skillFilePath}.`);
    return { status: 'error', reason: 'skill_not_found', skill: skillToRun };
  }

  try {
    const skillModule = await import(fileURLToPath(`file://${skillFilePath}`));

    if (typeof skillModule.skill !== 'function') {
      console.error(`[Skill Runner] Target skill "${skillToRun}" does not export a 'skill' function.`);
      return { status: 'error', reason: 'invalid_skill_export', skill: skillToRun };
    }

    console.log(`[Skill Runner] Executing target skill "${skillToRun}"...`);
    const result = await skillModule.skill(args, context);

Technical Analysis

The skill name is extracted directly from an externally supplied message and inserted into a filesystem path without validating its syntax, canonicalizing the result, or checking that the resolved file remains beneath the intended skills directory.

path.join() normalizes traversal components such as ... Consequently, an input such as run ../../other-location can escape `/home/bosunjung/.openclaw/workspac ...[truncated 2816 chars]

Remediation
View remediation

Remediation Suggestions

  1. Use an explicit allowlist. Map approved external identifiers to fixed module paths rather than deriving paths from user input:

    javascript
    const APPROVED_SKILLS = new Map([
      ['memory-enhancer', '/home/bosunjung/.openclaw/workspace/skills/memory-enhancer/index.js'],
    ]);
    
    const skillFilePath = APPROVED_SKILLS.get(skillToRun);
    if (!skillFilePath) {
      return { status: 'error', reason: 'skill_not_authorized' };
    }
    
  2. Strictly validate identifiers. If dynamic discovery is required, accept only a narrow format such as /^[a-z0-9][a-z0-9-]{0,63}$/. Reject slashes, backslashes, dots used as traversal segments, null bytes, encoded separators, and unexpected whitespace.

  3. Enforce the canonical directory boundary. Resolve both the root and candidate path, then verify that the candidate is a descendant of the root:

    javascript
    const skillsRoot = path.resolve('/home/bosunjung/.openclaw/workspace/skills');
    const candidate = path.resolve(skillsRoot, skillToRun, 'index.js');
    
    if (!candidate.startsWith(skillsRoot + path.sep)) {
      return { status: 'error', reason: 'invalid_skill_path' };
    }
    
  4. Defend against symbolic-link escapes. Use fs.realpath() on the root and candidate and repeat the descendant check against their canonical paths before import.

  5. Add caller-level authorization. Verify that the requesting cron job, agent, or session is authorized to invoke the specific allowlisted skill. Message formatting is not an authorization control.

  6. Apply least privilege to context delegation. Do not pass the complete runner context by default. Construct a restricted context exposing only the tools and scopes required by the approved target skill.

  7. Separate trust domains. Execute target skills in isolated processes or sandboxes with restricted filesystem, network, environment, and tool access. Dynamic module impo ...[truncated 332 chars]

Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep