T02 · Agent Memory Poisoning
- Location
scripts/learner.py:88- Finding
Persistent memory poisoning through unvalidated learning records
- Content
View full analysis
= THRESHOLD_ERROR: suggestions.append( f"⚠️ 错误「{err}」已出现 {info['count']} 次,建议增加预检/兜底步骤," f"并将经验回写本技能 SKILL.md(lastNote: {info.get('lastNote','')})" ) ``` The associated Skill instructions state: ```markdown python scripts/learner.py prefer <本技能目录> --key 输出语言 --val 中文 python scripts/learner.py insight <本技能目录> python scripts/learner.py reflect <本技能目录> ``` ```markdown - **错误累计 ≥3 次** → 主动增加预检/兜底步骤,并将经验回写本 SKILL.md。 - **重要用户偏好** → 写入 `learned_patterns.json`,下次调用直接采用,减少重复询问。 ``` ### Technical Analysis The `prefer` command accepts arbitrary values through `--key` and `--val`, and `record` similarly accepts arbitrary capability names, error names, and notes. These values are persisted verbatim in `learned_patterns.json` without validation, normalization, trust labeling, or separation between passive data and behavioral instructions. The reflection mechanism subsequently embeds attacker-controlled error names and notes into generated recommendations. The accompanying Skill documentation directs agents to apply stored preferences during later uses and recommends writing accumulated experience back into `SKILL.md` after repeated errors. The code does not itself modify `SKILL.md`; however, the documented workflow creates a persistent poisoning path when an agent fol ...[truncated 1528 chars]- Remediation
View remediation
