Back to skill

Security audit

reflection-replanner

Security checks for vulnerabilities and agentic risk

Overview

The skill contains a functional replanner, but it also adds persistent learning and preference memory that can affect future runs without clear consent, scoping, or retention controls.

Install only if you are comfortable with this skill keeping local cross-session usage and preference memory. Do not let it record secrets, personal data, customer data, or sensitive error payloads, and consider removing or disabling the learner workflow unless you have a clear review process for learned_patterns.json and any proposed SKILL.md changes.

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

Warning
Location
scripts/learner.py:91
Finding

Persistent Memory Poisoning Through Unvalidated User-Controlled Preferences

Content
View full analysis

Vulnerability Details

File Location: scripts/learner.py:91-95, scripts/learner.py:137-139, and SKILL.md:60-77
Vulnerability Type: T02: Agent Memory Poisoning
Risk Level: Medium

The learning subsystem persists arbitrary preference keys and values in learned_patterns.json. The accompanying skill instructions tell future agents to apply important stored preferences directly and to write accumulated experiences back into SKILL.md. No validation, trust labeling, user isolation, or approval gate is imposed on this persistent content.

Relevant code from scripts/learner.py:91-95:

python
def record_preference(skill_dir, key, value):
    data = load_learning(skill_dir)
    data["preferences"][key] = value
    save_learning(skill_dir, data)
    return data

CLI path from scripts/learner.py:137-139:

python
elif args.cmd == "prefer":
    record_preference(sd, args.key, args.val)
    print("✅ Preference recorded")

Relevant workflow instructions from SKILL.md:60-77, translated into English:

text
Record a user preference for direct use next time:
python scripts/learner.py prefer <skill-directory> --key output-language --val Chinese

Iteration rules:
- Errors accumulated at least three times: proactively add preflight/fallback
  steps and write the experience back into this SKILL.md.
- Important user preferences: write them into learned_patterns.json and
  adopt them directly during the next invocation.

Technical Analysis

The prefer command accepts unrestricted values through --key and --val, then writes those values into persistent JSON state. The related record command also accepts unrestricted error and note text, which may later be surfaced by the reflection workflow. The persisted data has no provenance, ownership, trust level, content restrictions, expiration, or task scope.

Persistence alone is not necessarily unsafe; the ...[truncated 2624 chars]

Remediation
View remediation

Remediation Suggestions

  1. Replace arbitrary preference keys and values with an explicit allowlist and typed schema. Permit only passive settings such as output language, date format, or verbosity.
  2. Reject values containing imperative instructions, tool requests, role changes, safety-policy references, executable content, or other material unrelated to the declared preference type.
  3. Record provenance for every entry, including authenticated user identity, tenant, task, timestamp, source, and approval status.
  4. Isolate memory by user and tenant. Do not share one learned_patterns.json across unrelated users or trust domains.
  5. Treat persisted content as untrusted data when loading it. Never interpolate it into system or skill instructions, and never interpret it as executable agent guidance.
  6. Require explicit user confirmation before applying a stored preference in a new task, particularly when the preference affects behavior beyond presentation.
  7. Remove the instruction to write accumulated notes directly into SKILL.md. Proposed changes should instead be represented as structured, reviewable suggestions and accepted only through a trusted human approval process.
  8. Add expiration, revocation, audit logging, and reset controls for persistent preferences.
  9. Constrain skill_dir to an approved canonical directory and use atomic, permission-restricted writes to reduce unauthorized modification of unrelated paths.
  10. Add tests proving that instruction-like values are rejected and that records from one user or tenant cannot affect another.
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
Findings (15)

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding

The documented behavior materially differs from the stated purpose: the skill claims focused replanning logic but also introduces a separate persistent learning subsystem, while key 'automatic' replanning/trigger behavior is not clearly implemented. Security reviewers and users may authorize the skill for one purpose while it performs broader stateful actions, which is a trust and transparency failure.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
89% confidence
Finding

The skill documents file-writing behavior via the learner/memory subsystem but does not declare any explicit tool scope or permissions boundary. That mismatch weakens reviewability and allows persistence to occur without clear operator approval, increasing the risk of unintended local state changes or covert data retention.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The skill embeds a persistent self-learning/memory subsystem that records operational history and preferences, even though the manifest presents it as a reflection/replanning component. Hidden or secondary persistence capabilities are dangerous because they expand data collection beyond user expectations and create long-lived local artifacts that may later be exposed or reused improperly.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

Storing user preferences and cross-session usage history is not necessary for core replanning and broadens the data surface substantially. If exploited or mishandled, these records can reveal behavioral patterns, prior errors, and preference data across sessions, enabling profiling or leakage unrelated to the task.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The skill instructs operators to record user preferences, errors, and usage details to a local JSON file without any visible privacy notice, consent mechanism, or retention policy. This creates a meaningful privacy and compliance risk because potentially sensitive operational data is stored persistently without transparent user-facing disclosure.

Content

No source excerpt is available for this finding.

Ssd 3

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

Persisting user preferences and usage details in natural-language notes creates a leakage risk because free-form text often includes sensitive context, file names, error payloads, or personal information. Once written to disk, that data may be accessible to other tools, later prompts, backups, or operators beyond the original task context.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

The example instructs writing a language preference of Chinese into persistent memory as a default workflow, which can bias future behavior without confirming the user's actual preference. While not severe on its own, it demonstrates preference persistence without opt-in and may lead to unwanted personalization or incorrect language handling across sessions.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The manifest describes a capability centered on triggering reflection after verification failure and automatically revising plans to form a planning/verification feedback loop. In this file, the implemented behavior is a generic learner that stores usage stats and returns textual suggestions via self_reflect, with no code that edits plans, invokes verification, or closes a replanning loop.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
82% confidence
Finding

The file-level docstring explicitly says it is a universal learning module callable by any WorkBuddy skill and manages general usage logging, preferences, insights, and retrospective analysis. That is broader than the manifest's narrow purpose of failure-triggered reflection and replanning for this specific skill.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The module description, usage guidance, and user-facing output strings are all in Chinese, which effectively forces a specific language for users without opt-in. The policy allows locale constraints only when choice or clear justification is provided, which is not present here.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
85% confidence
Finding

The code persistently stores arbitrary user preferences without any schema, sensitivity filtering, consent, or retention controls. In skill context, this can accumulate personal or secret-like data unrelated to the replanning purpose, increasing privacy exposure if the skill directory is accessed, synced, or shared.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The script accepts arbitrary skill directories, including direct paths, and then reads/writes learned_patterns.json under that location. In context, this broadens the write surface beyond the named skill and can overwrite or create files in unintended directories if another component passes untrusted paths.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The script writes free-form notes and preferences directly to learned_patterns.json, creating persistent storage for potentially sensitive user content with no warning, redaction, retention policy, or access control. Because notes are arbitrary text, users or upstream tools may inadvertently store secrets, personal data, or internal operational details.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
82% confidence
Finding

The script section presents the skill as scripts/replanner.py with a focused replanning CLI, implying a contained replanning implementation. Later sections assert the skill '内置通用学习模块' that automatically reviews usage and writes learned patterns, which materially changes the skill's behavior and intent compared with the earlier focused description.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
71% confidence
Finding

The top-level documentation says the module is skill-agnostic and only records operations, preferences, insights, and retrospective suggestions. However, self_reflect explicitly recommends writing experience back into SKILL.md, which contradicts the claim of being limited to generic, business-agnostic learning responsibilities.

Content

No source excerpt is available for this finding.