T02 · Agent Memory Poisoning
- Location
SKILL.md:51- Finding
Unvalidated Persistent Preference and Instruction Poisoning
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 51-72
Vulnerability Type: Persistent memory poisoning through unvalidated preferences and self-modifying instructions
Risk Level: MediumVulnerable Code Snippet
The following is an English translation of the relevant instructions:
markdown ### Memory File `learned_patterns.json` records operation totals, decision-category frequency, overconfidence calibration alerts, user preferences, and improvement suggestions. ### Invoke After Use # Record a user preference and adopt it directly next time python scripts/learner.py prefer <skill-directory> --key degradation-strategy --val conservative-validation ### Iteration Rules - Overconfidence alerts accumulated at least 3 times: proactively lower the SEEK_HELP threshold for the corresponding domain and write it back to this SKILL.md. - Important user preferences: write them to learned_patterns.json and adopt them directly on the next invocation.Technical Analysis
The skill directs the agent to persist user-provided preferences in
learned_patterns.jsonand automatically apply them during later invocations. It does not define validation, an allowlist of permitted preference values, provenance tracking, user or task isolation, expiration, or confirmation before a stored preference is reused.The iteration rules also direct the agent to modify
SKILL.md. This is more sensitive than recording telemetry because content written into the skill definition may subsequently be treated as authoritative agent instructions whenever the skill is loaded. Consequently, attacker-controlled or otherwise untrusted learned content could cross the boundary from data into persistent instructions.The bundled
scripts/learner.pycurrently stores arbitrary note strings but does not itself interpret them as executable commands or implement the documentedpreferinterface. Therefore, this f ...[truncated 1577 chars]- Remediation
View remediation
Remediation Suggestions
- Treat all learned preferences, notes, and improvement suggestions as untrusted data rather than agent instructions.
- Replace arbitrary strings with a strict schema containing typed fields and narrowly allowlisted values.
- Bind each record to its originating user, task, domain, and workspace so state cannot silently influence unrelated sessions.
- Store provenance, creation time, expiration time, and the identity or context that authorized each preference.
- Require explicit user confirmation before applying a persisted preference in a later session.
- Never automatically rewrite
SKILL.mdfrom runtime observations or user-controlled memory. - Keep immutable skill instructions separate from learned telemetry and proposed configuration changes.
- If threshold adjustment is required, write a proposed change to a review queue and apply it only after validation against calibration data and explicit approval.
- Escape and length-limit free-form notes, and ensure they are never inserted into prompts or instruction files as trusted content.
- Implement the documented command interface consistently and add tests proving that stored data cannot modify instructions or cross user and task boundaries.
