CWE-400
- Location
plugin/dist/.setup/runtime-entry-Br7ttAwq.mjs:3202- Finding
Inbound Realtime Calls Bypass the Configured Concurrent Call Limit ## Remediation Suggestions 1. **Centralize capacity enforcement.** Apply the concurrent-call check in the manager’s serialized admission path before persisting or activating any new call, regardless of direction, carrier, or callback origin. 2. **Reserve capacity before stream setup.** Acquire a pending inbound reservation before issuing realtime stream credentials or answering a call. Include pending inbound reservations, pending outbound reservations, and active calls in the capacity calculation. 3. **Make reservations lifecycle-safe.** Bind each reservation to its carrier call identifier. Atomically convert it to an active call, and release it on rejection, expiration, failed setup, termination, or shutdown. Retries must not consume duplicate reservations. 4. **Handle excess calls explicitly.** Reject or place them in a bounded queue without opening realtime model sessions. Do not rely on carrier signatures, request throttling, or per-call timeouts as substitutes for capacity enforcement. 5. **Add regression tests.** With `maxConcurrentCalls: 1`, verify that overlapping inbound calls cannot both become active. Also test mixed inbound/outbound admissions, callbacks, concurrent arrivals, duplicate webhooks, expired stream credentials, and cleanup after setup failures. 6. **Monitor enforcement.** Record active calls, pending reservations, and capacity rejections without logging stream credentials or sensitive conversation data.
- Content
View full analysis
Vulnerability Details
File Location:
plugin/dist/.setup/runtime-entry-Br7ttAwq.mjs:3202–3212— realtime inbound admission.plugin/dist/.setup/runtime-entry-Br7ttAwq.mjs:1616–1651— accepted inbound call creation and registration.plugin/dist/.setup/realtime-handler-BkoZ-ZYd.mjs:1699–1724— realtime stream admission into the call manager.plugin/dist/.setup/runtime-entry-Br7ttAwq.mjs:1070–1074— contrasting outbound concurrency enforcement.
Vulnerability Type: Uncontrolled Resource Consumption — CWE-400
Risk Level: MediumVulnerable Code
The complete realtime inbound admission function checks caller policy but does not check or reserve concurrent-call capacity:
js async function acceptRealtimeInboundRequest(params) { if (params.config.inboundPolicy === "open") return true; if ((params.config.inboundPolicy === "allowlist" || params.config.inboundPolicy === "pairing") && isAllowlistedCaller(normalizePhoneNumber(params.form.get("From") ?? void 0), params.config.allowFrom)) return true; if (!params.config.callbacks.enabled) return false; const parsed = params.provider.parseWebhookEvent(params.request, { verifiedRequestKey: params.verifiedRequestKey }); await params.processEvents(parsed.events); const providerCallId = params.form.get("CallSid"); return Boolean(providerCallId && params.manager.getCallByProviderCallId(providerCallId)); }The complete downstream realtime preparation function also has no capacity check. For a new incoming call, it submits an initiation event to the manager and retrieves the resulting active call:
js async prepareCallInManager(callSid, callerMeta = {}) { const baseFields = { providerCallId: callSid, timestamp: Date.now(), direction: callerMeta.direction ?? "inbound", ...callerMeta.from ? { from: callerMeta.from } : {}, ...callerMeta.to ? { to: callerMeta.to } : {} }; let callRecord; if (callerMeta.callId) { const call = await this.manager.getCallForStream(callerMeta.c ...[truncated 3675 chars]
