T02 · Agent Memory Poisoning
- Location
SKILL.md:52- Finding
Persistent Agent Memory and Instruction Poisoning
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 52-71
Vulnerability Type: Persistent storage of user-controlled preferences and failure-derived instructions
Risk Level: HighVulnerable Excerpt
The following is an English translation of the security-relevant directives:
text This skill includes the general learning module scripts/learner.py. After each use, it automatically reviews the operation and accumulates experience to improve future output quality and execution efficiency without manual maintenance. learned_patterns.json records operation counts, capability usage frequency, error patterns, user preferences, and improvement suggestions. Error count greater than or equal to three: proactively add preflight or fallback steps and write the experience back into SKILL.md. Important user preferences: write them into learned_patterns.json and apply them directly the next time the skill is invoked.Related instructions also appear in
SKILL.md, lines 31-35, where the skill states that learned information is injected into a cross-session evolution loop.Technical Analysis
The skill directs the Agent to retain user-controlled preferences, notes, and failure-derived rules across sessions. More critically, it instructs the Agent to write accumulated experience back into
SKILL.md, which is itself an instruction source loaded by future Agent sessions.This design fails to separate untrusted task data from trusted Agent instructions. If attacker-controlled content is accepted as a preference, error note, or improvement rule and later written into the skill document, that content can become a durable instruction. Future invocations may then treat it as authoritative rather than as untrusted historical data.
Although the included
learner.pydoes not itself modifySKILL.md, the skill text explicitly tells the executing Agent to perform that modification. The vulnerability there ...[truncated 1262 chars]- Remediation
View remediation
Remediation Suggestions
- Remove all runtime instructions that permit automatic modification of
SKILL.md. - Keep executable instructions immutable and separate from learned telemetry.
- Store only structured values under a strict schema; never store arbitrary text as a future behavioral rule.
- Treat every stored note and preference as untrusted data, not as an instruction.
- Reject or neutralize imperative content, role directives, tool-use requests, and prompt-like text in stored fields.
- Scope retained state by user, tenant, and task to prevent cross-user contamination.
- Require explicit, informed user approval before retaining a preference across sessions.
- Apply expiration policies and provide mechanisms to inspect and delete retained data.
- Require trusted human review before promoting any observation into an Agent policy.
- Ensure future prompts delimit retained data and explicitly prohibit following instructions contained within it.
- Remove all runtime instructions that permit automatic modification of
