T01 · Skill Instruction Hijacking
- Location
references/prompts.md:8- Finding
Untrusted Repository Content Can Hijack Model Instructions
- Content
View full analysis
` 的形式 - 让 Claude(自己)生成一个 JSON 对象 `{"文件路径": "摘要"}` - 合并所有批次的摘要,得到完整的 `code_summary` 字典 ``` `references/prompts.md:8-31`: ```text 你是一名资深软件工程师。请阅读以下代码文件列表,为每个文件生成一句话摘要(不超过30字),概括其业务功能。 只输出一个 JSON 对象,格式为 {"文件路径": "一句话摘要", ...},不要任何多余内容。 注意: - 摘要要体现业务语义(如"处理用户登录逻辑"),而非技术细节(如"定义了3个类") - 最多提及关键类名或方法名 - 不要超过30字 $FILES ``` The `$FILES` value is populated as follows: ```text === 文件: path/to/file1.py === <文件内容> === 文件: path/to/file2.java === <文件内容> ``` ### Technical Analysis The Skill directly inserts attacker-controlled source-file contents into an Agent prompt. The prompt does not establish that repository content is untrusted data and does not instruct the model to ignore commands, role changes, output overrides, or tool-use requests found inside source files. Comments, strings, documentation blocks, or other text in a scanned repository can therefore contain instructions that compete with the Stage 1 prompt. If followed, those instructions can alter the generated summary JSON. The resulting summaries are then trusted by Stage 2 and Stage 3, allowing the injected instructions to influence architecture nodes, file associations, relationship data, and Mermaid content. The output requirement to return JSON is not a security boundary. An attacker can ask the model to return syntactically valid but misleading or payload-bearing JSON. ### Attack Path 1. An attacker places instruction-like content inside a supported source file, such as a `.py`, `.js`, or `.ts` file. 2. `scan_repo.py` reads that file and returns its complete contents. 3. The Skill inserts ...[truncated 1101 chars]- Remediation
View remediation
