T02 · Agent Memory Poisoning
- Location
scripts/learner.py:10- Finding
Untrusted Input Written to Persistent Agent Learning State
- Content
View full analysis
1 else True rec = (sys.argv[2] if len(sys.argv) > 2 else "") print(json.dumps(record(ok, rec), ensure_ascii=False)) ``` ### Technical Analysis The script accepts its second command-line argument as an unrestricted note and appends it directly to the persistent `patterns` collection in `learned_patterns.json`. It does not validate the note's origin, content, structure, semantics, or length. The skill documentation characterizes this file as cross-session learning state used by a broader reflection and evolution process. If another agent component subsequently interprets these entries as trusted learned guidance, an attacker who can influence the command-line note can persist arbitrary rules or misleading instructions across sessions. The included script does not itself execute or interpret the stored text. Exploitation beyond state corruption therefore depends on a downstream agent or evolution component consuming `patterns` as trusted guidance. ### Attack Path 1. An attacker supplies content through a task, operation result, or other input that reaches the learner invocation. 2. A caller passes the attacker-controlled content as the second command-line argument to `learner.py`. 3. The script assigns that argument to `rec` without validation. 4. `record()` appends the content to the persistent `patterns` array. 5. The modified state remains in `scripts/learned_patterns.json` across later invocations. 6. If a downstr ...[truncated 693 chars]- Remediation
View remediation
