T01 · Skill Instruction Hijacking
Warning
- Location
- git_log_intelligence.py:112
- Finding
- Untrusted GitHub Commit Content Is Passed into the Agent Context Without Prompt-Injection Boundaries<![CDATA[ ## Vulnerability Details **File Location**: `git_log_intelligence.py:112-133`; related agent instructions in `SKILL.md:31-36` and `SKILL.md:63-65` **Vulnerability Type**: Untrusted remote content incorporated into AI-agent instructions **Risk Level**: Medium ### Complete Code Snippet ```python for c in commits: full_msg = c['commit']['message'] subject = full_msg.split('\n')[0] # 1. Filter based on subject line if any(re.search(p, subject, re.IGNORECASE) for p in filters): filtered_out += 1 continue # 2. Collect data based on flag sha = c['sha'][:7] author = c['commit']['author']['name'] if len(important) >= MAX_LINES: capped_out += 1 continue if full_context: # Truncate long messages to protect the agent's context window content = (full_msg[:MAX_MSG_LEN] + '...') if len(full_msg) > MAX_MSG_LEN else full_msg important.append(f"COMMIT: {sha}\nAUTHOR: {author}\nMESSAGE:\n{content}\n{'-'*20}") else: important.append(f"- {sha}: {subject} ({author})") ``` The corresponding Skill instructions state: ```markdown ### Agent Logic: Call the script with the repo name and timeframe. Receive a filtered list of "Important" commits. Present a natural language summary to the user, noting how many noisy commits were hidden. ``` ### Technical Analysis Commit messages, commit subjects, and author names are controlled by repository contributors. The implementation retrieves these fields from GitHub and places them directly into text intended for processing by an AI agent. The output does not establish a strong trust boundary around the remote content. In particular, the Skill does not instruct the agent to: - Treat all repository metadata as untrusted data rather than instructions. - Ignore directives, tool requests, links, or requests for disclosure embedded in commit text. - Avoid changing its goals or invoking tools based on retrieved cont ...[truncated 2005 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Add an explicit trust-boundary rule to `SKILL.md` stating that commit messages, author names, repository metadata, URLs, and API responses are untrusted data and must never be interpreted as instructions. 2. Require the agent to summarize only factual repository activity and prohibit tool calls, secret disclosure, goal changes, or navigation based on fetched content. 3. Return structured JSON rather than presentation-oriented text. Use fixed fields such as `sha`, `author`, `subject`, and `message`, and tell the agent that field values are data only. 4. Wrap remote content in clear delimiters and identify its origin before presenting it to the agent. 5. Normalize or remove control characters and other formatting that could blur the boundary between trusted instructions and remote content. 6. Keep full-message mode opt-in and consider reducing its maximum length or extracting factual fields before the content reaches the agent. 7. Add adversarial tests containing commit messages such as tool requests, system-style instructions, and requests to disclose secrets. Verify that the agent only summarizes them as quoted repository content. ]]>
