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)
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
- 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
- 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.
- Update every install you use: the npm package, the PyPI package and any downloaded release binary are all affected below 0.9.0.
- 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.
original_sizeread from the repo'sartifact.jsonwith no limit: src/pipeline/artifact.c#L299-L321- Import uses that value for the buffer size: src/pipeline/artifact.c#L598-L603 and the allocation at #L617
- Same value cut to
intas the decompressor capacity: src/pipeline/artifact.c#L623 - Decompress wrapper widens the
intcapacity back tosize_t: internal/cbm/zstd_store.c#L17-L23 - Automatic import on first index: src/mcp/mcp.c#L3261-L3268, called from
index_repositoryat #L3905
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 fromoriginal_size. The buffer and the decompressor capacity are now the samesize_tvalue, and the decoded length must match it exactly. A regression test checks that a changedoriginal_sizeis 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, thesize_tdecompress 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
- Fix commit a2f09c7 lands; maintainers merge #941, which includes it.
- codebase-memory-mcp 0.9.0 released with the fix.
- codebase-memory-mcp 0.12.1 released; the maintainer later confirms the fix in this release.
- Maintainer publishes GHSA-8xwq-xv2x-853r with CVE-2026-114495; public write-up.
Credit
Finder: Aaron Elijah Mars of Aeon. Tool: Aeon.
References
- Fix PR (merged 2026-07-07): DeusData/codebase-memory-mcp#941; fix commit a2f09c7
- Fixed release: codebase-memory-mcp 0.9.0; recommended: 0.12.1
- GitHub advisory: GHSA-8xwq-xv2x-853r
- CVE: CVE-2026-114495 (assigned by the GitHub CNA)
- Affected repository: DeusData/codebase-memory-mcp