GHSA-46jr-4wx8-v453: High severity npm/@modelcontextprotocol/server vulnerability
Summary In affected versions, servers put no limit on how many array elements and object keys they validated in one request. One HTTP request within the default 4 MiB size limit could exhaust the server's memory, and the process aborted with JavaScript heap out of memory.
No credentials are needed, unless you authenticate requests before they reach the SDK.
Am I affected? Yes, if clients you do not fully trust can reach your server over HTTP. The risk is highest for McpServer tools whose input contains an array or a record. stdio-only servers are not affected.
Affected versions:
- @modelcontextprotocol/sdk 1.3.0 through 1.31.0 - @modelcontextprotocol/server 2.0.0 through 2.2.0
Fix Upgrade to:
- 1.x: @modelcontextprotocol/sdk 1.32.0 or later - 2.x: @modelcontextprotocol/server 2.3.0 or later
Upgrading alone changes nothing. The patched versions add an McpServer option, maxToolInputElements, that is off by default. Make both of these changes:
1. Set maxToolInputElements just above the largest input your tools need, for example new McpServer(info, { maxToolInputElements: 10000 }). It counts array elements and object keys in a call's arguments. A call over the limit gets an isError: true result. 2. Lower the request size limit to what your tools need. The option covers tool arguments only, and the size limit covers everything else. Set maxRequestBodySize on the transport or createMcpHandler(). If you parse the body yourself, for example with express.json() or Fastify, set that parser's limit.
If you cannot upgrade yet, make the second change. maxRequestBodySize needs @modelcontextprotocol/sdk 1.30.1 or @modelcontextprotocol/server 2.1.0. Below that, use a reverse proxy.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
npm/@modelcontextprotocol/serverto a version that resolves this vulnerability.Fixed in 2.3.0 - Upgrade
Upgrade
npm/@modelcontextprotocol/sdkto a version that resolves this vulnerability.Fixed in 1.32.0 - Upgrade
Upgrade
@modelcontextprotocol/sdkto a version that resolves this vulnerability.Fixed in 1.32.0 - Upgrade
Upgrade
@modelcontextprotocol/serverto a version that resolves this vulnerability.Fixed in 2.3.0 - Configuration
Set maxToolInputElements on McpServer to limit the number of array elements and object keys validated in tool arguments. The option is off by default in the patched versions.
McpServer maxToolInputElements = Just above the largest input required by the tools, for example 10_000 - Configuration
Set maxRequestBodySize on the transport or createMcpHandler(). If the request body is parsed separately with express.json() or Fastify, set that parser's request-size limit as well. This setting requires @modelcontextprotocol/sdk 1.30.1 or @modelcontextprotocol/server 2.1.0.
MCP transport or createMcpHandler() maxRequestBodySize = Lowered to what the tools need - Compensating control
If the server is below @modelcontextprotocol/sdk 1.30.1 or @modelcontextprotocol/server 2.1.0 and cannot be upgraded, use a reverse proxy to enforce a lower request size limit.
Event History
Frequently Asked Questions
Does upgrading to a patched package version protect the server by itself?
No. In patched versions, maxToolInputElements is off by default. Configure it on McpServer to a value just above the largest input your tools need; it counts array elements and object keys in a call's arguments.
Which deployments are exposed to unauthenticated attacks?
HTTP servers reachable by clients you do not fully trust are exposed, and no credentials are required unless requests are authenticated before reaching the SDK. The highest-risk cases are McpServer tools that accept an array or record as input; stdio-only servers are not affected.
Which package versions need remediation?
Affected versions are @modelcontextprotocol/sdk 1.3.0 through 1.31.0 and @modelcontextprotocol/server 2.0.0 through 2.2.0. Upgrade the SDK to 1.32.0 or later, or the server package to 2.3.0 or later, and configure maxToolInputElements.