Expensive operations have resource limits
Why it matters
A read_file tool with no size limit will attempt to load a 5GB log file into Node.js heap, causing an out-of-memory crash that takes down every tool in the server simultaneously. A database query tool with no LIMIT clause can return millions of rows, exhausting memory and making the response unparseable. CWE-400 (uncontrolled resource consumption) and CWE-770 (allocation of resources without limits) are the mechanisms. These are not theoretical edge cases — agentic AI workflows routinely hit large files and broad queries when exploring unfamiliar codebases or databases.
Severity rationale
Medium because resource exhaustion from oversized responses crashes the server process, but it requires the AI or user to trigger an operation against genuinely large data sources.
Remediation
Add explicit size checks before loading data and document the limits in the tool description.
// src/tools/read-file.ts — bounded file read
const MAX_FILE_SIZE = 10 * 1024 * 1024 // 10 MB
server.tool('read_file', 'Read a file (max 10 MB). For larger files, use read_file_range.', ...,
async ({ path }) => {
const stat = await fs.stat(path)
if (stat.size > MAX_FILE_SIZE) {
return {
content: [{ type: 'text', text:
`File is ${(stat.size / 1024 / 1024).toFixed(1)} MB — exceeds 10 MB limit. ` +
`Use read_file_range to read specific byte ranges.`
}],
isError: true,
}
}
return { content: [{ type: 'text', text: await fs.readFile(path, 'utf-8') }] }
}
)
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the MCP Server Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- cwe · CWE-400 — Uncontrolled Resource Consumption
- cwe · CWE-770 — Allocation of Resources Without Limits or Throttling
- iso-25010:2011 · performance-efficiency
Taxons
History
- 2026-04-18·v1.0.0·Initial import from mcp-server·automated