T02 · Agent Memory Poisoning
- Location
scripts/learner.py:58- Finding
Unsanitized Persistent Preferences Can Poison Future Agent Sessions
- Content
View full analysis
--capability ResumeOptimization python scripts/learner.py record --capability ResumeOptimization --fail --error FormatRecognitionFailure --note "The user uploaded a non-standard file" python scripts/learner.py prefer --key OutputLanguage --val Chinese python scripts/learner.py insight python scripts/learner.py reflect ``` ### Iteration Rules - Important user preferences are written to `learned_patterns.json` and directly adopted during the next invocation to reduce repeated questions. ``` The implementation accepts arbitrary keys and values and writes them directly into the persistent JSON file: ```python def load_learning(skill_dir): p = learn_path(skill_dir) try: return json.loads(open(p, encoding="utf-8").read()) except Exception: return default_data(os.path.basename(skill_dir)) def save_learning(skill_dir, data): data["lastUpdated"] = datetime.datetime.now().strftime("%Y-%m-%dT%H:%M") p = learn_path(skill_dir) with open(p, "w", encoding="utf-8") as f: f.write(json.dumps(data, in ...[truncated 3828 chars]- Remediation
View remediation
