Back to skill

Security audit

Memory Daily

Security checks for vulnerabilities and agentic risk

Overview

This skill coherently manages local daily memory notes, with one limited input-validation issue users should account for.

Install only if you are comfortable with the agent writing persistent daily notes. Treat memory entries as potentially sensitive, and avoid exposing the date or memoryDir arguments directly to untrusted users unless validation and path containment are added.

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
index.js:14
Finding

Path Traversal in Daily Memory File Reader

Content
View full analysis

Vulnerability Details

File Location: index.js:14-17, used by index.js:64-69
Vulnerability Type: Path traversal / arbitrary Markdown file read
Risk Level: Medium

Vulnerable Code

js
function dateFilePath(date, memoryDir) {
  const dir = memoryDir || DEFAULT_MEMORY_DIR;
  return path.join(dir, `${date}.md`);
}

The resulting path is used directly by the public read function:

js
function read(date, memoryDir) {
  const d = date || todayStr();
  const filePath = dateFilePath(d, memoryDir);
  if (!fs.existsSync(filePath)) return null;
  return fs.readFileSync(filePath, 'utf8');
}

Technical Analysis

The documented date format is YYYY-MM-DD, but the implementation does not validate that the supplied value conforms to this format. An attacker who can influence the date argument can include ../ path traversal components. path.join() normalizes these components, allowing the resulting path to escape the intended memory directory.

The implementation appends .md to the supplied value, so exploitation is generally limited to process-readable files whose names end in .md. Nevertheless, this can expose Markdown files outside the memory directory, including documentation, notes, configuration material, or other agent memory stored elsewhere.

The optional memoryDir argument further affects the traversal base. Although directory overriding is documented functionality, callers that expose this API to untrusted input must not treat it as a security boundary.

Attack Path

  1. An application or agent exposes read(date, memoryDir) directly or indirectly to an untrusted user.

  2. The attacker supplies traversal components instead of a valid date, such as:

    js
    read('../../other-directory/secrets', trustedMemoryDir);
    
  3. The function constructs:

    text
    trustedMemoryDir/../../other-directory/secrets.md
    
  4. `path.jo ...[truncated 598 chars]

Remediation
View remediation

Remediation Suggestions

Enforce the documented date format before constructing a path:

js
function validateDate(date) {
  if (!/^\d{4}-\d{2}-\d{2}$/.test(date)) {
    throw new TypeError('Date must use YYYY-MM-DD format');
  }

  const parsed = new Date(`${date}T00:00:00`);
  if (
    Number.isNaN(parsed.getTime()) ||
    todayParts(parsed) !== date
  ) {
    throw new RangeError('Invalid calendar date');
  }
}

Independently enforce path containment using resolved paths:

js
function dateFilePath(date, memoryDir) {
  validateDate(date);

  const base = path.resolve(memoryDir || DEFAULT_MEMORY_DIR);
  const target = path.resolve(base, `${date}.md`);

  if (path.dirname(target) !== base) {
    throw new Error('Resolved path escapes the memory directory');
  }

  return target;
}

Additional hardening measures:

  • Do not permit untrusted callers to choose memoryDir.
  • Apply the same validation centrally so both read() and any future date-based operations remain protected.
  • Consider rejecting symbolic links or verifying the canonical path with fs.realpathSync() when the memory directory may be writable by another user.
  • Add tests for ../, absolute-path-like input, encoded traversal passed through upstream layers, invalid calendar dates, and legitimate YYYY-MM-DD values.
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