MCP06
- Location
plugin/dist/stream.js:61- Finding
Historical Tool Results Promoted to User Messages Enable Prompt Injection ## Remediation Suggestions 1. **Preserve tool-output provenance.** Use a provider-supported representation that retains the distinction between tool data and user instructions. Do not assign raw tool results to the `user` role. 2. **Fail safely when history cannot be represented.** If unsigned tool history is incompatible with the provider, omit the affected call/result batch with an explicit diagnostic, or reject the replay. Do not silently promote its contents to user input. 3. **Treat textual framing as defense in depth only.** If a textual fallback is unavoidable, clearly identify external content as untrusted, use structured encoding, and add trusted instructions prohibiting its interpretation as commands. These measures do not replace protocol-level role separation. 4. **Retain independent action controls.** Require authorization for sensitive tool actions regardless of model instructions, particularly filesystem writes, command execution, credential access, and outbound data transfers. 5. **Add regression coverage.** Test unsigned Gemini 3 history containing malicious tool results, including delimiter-breaking text and requests for sensitive actions. Assert that attacker-controlled output is never emitted as a user-role message. Also verify that signed history retains the intended tool-call associations.
- Content
View full analysis
Vulnerability Details
File Location:
plugin/dist/stream.js:61–77,applyVeniceGeminiToolHistoryCompatibility
Vulnerability Type: Prompt injection through loss of tool-output provenance
Risk Level: MediumVulnerable Code
javascript if (record.role === "tool") { const toolCallId = typeof record.tool_call_id === "string" ? record.tool_call_id : void 0; if (!toolCallId) continue; const pendingCalls = pendingDowngradedToolCalls; if (!pendingCalls) continue; const toolNames = pendingCalls.get(toolCallId); if (!toolNames) continue; const toolName = toolNames.shift(); if (!toolName) continue; if (toolNames.length === 0) pendingCalls.delete(toolCallId); const result = stringifyHistoricalValue(record.content); for (const key of Object.keys(record)) delete record[key]; record.role = "user"; record.content = `[Historical tool result for ${toolName}:\n${result}]`; continue; }Technical Analysis
The stream wrapper implements a compatibility fallback for Venice Gemini 3 models. When a historical tool-call batch lacks a matching thought signature, it converts the batch into textual history. Associated tool results are then rewritten from
toolmessages intousermessages.The vulnerable segment copies tool-result content verbatim, deletes the original message fields, and assigns
record.role = "user". This removes structured tool provenance and places potentially attacker-controlled data in a role normally reserved for user input.The surrounding
[Historical tool result ...]label provides contextual guidance but does not enforce a security boundary. Instructions embedded in the result remain part of a user-role message.This is a conditional prompt-injection weakness, not evidence of intentional malicious behavior. Exploitation requires attacker-controlled tool output and replay through the affected compatibility fallback.
Attack Path
- An attacker controls content consumed by a ...[truncated 1736 chars]
