T01 · Skill Instruction Hijacking
Error
- Location
- scripts/commands/agents.sh:129
- Finding
- Indirect Prompt Injection Through Repository-Controlled Content<![CDATA[ ## Vulnerability Details **File Location**: `scripts/commands/agents.sh:129-168`; `prompts/agent-analysis.md:12-35, 88-92` **Vulnerability Type**: Indirect prompt injection **Risk Level**: High ### Vulnerable Code ```bash # Get sample commit messages local commit_samples=$(db_query "SELECT message FROM commits WHERE project_id = '$project_id' ORDER BY timestamp DESC LIMIT 10" | jq -r '.[].message | split("\n")[0]' | head -10) # Build the complete prompt local prompt="$prompt_template" prompt="${prompt//\{\{ project_name \}\}/$project_name}" prompt="${prompt//\{\{ repository \}\}/$repo}" prompt="${prompt//\{\{ days \}\}/$analysis_days}" prompt="${prompt//\{\{ commit_count \}\}/$commit_count}" prompt="${prompt//\{\{ agent_content \}\}/$agent_content}" prompt="${prompt//\{\{ commit_types \}\}/$commit_types_formatted}" prompt="${prompt//\{\{ file_patterns \}\}/$topics_formatted}" prompt="${prompt//\{\{ revert_count \}\}/$(echo "$patterns" | jq '.churn.count')}" prompt="${prompt//\{\{ typo_fix_count \}\}/$(echo "$patterns" | jq '.churn.count')}" prompt="${prompt//\{\{ repeated_patterns \}\}/See topics above}" prompt="${prompt//\{\{ commit_samples \}\}/$commit_samples}" # Output the prompt for the LLM echo "" echo "$prompt" ``` The corresponding prompt template inserts the content directly into an instruction-bearing Markdown document: ```markdown ## Current Agent Instructions ```markdown {{ agent_content }} ``` ### Commit Message Samples {{ commit_samples }} ## Your Task Analyze the agent instructions against the commit patterns and identify: ``` ### Technical Analysis Agent instruction files and commit messages are controlled by repository contributors. They are inserted directly into a prompt that is intended to be sent to an LLM. The template does not establish a trust boundary or tell the LLM that embedded directives must be treated exclusive ...[truncated 1489 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Treat agent files, commit messages, project names, and repository metadata as untrusted data. 2. Put untrusted values in a structured data message separate from the controlling instructions. 3. Add explicit instructions that the model must not follow commands found in repository content. 4. Encode or escape Markdown fence delimiters before interpolation. 5. Prefer a JSON request structure with separately named fields over free-form string substitution. 6. Validate the LLM response against a strict JSON schema and reject additional fields or non-JSON text. 7. Require explicit human approval before applying generated recommendations. 8. Limit downstream tools available during this analysis to read-only operations. ]]>
