T01 · Skill Instruction Hijacking
- Location
index.js:456- Finding
Untrusted Git Diff Content Can Inject Instructions into the AI Prompt
- Content
View full analysis
0) { output = `⚠️ 警告:\n${warnings.map(w => ` - ${w}`).join('\n')}\n\n---\n\n`; } output += `请根据以下 Git diff 生成 commit message: --- ## Git Diff 内容: \`\`\`diff ${diff} \`\`\` --- ## 分析要求: ${systemPrompt} --- 请生成符合规范的 commit message,只输出 message 本身,不要其他解释。`; return output; ``` ### Technical Analysis The skill inserts the complete staged Git diff into an AI prompt without treating it as untrusted input. A Git diff may contain attacker-controlled text from source files, comments, documentation, test fixtures, filenames, or configuration files. Markdown code fences do not create a security boundary for a language model. An attacker can stage text that instructs the model to ignore the commit-message task, disclose available context, generate unrelated content, or attempt to invoke tools. The generated prompt does not explicitly prohibit following instructions found inside the diff, and it does not use a structured or isolated data channel. The effective severity depends on the host agent. If the receiving model only returns text and has no tool access, the likely consequence is manipulation of the generated commit message. If the host processes the returned prompt in a tool-enabled agent context, the injection could attempt broader actions subject to that host's permissions and safety controls. ### Attack Path 1. An attacker contributes a tracked file containing instructions directed at an AI agent. 2. A user reviews or receives the repository changes and stages the malicious file with `git add`. 3. The skill executes `git diff --cached` and reads the attacker-controlled instructions. 4. The skill interpolates the diff verbatim into th ...[truncated 802 chars]- Remediation
View remediation
