MCP05
- Location
src/gateway/powpow-gateway.ts:182- Finding
Unbounded Inbound Message Queue Allows Remote Resource Exhaustion ## Remediation Suggestions 1. **Bound queue capacity:** Enforce both a maximum queued-message count and a cumulative byte budget before accepting a message. 2. **Define safe overflow behavior:** Apply a documented rejection, expiration, or bounded persistent-spooling policy when capacity is reached. 3. **Authorize before buffering:** Resolve sender access before retaining messages in the processing queue. Keep any authorization-stage buffer bounded as well. 4. **Apply sender and session quotas:** Limit message rates and outstanding work per identity so one visitor cannot monopolize the channel. 5. **Limit inbound payload sizes:** Reject oversized message content and unnecessary metadata before queue admission. 6. **Introduce backpressure and deadlines:** Coordinate polling with available queue capacity and place deadlines on dispatch operations. Ensure cursor handling does not silently discard messages when polling is deferred. 7. **Minimize retained data:** Avoid retaining complete raw records when only selected fields are required. 8. **Verify under load:** Test sustained arrivals above dispatch throughput, slow agent responses, delivery failures, oversized messages, and unauthorized senders. Confirm that memory remains bounded and legitimate traffic retains service.
- Content
View full analysis
Vulnerability Details
File Location:
src/gateway/powpow-gateway.ts:182–207; compiled equivalent:dist/gateway/powpow-gateway.js:121–150
Vulnerability Type: CWE-400 / CWE-770 — Uncontrolled Resource Consumption
Risk Level: MediumVulnerable Code
typescript let inboundQueue: NormalizedInbound[] = []; let processing = false; const processQueue = async (): Promise<void> => { if (processing) return; processing = true; try { while (inboundQueue.length > 0) { const next = inboundQueue.shift(); if (!next) break; await dispatchInbound(next); } } finally { processing = false; } }; const handleInbound = (inbound: NormalizedInbound | null): void => { if (!inbound) return; if (!dedup.markSeen(inbound.messageId)) return; inboundQueue.push(inbound); void processQueue().catch((err) => { ctx.log?.error?.( `[${account.accountId}] PowPow inbound dispatch failed: ${String(err)}` ); }); };Technical Analysis
The plugin appends incoming messages to
inboundQueuewithout enforcing a maximum message count, cumulative byte budget, or per-sender quota. A single worker processes this queue serially, awaitingdispatchInbound(next)before handling the next message. Dispatch includes agent processing and reply delivery.History polling continues independently while dispatch is in progress. Its message callback enqueues messages without waiting for the queue to drain. Consequently, sustained arrivals exceeding the worker’s processing rate create an increasing backlog.
The configured history page limit bounds individual fetches, not cumulative queued messages. Likewise, the deduplication map only suppresses previously seen identifiers; it does not cap the queue. Distinct messages bypass deduplication normally. Normalized messages also retain their original record through the
rawfield.Sender authorization occurs inside `dispatchInbou ...[truncated 1946 chars]
