Back to skill

Security audit

Memory Auto Index

Security checks for vulnerabilities and agentic risk

Overview

This skill is a coherent memory-indexing helper, but its recommended automatic shell integration is unsafe enough that users should review it before installing.

Install only if you are comfortable with a skill that updates persistent memory indexes. Do not implement the automatic trigger exactly as shown; use safe argument-vector process APIs, validate dates and paths, limit writes to MEMORY.md and memory/, and inspect or supply the referenced scripts yourself.

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
SKILL.md:42
Finding

Shell Command Injection in Recommended Memory Indexing Integration

Content
View full analysis

Vulnerability Details

File Location: SKILL.md, lines 42–50
Vulnerability Type: Shell command injection through dynamically interpolated input
Risk Level: High

typescript
// Pseudocode example
async function writeMemory(entry: MemoryEntry) {
  // 1. Write the memory file
  await writeFile(`memory/${entry.date}.md`, entry.content);
  
  // 2. Automatically add the index
  const tags = extractTags(entry.content);
  const subject = extractSubject(entry.content);
  await exec(`./scripts/auto-index-memory.sh memory/${entry.date}.md '${subject}' '${tags}'`);
}

Technical Analysis

The recommended integration constructs a shell command by directly interpolating entry.date, subject, and tags. These values are derived from a memory entry or its content and must therefore be treated as untrusted.

The single quotes around subject and tags do not prevent injection. An attacker can include a single quote to terminate the quoted argument and then append shell operators and commands. The interpolated entry.date value is not quoted at all, making it directly susceptible to whitespace, command substitution, or shell metacharacters.

Because exec() invokes a shell, the resulting string is parsed as shell syntax rather than passed exclusively as literal arguments to the indexing script.

Attack Path

  1. An attacker supplies or influences memory content, its extracted subject or tags, or the entry.date field.
  2. The malicious value contains a quote or another shell metacharacter followed by an operating-system command.
  3. extractSubject() or extractTags() preserves the malicious sequence, or the crafted date is used directly.
  4. The application interpolates that value into the command passed to exec().
  5. The shell interprets the injected sequence as executable syntax.
  6. The injected command runs with the operating-system privileges of the Agent or process executing the Skill ...[truncated 848 chars]
Remediation
View remediation

Remediation Suggestions

  • Do not construct shell commands by concatenating or interpolating untrusted data.

  • Replace shell-based exec() with an argument-vector API such as execFile() or spawn() with shell processing disabled:

    typescript
    import { execFile } from "node:child_process";
    import { promisify } from "node:util";
    import path from "node:path";
    
    const execFileAsync = promisify(execFile);
    const datePattern = /^\d{4}-\d{2}-\d{2}$/;
    
    if (!datePattern.test(entry.date)) {
      throw new Error("Invalid memory date");
    }
    
    const memoryRoot = path.resolve("memory");
    const filePath = path.resolve(memoryRoot, `${entry.date}.md`);
    
    if (!filePath.startsWith(`${memoryRoot}${path.sep}`)) {
      throw new Error("Memory path escapes the permitted directory");
    }
    
    await execFileAsync(
      "./scripts/auto-index-memory.sh",
      [filePath, subject, tags],
      { shell: false }
    );
    
  • Strictly validate entry.date against the expected date format and ensure the resolved file remains inside the designated memory/ directory.

  • Apply explicit length and character constraints to extracted subjects and tags.

  • Treat memory content and all values derived from it as untrusted input.

  • Run the indexing process with least privilege and restrict its filesystem access to the files required for indexing.

  • Add security tests containing quotes, command substitutions, newlines, semicolons, pipes, and redirection operators to verify that all values remain literal arguments.

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
Findings (1)

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The manifest description and the entire user-facing documentation are written only in Chinese, with no indication that users may choose another language or locale. Under the language/locale policy, forcing a specific language without opt-in is a natural-language policy violation unless the regional constraint is explicitly documented and justified.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.