Summary
MCP-Framework: Unbounded memory allocation in readRequestBody allows denial of service via HTTP transport
The readRequestBody() function in src/transports/http/server.ts concatenates HTTP request body chunks into a string with no size limit, allowing a remote unauthenticated attacker to crash the server via memory exhaustion with a single large HTTP POST request.
Details
File: src/transports/http/server.ts, lines 224-240
private async readRequestBody(req: IncomingMessage): Promise<any> {
return new Promise((resolve, reject) => {
let body = '';
req.on('data', (chunk) => {
body += chunk.toString(); // No size limit
});
req.on('end', () => {
try {
const parsed = body ? JSON.parse(body) : null;
resolve(parsed);
} catch (error) {
reject(error);
}
});
req.on('error', reject);
});
}
A maxMessageSize configuration value exists in DEFAULT_HTTP_STREAM_CONFIG (4MB, defined in src/transports/http/types.ts line 124) but is never enforced in readRequestBody(). This creates a false sense of security.
PoC
Local testing with 50MB POST payloads against the vulnerable readRequestBody() function:
| Trial | Payload | RSS growth | Time | Result |
|---|---|---|---|---|
| 1 | 50MB | +197MB | 42ms | Vulnerable |
| 2 | 50MB | +183MB | 46ms | Vulnerable |
| 3 | 50MB | +15MB | 43ms | Vulnerable |
| 4 | 50MB | +14MB | 32ms | Vulnerable |
| 5 | 50MB | +65MB | 38ms | Vulnerable |
Reproducibility: 5/5 (100%)
Disclosure Timeline
This report follows coordinated disclosure. I request a 90-day window before public disclosure.
Reporter: Raza Sharif, CyberSecAI Ltd ([email protected])
Impact
- Denial of Service: Any mcp-framework HTTP server can be crashed by a single large POST request to /mcp
- No authentication required: readRequestBody() executes before any auth checks (auth is opt-in, default is no auth)
- Dead config: maxMessageSize exists but is never enforced, giving a false sense of security
- Affected: All applications using mcp-framework HttpStreamTransport (60,000 weekly npm downloads)
CWE-770: Allocation of Resources Without Limits or Throttling
Suggested CVSS 3.1: 7.5 (AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H)
The application allocates resources such as memory, threads, or file descriptors based on untrusted input without enforcing a cap. Typical impact: resource exhaustion leading to denial of service.
Affected versions
Security releases
Kodem intelligence
Severity tells you how bad this could be in the worst case. It does not tell you whether you are exposed. Exploitability and impact are functions of runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A vulnerable package can sit in your dependency tree and never run.
Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter. Kodem's runtime-powered SCA identifies whether this CVE is reachable in your applications.
Already deployed Kodem?
See it in your environmentNew to Kodem? Get a demo →Remediation advice
Enforce maxMessageSize in readRequestBody():
private async readRequestBody(req: IncomingMessage): Promise<any> {
const maxSize = this._config.maxMessageSize || 4 * 1024 * 1024;
return new Promise((resolve, reject) => {
let body = '';
let size = 0;
req.on('data', (chunk) => {
size += chunk.length;
if (size > maxSize) {
req.destroy();
reject(new Error('Request body too large'));
return;
}
body += chunk.toString();
});
// ...
});
}
Frequently Asked Questions
- What is CVE-2026-39313? CVE-2026-39313 is a high-severity allocation of resources without limits or throttling vulnerability in mcp-framework (npm), affecting versions <= 0.2.21. It is fixed in 0.2.22. The application allocates resources such as memory, threads, or file descriptors based on untrusted input without enforcing a cap.
- Which versions of mcp-framework are affected by CVE-2026-39313? mcp-framework (npm) versions <= 0.2.21 is affected.
- Is there a fix for CVE-2026-39313? Yes. CVE-2026-39313 is fixed in 0.2.22. Upgrade to this version or later.
- Is CVE-2026-39313 exploitable, and should I be worried? Whether CVE-2026-39313 is exploitable in your environment depends on whether the vulnerable code is present and reachable. A CVSS score is a worst-case rating; it does not account for your specific deployment, configuration, or usage patterns. Kodem, an Intelligent Application Security platform, uses runtime intelligence to show which vulnerabilities actually execute in production, so you can focus on the ones that represent real risk. Get a demo
- What actually determines whether CVE-2026-39313 is exploitable, and how bad it is? Exploitability and impact are not fixed properties of a CVE. They depend on runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A high CVSS score on a dependency that never runs is not the same as real risk. Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter.
- How do I fix CVE-2026-39313? Upgrade
mcp-frameworkto 0.2.22 or later.