T02 · Agent Memory Poisoning
- Location
scripts/learner.py:88- Finding
Unvalidated Persistent Preferences Can Influence Future Agent Behavior
- Content
View full analysis
Vulnerability Details
File Location:
scripts/learner.py:88-92; related behavioral instructions inSKILL.md:60,67-70
Vulnerability Type: Persistent memory poisoning through attacker-controlled preference data
Risk Level: MediumVulnerable Code
python def record_preference(skill_dir, key, value): data = load_learning(skill_dir) data["preferences"][key] = value save_learning(skill_dir, data) return dataThe command-line interface accepts the preference key and value without validation:
python p_pre = sub.add_parser("prefer"); p_pre.add_argument("skill_dir") p_pre.add_argument("--key", required=True); p_pre.add_argument("--val", required=True)The associated Skill instructions state that important preferences are persisted in
learned_patterns.jsonand should be applied during subsequent use. They also encourage accumulated experience to be written back intoSKILL.md.Technical Analysis
record_preferencepersists arbitrary key and value strings without a schema, allowlist, provenance marker, integrity protection, or review workflow. The stored preferences are not interpreted or executed bylearner.pyitself. However, the Skill documentation instructs future agents to consult and apply this persistent state.This creates a cross-session influence channel: data supplied by a user or another process can be stored as if it were a trusted operational preference and later affect an agent that loads the Skill. An instruction-like value could attempt to alter evaluation behavior, suppress checks, or cause unsafe guidance to be incorporated into future Skill instructions.
The issue is constrained by two factors:
- The attacker must be able to invoke the learner or modify the Skill's state file.
- The current Python implementation does not automatically execute preference values or rewrite
SKILL.md; exploitation depends on a future agent treating the store ...[truncated 1295 chars]
- Remediation
View remediation
Remediation Suggestions
- Define a strict schema for preferences and permit only documented keys and typed values.
- Reject multiline values, instruction-like content, control characters, and values exceeding a conservative length limit.
- Store provenance with every preference, including who supplied it, when it was supplied, and whether it was explicitly approved.
- Treat persisted preferences as untrusted data rather than agent instructions.
- Require explicit user confirmation before a stored preference affects behavior in a later session.
- Do not automatically or procedurally copy learned state into
SKILL.md. - Require human review and a visible diff before modifying Skill instructions.
- Add integrity controls or access restrictions if the state is shared among multiple users.
- Provide commands to inspect, revoke, and reset persisted preferences.
