MCP06
- Location
dist/index.js:63- Finding
Remote Plan Metadata Is Injected into Agent Prompt Context ## Remediation Suggestions 1. Use administrator-approved local display names in instruction-bearing prompt context instead of remote plan names. 2. Separate trusted payment instructions from externally sourced metadata. 3. Present remote metadata as explicitly untrusted structured data, with clear instructions not to interpret its contents as operational guidance. 4. Apply reasonable length limits and normalize control characters and line breaks. Treat these measures as defense in depth, not a complete prompt-injection defense. 5. Enforce purchase approval, destination authorization, and sensitive-tool permissions outside the model. 6. Add regression tests using plan names containing multiline instructions and forged payment guidance.
- Content
View full analysis
Vulnerability Details
File Location:
plugin/dist/index.js:63–78, 273–285
Vulnerability Type: Indirect prompt injection
Risk Level: HighVulnerable Code
Remote plan metadata is retrieved and incorporated into the catalog:
javascript const balances = await Promise.all(plans.map(async (plan) => { try { const b = await p.plans.getPlanBalance(plan.planId); return { ...plan, planName: b.planName ?? plan.name ?? plan.planId, balance: Number(b.balance), isSubscriber: b.isSubscriber, }; } catch { return { ...plan, planName: plan.name ?? plan.planId, balance: 0, isSubscriber: false }; } })); const text = formatPlanCatalog(balances, config.creditsPerMinute, config.creditsPerRequest); catalogCache = { text, fetchedAt: now }; return { prependContext: text };The catalog formatter directly interpolates the remote plan name:
javascript for (const p of plans) { const method = p.paymentType === 'fiat' ? 'Credit Card' : 'Crypto (USDC)'; const priceStr = p.price ? ` — ${p.price}` : ''; const creditsStr = p.credits ? ` for ${p.credits} credits` : ''; if (p.paymentType === 'crypto') { const balanceStr = p.isSubscriber ? ` [balance: ${p.balance} credits]` : ' [not subscribed]'; lines.push(` ${p.planName} (${method})${priceStr}${creditsStr}${balanceStr}`); } else { lines.push(` ${p.planName} (${method})${priceStr}${creditsStr} [auto-charge]`); } }Technical Analysis
The
before_prompt_buildhook retrieves externally supplied plan names and places them directly into prepended model context. There is no length restriction, control-character handling, or explicit separation identifying these names as untrusted data.The catalog also contains legitimate behavioral instructions about payments, purchases, and bookings. Consequently, malicious text embedded in a plan name appears alongside truste ...[truncated 1647 chars]
