T02 · Agent Memory Poisoning
- Location
scripts/extract_skill.py:65- Finding
Stored Prompt Injection Through Unsanitized Skill Generation
- Content
View full analysis
str: """生成 SKILL.md 格式的技能文档""" md = f"""--- name: {skill['name']} description: {skill['description']} --- # {skill['name'].replace('_', ' ').title()} ## When to Use - {skill['when_to_use']} ## Tools Used {', '.join(f'`{t}`' for t in skill['tools_used']) if skill['tools_used'] else '无特定工具'} ## Procedure """ for i, step in enumerate(skill["steps"], 1): md += f"{i}. {step}\n" md += f""" ## Notes - 自动提取自对话记录 - 提取时间: {skill['extracted_at'][:10]} --- *此技能由 skill-extractor 自动生成* """ return md def save_skill(skill: dict) -> str: """保存技能到仓库,返回文件路径""" filename = f"{skill['name']}_{skill['extracted_at'][:10]}.md" filepath = SKILLS_DIR / filename md = generate_skill_markdown(skill) filepath.write_text(md, encoding="utf-8") ``` ### Technical Analysis The extractor treats the task description and conversation history as trusted skill-authoring input. Content parsed from the conversation is placed directly into the generated `## Procedure` section, while task text is inserted into YAML frontmatter and the `## When to Use` section. No semantic validation, instruction filtering, frontmatter escaping, or trust-boundary marking is applied before the document is written to the persistent local skill repository. An attacker who can influence a conversation can include list items that look like legitimate procedural steps but contain instructions to override p ...[truncated 2724 chars]- Remediation
View remediation
