CVE-2026-59951
Memory exhaustion via unbounded session storage in MCP Python SDK HTTP servers.
- CVSS 6.9
- CWE-400
- Resource Management
- Remote
The MCP Python SDK, called mcp on PyPI, is a Python implementation of the Model Context Protocol (MCP). From 1.8.0 until 1.30.0 and 2.2.0, stateful Streamable HTTP servers, including FastMCP, MCPServer, Server.streamable_http_app(), and StreamableHTTPSessionManager, retain session entries without an idle expiration or aggregate session-count limit. DELETE, refused opening requests, and completed sessions do not reliably discard their entries, and each entry can retain parsed initialize parameters. A client that can reach the endpoint can therefore create ordinary short requests that grow server memory without bound until restart. Stateless HTTP, stdio, and SSE transports are not affected. This issue is fixed in versions 1.30.0 and 2.2.0.
- CWE
- CWE-400
- CVSS base score
- 6.9
- Published
- 2026-10-14
- OWASP
- A04 Insecure Design
- Orthogonal defect classification
- Assignment
- Code defect classification
- Missing Check
- Category
- Resource Management
- Subcategory
- Memory Leaks
- Accessibility scope
- Remote
- Impact
- Denial of Service (DoS)
- Affected component
- mcp
- Fixed by upgrading
- Yes
Solution
Upgrade the MCP Python SDK to version 1.30.0 (or later, e.g., 2.2.0) to apply the fix.
Vulnerable code sample
import asyncio
from mcp import FastMCP, Server
# VULNERABLE: unbounded session store retains entries forever
def start_server():
server = FastMCP(host='0.0.0.0', port=8080)
# The FastMCP implementation keeps an internal dict `session_store`
# that grows without limit because no limits or cleanup are configured.
server.session_store = {} # noqa: F841
asyncio.run(server.serve_forever())Patched code sample
import asyncio
from mcp import FastMCP, Server
# FIX: configure idle timeout and session limit to bound memory usage
def start_server():
server = FastMCP(host='0.0.0.0', port=8080, max_sessions=1000, idle_timeout=300)
asyncio.run(server.serve_forever())Published fix
Public sources link this CVE to the changes below. The code samples above were generated to illustrate the defect; these links lead to the code the project actually changed.
- [v1.x] Expire idle Streamable HTTP sessions by default and cap concurrent sessions (#3426) (modelcontextprotocol/python-sdk)
src/mcp/server/fastmcp/server.py,src/mcp/server/fastmcp/server.py · FastMCP.streamable_http_app,src/mcp/server/fastmcp/server.py · FastMCP.__init__,src/mcp/server/streamable_http.py,src/mcp/server/streamable_http.py · StreamableHTTPServerTransport.connect,src/mcp/server/streamable_http.py · StreamableHTTPServerTransport.handle_request,src/mcp/server/streamable_http.py · StreamableHTTPServerTransport._handle_get_request,src/mcp/server/streamable_http.py · StreamableHTTPServerTransport._handle_post_request,src/mcp/server/streamable_http.py · StreamableHTTPServerTransport.__init__,src/mcp/server/streamable_http_manager.py,src/mcp/server/streamable_http_manager.py · StreamableHTTPSessionManager._handle_stateful_request,src/mcp/server/streamable_http_manager.py · StreamableHTTPSessionManager._handle_stateless_requestand 1 more - Expire idle Streamable HTTP sessions by default and cap concurrent sessions (#3395) (modelcontextprotocol/python-sdk)
src/mcp/server/lowlevel/server.py,src/mcp/server/lowlevel/server.py · Server.streamable_http_app,src/mcp/server/mcpserver/server.py,src/mcp/server/mcpserver/server.py · MCPServer.run#3,src/mcp/server/mcpserver/server.py · MCPServer.run_streamable_http_async,src/mcp/server/mcpserver/server.py · MCPServer.streamable_http_app,src/mcp/server/streamable_http.py,src/mcp/server/streamable_http.py · StreamableHTTPServerTransport.connect,src/mcp/server/streamable_http.py · StreamableHTTPServerTransport.handle_request,src/mcp/server/streamable_http.py · StreamableHTTPServerTransport._handle_delete_request,src/mcp/server/streamable_http.py · StreamableHTTPServerTransport.__init__,src/mcp/server/streamable_http_manager.pyand 3 more
Cite this entry
@misc{vaitp:cve202659951,
title = {{Memory exhaustion via unbounded session storage in MCP Python SDK HTTP servers.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2026},
note = {VAITP Python Vulnerability Dataset, entry CVE-2026-59951},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-59951/}}
}
Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.
The supreme art of war is to subdue the enemy without fighting.
Sun Tzu – “The Art of War”
:: Shaping the future through research and ingenuity ::
