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)
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
- 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
- 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.
- Check every place the server is installed (npm, PyPI, Homebrew, Go wrapper or a downloaded binary) and run
codebase-memory-mcp --versionto confirm the new version is the one your agent starts. - Until you upgrade, treat
query_graphas 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).
- RETURN/WITH item loop that grows the list with no upper limit: src/cypher/cypher.c#L1635-L1653
execute_return_simplefillsvals[32]andfunc_bufs[32]once per parsed item: src/cypher/cypher.c#L4105-L4119- Aggregate path, same pattern in
ret_agg_build_key(called with 32-slot arrays) andret_agg_emit_row: src/cypher/cypher.c#L3992-L4048 build_return_columnsfills at most 32 names, then passes the full item count on: src/cypher/cypher.c#L4075-L4095;rb_set_columnsreads that many: #L2565-L2571query_graphhandler passes the caller's query string straight to the engine: src/mcp/mcp.c#L2055-L2082
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 atmain.
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
- Reported privately via GitHub PVR (GHSA-vpgh-g3jg-ggx9).
- Maintainer merges #941, which includes the projection bound (e69e084).
- codebase-memory-mcp 0.9.0 released with the fix.
- #1918 merged, lowering the WITH limit to 16 items.
- codebase-memory-mcp 0.11.0 released with the tighter WITH limit.
- codebase-memory-mcp 0.12.1 released; the maintainer verifies the fix in it.
- Maintainer publishes GHSA-vpgh-g3jg-ggx9 with CVE-2026-114494; 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 e69e084
- Fixed release: codebase-memory-mcp 0.9.0; recommended: 0.12.1
- WITH limit: DeusData/codebase-memory-mcp#1918, released in 0.11.0
- GitHub advisory: GHSA-vpgh-g3jg-ggx9
- CVE: CVE-2026-114494 (assigned by the GitHub CNA)
- Affected repository: DeusData/codebase-memory-mcp