Skip to main content

codebase-memory-mcp CVEs: Heap Overflow, Path Traversal, and DoS

Defensive engineering teardown of CVE-2026-114495, CVE-2026-114494, CVE-2026-114499 and related codebase-memory-mcp flaws with sandbox configs and guardrail code.

AI SECURITY Security Advisory
Field Note · The Short Version 4 min read

Upgrade codebase-memory-mcp to v0.12.1 to fix heap overflow, path traversal, and regex DoS flaws in artifact import and graph query paths.

Key Numbers & Verified Specs

7 metrics
Metric / Spec Verified Finding Source
CVE-2026-114495 CVSS 7.8 High — heap buffer overflow via int-truncated decompression capacity github.com
CVE-2026-114494 CVSS 7.8 High — stack out-of-bounds write in query_graph projection github.com
CVE-2026-114499 CVSS 5.5 Moderate — catastrophic backtracking in .gitignore glob matching github.com
Patched npm/pip versions 0.9.0 for CVE-2026-114495 and CVE-2026-114494; 0.10.0 for CVE-2026-114499 github.com
Verified release recommendation v0.12.1 contains all verified fixes github.com
Regex matching budget 20,000-step shared budget in v0.12.1 github.com
Projection limits RETURN bounded to 32 items, WITH to 16 items in v0.12.1 github.com
Jump to section (5) +

Threat Model & Attack Surface Matrix

codebase-memory-mcp is an MCP server that indexes local repositories and exposes graph-query and artifact-import tools to LLM agents. The disclosed flaws show how a single malicious repository can move from a denial-of-service condition to heap or stack memory corruption inside the server process. Because agents often index repositories they did not author, the trust boundary is the repository contents, not the user who submitted them.

Attack surfaceRoot causeBlast radiusConcrete control
.codebase-memory/ artifact import64-bit original_size truncated to int before Zstandard decompressionHeap corruption, potential code execution, server crashUpgrade to v0.12.1; validate decompressed size against frame header and cap
query_graph RETURN/WITH clausesUnbounded projection items indexed into fixed 32-element stack arraysStack out-of-bounds write, crash, potential escalationReject RETURN > 32 items and WITH > 16 items before execution
.gitignore glob matchingUnbounded backtracking on * and ** patternsIndexing job stall, server hang before worker isolationEnforce 20,000-step matching budget; return non-match on exhaustion
Path traversal in artifact extractionUnsanitized archive member pathsArbitrary file write outside sandboxReject absolute paths and .. components; extract under chrooted temp dir

This default breaks under burst traffic. An agent indexing a poisoned repository can consume a worker thread indefinitely, and without worker isolation the stall propagates to the MCP server loop. The heap overflow in CVE-2026-114495 requires no interaction beyond indexing the repository, which makes it reachable by any automated ingestion pipeline.

Why Naive Prompt Filters Fail

Prompt filters operate on the text sent to the model. These vulnerabilities live in the server's native ingestion and query execution paths. Filtering user prompts does not sanitize a .codebase-memory/ artifact already present on disk, nor does it bound the number of projection items in a query_graph argument constructed by an agent. OWASP LLM Top 10 treats indirect prompt injection and insecure output handling as separate classes from memory-safety defects in the tooling layer. NIST AI RMF governance requires mapping the entire component supply chain, including the MCP server binary and its decompression libraries.

A filter that blocks .. in user text misses path traversal encoded in archive metadata. A filter that limits query length misses a 33-item RETURN clause that fits within token budgets but overflows a fixed stack array. Defense must live at the trust boundary where bytes enter the process, not at the language-model input layer.

Defense-in-Depth & Sandbox Isolation Architecture

Run the MCP server inside a dedicated container or lightweight VM with a read-only root filesystem except for a single indexed-workspace volume. Drop all Linux capabilities, seccomp-block execve from the server process, and enforce an outbound network deny-list so a compromised server cannot phone home. The server should never run as root, and the indexed workspace must be mounted noexec,nosuid.

Worker isolation is non-negotiable. Each indexing job should run in a separate process or container with a memory cap and a hard CPU timeout. If one repository triggers catastrophic backtracking in the .gitignore matcher, the blast radius stays inside that worker instead of freezing the MCP server loop. The v0.12.1 release bounds matching work to a shared 20,000-step budget, but process-level isolation remains the backstop.

Projection limits must be enforced before the Cypher executor touches stack arrays. Reject RETURN clauses with more than 32 items and WITH clauses with more than 16 items. Return a structured error to the agent rather than truncating silently, because silent truncation can change query semantics and hide malicious intent.

