Security

codebase-memory-mcp: heap overflow when importing a repo artifact

codebase-memory-mcp - heap buffer overflow on artifact import via int-truncated decompression capacity (GHSA-8xwq-xv2x-853r)

PUBLISHED SEVERITY HIGHSTATUS PatchedGHSA-8xwq-xv2x-853r
Patched

Fixed in codebase-memory-mcp 0.9.0 (2026-07-08) by a2f09c7, part of #941, which sizes the import buffer from the zstd frame header and checks it. Upgrade to 0.12.1. Track the fix at DeusData/codebase-memory-mcp#941.

Product
codebase-memory-mcp (MCP server and CLI; npm, PyPI and release binaries) in DeusData/codebase-memory-mcp
Affected versions
codebase-memory-mcp before 0.9.0 (npm, PyPI and release binaries). Fixed in 0.9.0 (2026-07-08). The maintainer verified the fix in 0.12.1 (2026-10-16), the recommended upgrade.
Severity
HIGH
Status
Patched
Weaknesses
  • CWE-190Integer Overflow or Wraparound
  • CWE-681Incorrect Conversion between Numeric Types
  • CWE-787Out-of-bounds Write
As filed on the advisory.
GitHub advisory
GHSA-8xwq-xv2x-853r
Published by the maintainer on 2026-11-17
CVE
CVE-2026-114495
Published
Credit
Finder: Aaron Elijah Mars of Aeon. Tool: Aeon (https://www.aeon.fun).

What users should do now

  1. Update codebase-memory-mcp to 0.12.1 or later. 0.9.0 is the first fixed release; 0.12.1 is the release the maintainer re-checked and recommends.
  2. Update every install you use: the npm package, the PyPI package and any downloaded release binary are all affected below 0.9.0.
  3. Until you update, do not index repositories you do not trust if they contain a .codebase-memory/ folder, or remove that folder from your checkout before indexing.

Summary

codebase-memory-mcp can share a prebuilt index with a team by committing it to the repository as a .codebase-memory/ folder: a zstd-compressed database plus an artifact.json file that describes it. When a user indexes a repository and has no local index for it yet, the server imports that artifact by itself. Before 0.9.0 the import read original_size from artifact.json, which anyone who can commit to the repository controls, and used it for two things. It allocated the output buffer with the full 64-bit value, but it passed the same value to the decompressor as a 32-bit int. A size with bit 31 set turned negative, was widened back into a huge capacity, and the decompressor then wrote the whole decompressed content into a buffer that was much smaller than the capacity it was told.

Affected versions

codebase-memory-mcp before 0.9.0, in every package the advisory lists (npm, PyPI and the release binaries). The bug fires when a user runs index_repository on a repository that contains a .codebase-memory/ artifact and has no local index yet. The attacker needs a way to get a user to index their repository (a public repo, a pull request branch, a dependency checkout); nothing else is needed from the user.

Impact

  • Heap corruption with attacker bytes. The decompressor writes content the attacker chose past the end of a heap buffer. At minimum this crashes the server reliably; heap overflows with controlled data like this can also lead to code execution as the user running the server.
  • Triggered by normal use. Indexing is the main thing the tool does, and the import runs automatically on first index, so the user does not have to open or approve the artifact.
  • Hard to spot. The artifact folder is meant to be committed and is a binary blob, so a malicious one looks like a normal shared index in review.

Scored 7.8 (CVSS 3.1 AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H) on the advisory.

Affected code

Permalinks at e69e084, the last commit before the fix.

Fix

  • a2f09c7 ("artifact: size import decompression from the zstd frame header"), part of #941, reads the decompressed size from the zstd frame header instead of trusting artifact.json. It rejects the artifact when that size is missing, larger than a 64 GiB cap, or different from original_size. The buffer and the decompressor capacity are now the same size_t value, and the decoded length must match it exactly. A regression test checks that a changed original_size is refused. Released in 0.9.0.
  • Checked at current main (649eb5e, 2026-11-17) and in the 0.12.1 release: the frame-header size check, the size cap, the size_t decompress wrapper and the regression test are all in place.
  • The maintainer notes the regression test does not rebuild a multi-gigabyte artifact, and the advisory does not claim every decompression resource-exhaustion case is gone; it covers the out-of-bounds write.

Detection (for defenders)

Look for a .codebase-memory/artifact.json whose original_size is 2 GiB or more, or does not match the real decompressed size of the .zst file next to it. In logs, an index.artifact_bootstrap line right before a crash of the server is a strong sign. On fixed versions a rejected artifact logs artifact.import with bad_decompressed_size. A working exploit is withheld.

Timeline

  1. Fix commit a2f09c7 lands; maintainers merge #941, which includes it.
  2. codebase-memory-mcp 0.9.0 released with the fix.
  3. codebase-memory-mcp 0.12.1 released; the maintainer later confirms the fix in this release.
  4. Maintainer publishes GHSA-8xwq-xv2x-853r with CVE-2026-114495; public write-up.

Credit

Finder: Aaron Elijah Mars of Aeon. Tool: Aeon.

References