Security

codebase-memory-mcp: stack overflow from a wide query_graph RETURN

codebase-memory-mcp query_graph - stack out-of-bounds write in RETURN/WITH projection handling (GHSA-vpgh-g3jg-ggx9)

PUBLISHED SEVERITY HIGHSTATUS PatchedGHSA-vpgh-g3jg-ggx9
Patched

Fixed in codebase-memory-mcp 0.9.0 (2026-07-08) by #941, which rejects a RETURN or WITH with more than 32 items at parse time. 0.11.0 (2026-09-15) also caps WITH at 16 items. Upgrade to 0.12.1. Track the fix at DeusData/codebase-memory-mcp#941.

Product
codebase-memory-mcp (MCP server; 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 recommends 0.12.1 (2026-10-16).
Severity
HIGH
Status
Patched
Weaknesses
  • CWE-121Stack-based Buffer Overflow
  • CWE-787Out-of-bounds Write
As filed on the advisory.
GitHub advisory
GHSA-vpgh-g3jg-ggx9
Published by the maintainer on 2026-11-17
CVE
CVE-2026-114494
Published
Credit
Finder: Aaron Elijah Mars of Aeon. Tool: Aeon (https://www.aeon.fun).

What users should do now

  1. Upgrade codebase-memory-mcp to 0.12.1 or later, the release the maintainer verified and recommends. 0.9.0 is the first fixed release.
  2. Check every place the server is installed (npm, PyPI, Homebrew, Go wrapper or a downloaded binary) and run codebase-memory-mcp --version to confirm the new version is the one your agent starts.
  3. Until you upgrade, treat query_graph as a tool that can crash the server: do not let an agent pass it queries built from untrusted content (web pages, issues, files from other people) without review.

Summary

codebase-memory-mcp is an MCP server that indexes a codebase into a graph and lets an AI agent query it. Its query_graph tool takes a Cypher query as a plain string argument and runs it in the server process. The parser read RETURN and WITH clauses into a growable list with no upper limit on the number of items. The code that then builds each result row (execute_return_simple, execute_return_agg and the helpers they call) keeps one row in fixed stack arrays of 32 slots and fills them with a loop that runs once per parsed item. A query listing more than 32 items wrote past the end of those arrays.

A second path, build_return_columns, filled only the first 32 column names but then copied as many names as the query listed, so it read unset stack slots. That happens while the result header is built, even when no node matches the query.

Affected versions

codebase-memory-mcp before 0.9.0, in every package the advisory lists (npm, PyPI and the release binaries). Any client that can call query_graph reaches the bug, including an AI agent whose queries are shaped by content it has read. The server needs an indexed project for the query to run.

Impact

  • Reliable crash. One tool call with a wide RETURN corrupts the stack and takes down the server, so the agent loses its code graph until the server is restarted.
  • Possible worse outcomes. The overflow writes pointers and copies of query values past the end of the row arrays. What that overwrites depends on the build and stack layout, so code execution in the server process cannot be ruled out.
  • Low bar. No special access is needed beyond the ability to call the tool. An attacker who can get text in front of the agent (a README, an issue, a web page) can try to steer it into sending such a query.

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

Affected code

Permalinks at 5554f8a, the last commit on main before the fix (the base of #941).

Fix

  • e69e084 ("cypher: bound RETURN/WITH projection width to the result column limit"), part of #941, makes the parser reject a RETURN or WITH with more than 32 items, so the query fails with an error before any row is built. It adds a regression test that runs a 48-item RETURN in a child process and fails if the child is killed. Released in 0.9.0.
  • 426e415 ("refuse a WITH wider than a binding can carry"), part of #1918, lowers the WITH limit to 16 items, the number of variables a binding holds, so a wider WITH is refused instead of silently dropping columns. Released in 0.11.0.
  • Checked at current main (649eb5e) and in 0.12.1: the parser still refuses more than 32 RETURN items or 16 WITH items, and both regression tests are still in the test suite at main.

Detection (for defenders)

Look for unexpected crashes or restarts of the codebase-memory-mcp process, and in your agent or MCP client logs for query_graph calls whose RETURN or WITH lists more than 32 items. On a fixed version such a query returns an error instead of a result. A working exploit is withheld.

Timeline

  1. Reported privately via GitHub PVR (GHSA-vpgh-g3jg-ggx9).
  2. Maintainer merges #941, which includes the projection bound (e69e084).
  3. codebase-memory-mcp 0.9.0 released with the fix.
  4. #1918 merged, lowering the WITH limit to 16 items.
  5. codebase-memory-mcp 0.11.0 released with the tighter WITH limit.
  6. codebase-memory-mcp 0.12.1 released; the maintainer verifies the fix in it.
  7. Maintainer publishes GHSA-vpgh-g3jg-ggx9 with CVE-2026-114494; public write-up.

Credit

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

References