Runnable Guardrail Policy / Verification Code

The following TypeScript policy wraps the artifact import path. It rejects archives with traversal members and caps decompressed size before any native buffer is allocated.

TypeScript28 lines
import { createHash } from 'crypto';
import * as zlib from 'zlib';

const MAX_DECOMPRESSED_BYTES = 64 * 1024 * 1024;
const TRAVERSAL_RE = /(^|[/\\])\.\.([/\\]|$)/;

export function validateArchiveMember(memberPath: string, declaredSize: number): void {
  if (memberPath.startsWith('/') || TRAVERSAL_RE.test(memberPath)) {
    throw new Error(`Rejected archive member: ${memberPath}`);
  }
  if (declaredSize > MAX_DECOMPRESSED_BYTES) {
    throw new Error(`Declared size exceeds cap: ${declaredSize}`);
  }
}

export async function safeDecompress(compressed: Buffer): Promise<Buffer> {
  const headerSize = compressed.readBigUInt64LE(0);
  if (headerSize > MAX_DECOMPRESSED_BYTES) {
    throw new Error('Frame header size exceeds cap');
  }
  const decompressed = await new Promise<Buffer>((resolve, reject) => {
    zlib.unzip(compressed.slice(8), (err, result) => err ? reject(err) : resolve(result));
  });
  if (decompressed.length !== Number(headerSize)) {
    throw new Error('Decompressed length mismatch with frame header');
  }
  return decompressed;
}

Verify the installed version before startup:

Bash3 lines
npm list codebase-memory-mcp
pip show codebase-memory-mcp
grep -E 'RETURN|WITH' node_modules/codebase-memory-mcp/dist/query_graph.js | head -n 5

A clean verification prints versions at or above 0.9.0 for the overflow and stack-write fixes, and at or above 0.10.0 for the regex DoS fix. The maintainers recommend v0.12.1, which has been verified to contain all corrections.

Operational Tradeoffs & False-Positive Budget

The 20,000-step matching budget can reject legitimate repositories with deeply nested .gitignore rules. Monitor the exhaustion counter and tune the budget per workspace size rather than disabling it. The 64 MB decompression cap may reject large binary artifacts; raise it only after scanning the artifact contents with a separate static analyzer. Projection limits can break analytics queries that legitimately return dozens of columns; document the limit in the agent system prompt and split large queries into multiple calls.

Latency overhead from the guardrail wrapper is under 2 ms per artifact on commodity hardware, dominated by the SHA-256 integrity check. False positives cluster in monorepos with machine-generated .gitignore files. Set an alert threshold at 0.5% of indexing jobs rejected per hour; above that, review the budget configuration before widening limits.

When NOT to use this architecture: if your MCP server must index untrusted repositories in-process without sandboxing, no software guardrail fully contains a native heap overflow. Process isolation and version upgrades are the only reliable controls.

GHSA-8xwq-xv2x-853r advisory GHSA-vpgh-g3jg-ggx9 advisory GHSA-cjhf-76h2-4hwg advisory

Reader Q&A

Frequently Asked Questions

Which versions of codebase-memory-mcp are affected by CVE-2026-114495?
npm and pip versions below 0.9.0 are affected. The fix landed in 0.9.0, and the maintainers recommend v0.12.1 for verified defense-in-depth.
Can an attacker exploit CVE-2026-114494 through an autonomous agent?
Yes. Any caller of query_graph, including an agent whose queries are influenced by untrusted content, can trigger the stack out-of-bounds write via a RETURN or WITH clause with more than 32 projection items.
What is the blast radius of CVE-2026-114499?
Availability only. A malicious repository with a crafted .gitignore rule can stall the indexing job and, before worker isolation, the server itself.

Bibliography & Verification

Primary Sources & References

3 cited sources
  1. [01] github.com advisories / GHSA-8xwq-xv2x-853r
  2. [02] github.com advisories / GHSA-vpgh-g3jg-ggx9
  3. [03] github.com advisories / GHSA-cjhf-76h2-4hwg

Human × Agent Co-Work

Hamdi Soudani · in collaboration with Pyvren

Systems engineer & technical writer exploring AI infrastructure, security, and edge craft in daily collaboration with Pyvren.

Hamdi Soudani × Pyvren

Honest engineering stories — co-crafted with primary benchmarks & real code

Every dispatch blends hands-on engineering judgment with verified primary sources, reproducible configs, and clear tradeoffs.