Back to skill

Security audit

storage-templates

Security checks for vulnerabilities and agentic risk

Overview

This is a documentation-only skill for storage templates, with some low-risk wording and example-code issues but no hidden execution or data access.

Installers should understand this as a template/reference skill. Review its broad triggers if accidental activation matters, do not assume it provides a runnable command, and harden any copied storage code by validating IDs and checking paths before writing files.

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
modules/storage-patterns.md:163
Finding

Path Traversal Through an Unsanitized Session Identifier

Content
View full analysis

Vulnerability Details

File Location: modules/storage-patterns.md, lines 163–166
Vulnerability Type: Path traversal leading to arbitrary file creation or replacement
Risk Level: Medium

python
def write_session(session_dir: Path, session_id: str,
                  data: dict) -> None:
    target = session_dir / f"{session_id}.json"
    write_atomic_json(target, data)   # see Atomic Writes

Technical Analysis

The example directly interpolates session_id into a filesystem path without validating its format or verifying that the resolved destination remains inside session_dir.

An identifier containing parent-directory components, such as ../config, causes the generated path to escape the intended session directory. The subsequent atomic-write routine protects against partial writes but does not provide path containment or traversal protection. Because this is documentation rather than packaged executable code, exploitation requires a consumer to adopt the pattern in an application and pass attacker-controlled identifiers to it.

Attack Path

  1. An application copies or implements the documented write_session pattern.
  2. The application accepts a session identifier from an untrusted source.
  3. An attacker supplies an identifier containing traversal components, such as ../config.
  4. The expression constructs a path outside session_dir, such as session_dir/../config.json.
  5. write_atomic_json creates or replaces that destination with attacker-influenced JSON data.
  6. If the process can write to a security-sensitive location and the resulting file is consumed by another component, the attacker may alter application behavior or corrupt data.

Impact Assessment

Successful exploitation can create or replace JSON files outside the intended session directory within the filesystem permissions of the hosting process. The precise scope depends on the process account, directory permissions, attacker control over data, and ...[truncated 333 chars]

Remediation
View remediation

Remediation Suggestions

  • Require session_id to conform to a strict allowlist, preferably a canonical UUID or a similarly constrained identifier.
  • Reject absolute paths, .., directory separators, NUL characters, and unexpected filename characters.
  • Resolve the base directory and candidate destination, then verify containment before writing.
  • Create the session directory with restrictive permissions and run the application under a least-privileged account.
  • Add tests covering parent traversal, absolute paths, nested separators, encoded traversal variants, and valid identifiers.

Example hardened implementation:

python
import re
from pathlib import Path

SESSION_ID = re.compile(r"^[A-Za-z0-9_-]{1,128}$")

def write_session(session_dir: Path, session_id: str,
                  data: dict) -> None:
    if not SESSION_ID.fullmatch(session_id):
        raise ValueError("Invalid session identifier")

    base = session_dir.resolve()
    target = (base / f"{session_id}.json").resolve()

    if target.parent != base:
        raise ValueError("Session path escapes the storage directory")

    write_atomic_json(target, data)
Vulnerability Patterns
  • 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
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
Findings (6)

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The trigger list contains broad, common terms such as templates, storage, lifecycle, organization, and patterns, which can cause the skill to activate in many unrelated conversations. Unintended invocation can inject irrelevant instructions or context into other tasks, increasing the chance of workflow hijacking, user confusion, or accidental reliance on inappropriate guidance.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
95% confidence
Finding

The line tells users to 'Run the command with --help flag to verify availability,' yet this skill file contains only static template and lifecycle documentation with no command definition or executable interface. That is an active documentation-to-content mismatch rather than mere omission, because it instructs a validation action unsupported by the file's actual contents.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
95% confidence
Finding

This line again instructs the user to verify availability by running a command with --help, but the skill content shown is a Markdown template guide, not a command implementation. The instruction therefore contradicts the actual artifact and could mislead users about available capabilities.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
95% confidence
Finding

The same command-verification statement appears in the integration section despite the file exposing dependency metadata and documentation patterns rather than a runnable command. This creates an intent-code divergence between the documentation's claimed verification method and the actual contents available to the user.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
88% confidence
Finding

This markdown file provides a bash example that writes a new markdown file using shell redirection, which modifies the user's filesystem. The surrounding documentation presents the command as a usage example but does not include any warning that it will create or overwrite a local file if reused with an existing filename.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
84% confidence
Finding

The documented mv command renames a file on disk, which is a filesystem-modifying operation. Although this is part of a content-promotion workflow, the markdown does not explicitly warn users that running the command will alter local files and could overwrite a destination depending on environment and options.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.