MCP06
- Location
src/hook-core.mjs:1694- Finding
Remote Registry Metadata Is Promoted into System-Level Agent Context ## Remediation Suggestions 1. **Separate trusted instructions from remote content.** Keep lifecycle rules in locally maintained templates. Deliver registry descriptions, explanations, and other external text as explicitly untrusted structured data rather than concatenating them into system instructions. 2. **Remove free-form remote instruction fields from the system-context path.** Replace `contribution_directive.message` and `fallback_instruction` with a strict, validated action enumeration. Render supported actions using fixed local text; ignore unsupported values. 3. **State the authority boundary explicitly.** In trusted local instructions, prohibit registry metadata from authorizing credential access, unrelated tool execution, data export, approval changes, or exceptions to host policy. Delimiters alone should not be treated as a complete defense. 4. **Require deliberate skill selection before loading procedural content.** Automatic discovery should expose bounded descriptive metadata, not implicitly authorize execution of returned instructions. 5. **Preserve independent enforcement.** Maintain host approvals and destination restrictions for sensitive reads, network exports, and mutations. Apply these controls outside model-generated decisions wherever possible. 6. **Add adversarial regression tests.** Test malicious descriptions, match explanations, preference text, and fallback directives. Verify both the produced prompt structure and, in a controlled gateway environment, whether injected content can induce unauthorized tool calls.
- Content
View full analysis
Vulnerability Details
File Location:
src/hook-core.mjs:1694–1830— formats remote registry metadata and directives as agent context.src/hook-core.mjs:14821–14827— applies text redaction and truncation without separating instructions from data.src/index.mjs:606–610— returns the resulting text throughappendSystemContext.
Vulnerability Type: Indirect prompt injection through a remote-content trust boundary
Risk Level: Medium
Confidence: High for the unsafe data flow; downstream agent compliance was not dynamically verified.Complete Relevant Code Segments
The following complete conditional block in
formatContextincorporates a free-form instruction from the remote response:js const contributionDirective = body?.contribution_directive?.message ?? body?.fallback_instruction; if (contributionDirective) { requiredTailLines.push( `After using Remembrance: ${safeText(contributionDirective, MAX_DIRECTIVE_CHARS)}`, ); }The text-handling function is:
js function safeText(value, maxLength) { const text = redactPrompt(stringValue(value)).replace(/\s+/g, " ").trim(); if (text.length <= maxLength) { return text; } return `${text.slice(0, Math.max(0, maxLength - 3)).trim()}...`; }The OpenClaw adapter exposes the composed context through this complete return block:
js return { appendSystemContext: result.context, };Technical Analysis
The automatic prompt hook requests search results from the configured registry’s
/api/v1/agent/queryendpoint. Its formatter incorporates remote skill descriptions, match explanations, and free-form contribution instructions into text that the OpenClaw adapter supplies as system context.The inspected
safeTextfunction performs secret-pattern redaction, whitespace normalization, and length limiting. These operations do not prevent behavioral instructions from surviving. A short, ordinary-language instruction does not require special charac ...[truncated 2918 chars]
