CWE-770
- Location
plugin/dist/.setup/runtime-entry-DAVdRwFP.mjs:1617- Finding
Inbound Calls Bypass the Configured Concurrent Call Limit ## Remediation Suggestions 1. **Centralize admission control.** Apply a shared capacity check to outbound initiation, inbound event admission, callback admission, and realtime stream setup. 2. **Reserve capacity atomically.** Within the serialized admission operation, compare active calls plus pending admissions against `maxConcurrentCalls` and reserve a slot before persisting a new admitted call, answering it, or issuing a stream session. 3. **Reject excess calls safely.** Return the appropriate carrier rejection response or terminate the excess call without starting media or agent work. Keep rejection handling idempotent across webhook retries. 4. **Release reservations reliably.** Release pending reservations on provider errors, persistence failures, cancellation, and shutdown. Release active capacity when calls terminate. 5. **Cover all inbound paths.** Ensure realtime Twilio setup and other carrier event paths cannot bypass the shared admission mechanism. 6. **Add regression tests.** With `maxConcurrentCalls: 1`, test overlapping signed inbound events, mixed inbound/outbound traffic, simultaneous admission attempts, callbacks, realtime admission, and webhook retries. Verify that only one call is admitted and that failed admissions do not leak capacity. 7. **Use operational safeguards.** Until patched, restrict inbound callers where feasible and configure carrier-side concurrency and spending limits. These reduce exposure but do not replace application-level enforcement.
- Content
View full analysis
Vulnerability Details
File Location:
plugin/dist/.setup/runtime-entry-DAVdRwFP.mjs:1617–1694
Related Control:plugin/dist/.setup/runtime-entry-DAVdRwFP.mjs:1109–1113
Vulnerability Type: Uncontrolled Resource Consumption — CWE-770
Risk Level: MediumVulnerable Code
The new-call event branch checks inbound caller policy but does not check concurrent-call capacity:
js if (!call && providerCallId && event.direction) { const callback = event.direction === "inbound" && ctx.config.realtime.enabled ? await findRecentOutboundCallback(ctx, event.from) : void 0; if (event.direction === "inbound" && !callback && !shouldAcceptInbound(ctx.config, event.from)) {After the policy-rejection branch, the complete admission segment at lines 1658–1694 creates and registers the call without enforcing
maxConcurrentCalls:js const callId = crypto.randomUUID(); const from = event.from || "unknown"; const to = event.to || ctx.config.fromNumber || "unknown"; const { config: effectiveConfig, numberRouteKey } = resolveVoiceCallEffectiveConfig( ctx.config, event.direction === "inbound" ? to : void 0 ); const agentId = normalizeAgentId(callback?.agentId ?? effectiveConfig.agentId); call = { callId, providerCallId, provider: ctx.provider?.name || "twilio", direction: event.direction, state: "ringing", from, to, sessionKey: resolveVoiceCallSessionKey({ config: { ...effectiveConfig, agentId }, callId, phone: event.direction === "outbound" ? to : from, coreSession: ctx.coreSession }), agentId, startedAt: Date.now(), transcript: [], processedEventIds: [], metadata: { initialMessage: event.direction === "inbound" ? effectiveConfig.inboundGreeting || "Hello! How can I help you today?" : void 0, ...numberRouteKey ? { numberRouteKey } : {}, ...callback ? ...[truncated 3735 chars]
