Back to skill

Security audit

procedural-distiller

Security checks for vulnerabilities and agentic risk

Overview

This skill has a coherent memory-building purpose, but it should be reviewed because it saves past commands, file paths, and snippets as persistent future instructions without a clear redaction or approval gate.

Install only if you are comfortable with prior session traces becoming reusable skills. Before enabling or reusing generated learned skills, review them for secrets, private code, internal paths, unsafe commands, and instruction-like content from tool output; constrain the output directory and prefer traces that were explicitly approved for long-term memory.

Vulnerability Patterns
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • 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
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
Findings (1)

T02 · Agent Memory Poisoning

Error
Location
distill_logic.py:174
Finding

Untrusted Trace Content Is Persisted as Executable Procedural Memory

Content
View full analysis

Vulnerability Details

File Location: distill_logic.py:174-197, 240, 290-295
Vulnerability Type: Persistent agent-memory poisoning through unsanitized trace content
Risk Level: High

Vulnerable Code

python
def extract_success_pattern(events: list[TraceEvent]) -> list[str]:
    lines: list[str] = []
    seen: set[str] = set()
    for event in events:
        if not event.ok:
            continue
        candidate = f"- {event.summary}"
        if candidate in seen:
            continue
        seen.add(candidate)
        lines.append(candidate)
    return lines


def extract_failure_triggers(events: list[TraceEvent]) -> list[str]:
    lines: list[str] = []
    for event in events:
        if event.ok:
            continue
        detail = event.error or event.detail
        lines.append(f"- Avoid `{event.summary}` because {detail}")
    return lines or ["- No critical failed attempts were preserved in the inspected window."]


def extract_snippets(events: list[TraceEvent]) -> list[str]:
    snippets: list[str] = []
    for event in events:
        if event.snippet:
            label = event.raw.get("path") or event.raw.get("file") or event.tool
            snippets.append(f"### {label}\n```\n{event.snippet}\n```")
    return snippets[:5]

The resulting skill explicitly instructs future agents to replay the stored material:

python
"Replay the preserved commands and file edits in order. Prefer this skill when the task looks materially similar, and update the utility score after future uses if the workflow proves more or less effective.",

The generated files are then persisted:

python
(destination / "SKILL.md").write_text(markdown, encoding="utf-8")
(agents_dir / "openai.yaml").write_text(build_openai_yaml(task), encoding="utf-8")
(destination / "memory.json").write_text(
    json.dumps(memory_payload, indent=2, ensure_ascii=False) + "\n",
    encoding="utf-8",
)

Technical Analysis

Commands, paths, errors, labels, ...[truncated 3358 chars]

Remediation
View remediation

Remediation Suggestions

  1. Treat all trace fields as untrusted data, including task names, commands, paths, URLs, errors, snippets, diffs, and patches.
  2. Do not convert raw trace content directly into operational instructions. Store evidence in a structured, inert format and require a separate trusted synthesis step.
  3. Require explicit user review and confirmation before placing generated content in an auto-discovered learned-skill directory.
  4. Escape Markdown structural characters and dynamically choose code-fence lengths longer than any fence present in the content. Prefer serialization that cannot break into surrounding instructions.
  5. Add instruction-content detection for phrases requesting command execution, policy changes, secret access, external communication, or disregard of prior constraints.
  6. Allowlist acceptable tool types and command patterns. Reject or quarantine destructive commands, encoded payloads, shell metacharacters, credential access, and unexpected external URLs.
  7. Redact credentials, tokens, private keys, cookies, environment secrets, and other sensitive values before persistence.
  8. Remove the unconditional instruction to replay preserved commands. Require every stored step to be independently validated against the current task and security policy.
  9. Distinguish quoted historical evidence from trusted instructions using explicit metadata and enforce this distinction in the consuming agent.
  10. Record provenance and integrity metadata, including the trace origin, approving user, review status, and a content digest.
  11. Add adversarial tests covering code-fence breakout, injected headings, frontmatter injection, malicious commands, hostile error messages, and poisoned task names.
  12. Apply output-directory access controls so generated skills cannot overwrite trusted skills or become active before approval.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (5)

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 66)May include surrounding context.

md
- `SKILL.md` with valid frontmatter (`name`, `description`) and procedural sections

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
93% confidence
Finding

The skill explicitly instructs writing learned artifacts under skills/learned/... and persisting metadata in memory.json, but it does not declare any permissions or allowed-tools scope. That creates an authorization gap where a caller or runtime may grant broader file read/write access than the skill actually needs, increasing the chance of unintended file modification or data exposure if the trace/task inputs are adversarial or malformed.

Content

No source excerpt is available for this finding.

Ssd 3

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The snippet extraction logic copies tool-provided content such as snippets, full content, diffs, and patches into the generated skill without semantic filtering. In this skill's context, traces are specifically being converted into long-lived reusable memory, so any secrets, proprietary code, credentials, or sensitive prompts present in the trace can be republished and reused beyond the original session.

Content

No source excerpt is available for this finding.

Ssd 3

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

The generated markdown explicitly instructs future reuse of preserved commands and file edits, which operationalizes long-term retention of prior session data. While intended as a memory feature, this increases the chance that stale, sensitive, or context-specific information from one session is carried into unrelated future tasks and exposed again.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The code writes distilled markdown and memory artifacts derived from prior traces directly to disk, but there is no disclosure, consent check, or redaction step before persistence. Because traces may contain commands, file paths, snippets, errors, and task details, this can silently persist sensitive operational or user data into reusable skill files.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.