Skip to content

[BUG]: Invalid MCP timeout configurations cause immediate session expiration or cleanup hot loops #281

Open

Description

@Khush7Chauhan

Bug Report 🐛

An audit of the MCP integration's configuration parsing logic reveals that environment variable timeouts are evaluated without lower-bound validation. This absence of boundary checks exposes the runtime to potential resource exhaustion and state corruption.

Expected Behavior

When parsing environment variables like SESSION_TIMEOUT_MS or CLEANUP_INTERVAL_MS, the system should verify that the parsed value is a strictly positive integer. If a deployment environment is provisioned with zero or negative values, the system should either fall back to a safe default or throw a fatal initialization error to prevent silent logical failures.

Current Behavior

In mcp.ts, time-based configuration values are parsed using Number() or parseInt() without verifying positive integer constraints. If a user or deployment script provides an invalid configuration, the system exhibits severe degradation:

  • SESSION_TIMEOUT_MS = -1: Results in all sessions being evaluated as instantaneously expired.
  • CLEANUP_INTERVAL_MS = 0: Forces the cleanup interval to execute continuously (setInterval(..., 0)), effectively blocking the Node.js event loop and exhausting CPU resources.

Possible Solution

Implement a strict parsing utility for time-based environment variables that enforces safe, strictly positive integers before assignment.

Steps to Reproduce

  1. Configure the environment with CLEANUP_INTERVAL_MS=0.
  2. Start the MCP server.
  3. Observe the cleanup interval firing continuously without delay, causing a severe CPU spike and event loop block.

Context (Environment)

  • Impact: Misconfigurations currently cause silent logical failures (dropped sessions) or resource exhaustion (DoS) rather than failing loudly during startup validation.

Desktop

  • OS: Windows 11
  • Browser: Brave
  • Version: Latest

Detailed Description

N/A - See Current Behavior for technical mechanism.

Possible Implementation

Here is a defensive utility function that could safely replace standard parsing to protect the runtime:

const parseEnvMs = (val: string | undefined, defaultValue: number): number => {
    if (val === undefined || val.trim() === '') return defaultValue;

    const parsed = Number(val);
    if (!Number.isSafeInteger(parsed) || parsed <= 0) {
        throw new Error('MCP timeout configuration must be a positive integer.');
    }

    return parsed;
};

Activity

  1. mira-accord-project commented on Nov 13, 2026

    @mira-accord-project

    Thanks for the report. PR #282 (boundary validation for MCP timeout configurations) appears to address this, and it is open and waiting for review.

    Drafted by an Accord Project agent, reviewed by a maintainer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions