T01 · Skill Instruction Hijacking
- Location
src/code-review.js:76- Finding
AI Code Review Is Vulnerable to Prompt Injection from Untrusted Source Files
- Content
View full analysis
0) { localFindingsText = '\n\nLocal static analysis already detected these issues (incorporate and expand on them):\n'; for (const issue of localIssues) { localFindingsText += `- Line ${issue.line}: [${issue.severity}] ${issue.message}\n`; } } const truncated = code.length > MAX_CODE_CHARS; const codeContent = truncated ? code.substring(0, MAX_CODE_CHARS) + '\n\n... [truncated at 8000 chars]' : code; return `Review the following code from file "${filePath}":${localFindingsText} \`\`\` ${codeContent} \`\`\` Respond with valid JSON only.`; } ``` ### Technical Analysis The application inserts untrusted source-code content directly into the AI model's user prompt. Source files may contain comments, string literals, documentation, or other text that instructs the model to disregard its system prompt, suppress findings, assign an artificially high score, or produce fabricated review results. Markdown code fences are presentational delimiters rather than a security boundary. They do not reliably prevent a language model from interpreting embedded natural-language content as instructions. The returned AI result replaces the local findings in the final response rather than being merged with them. Consequently, successful prompt injection can suppress issues that the local analysis already detected, further increasing the integrity impact. ### Attack Path 1. An attacker adds a comment or string containing adversarial instructions to a source file. 2. A victim runs `CodeReview.review()` or `CodeReview.reviewDir()` with an AI model configured. 3. `_buildUserPrompt()` embeds the attacker-controlled ...[truncated 972 chars]- Remediation
View remediation
