codebase-memory-mcp: git option injection in detect_changes writes files
codebase-memory-mcp - git option injection through base_branch in detect_changes allows writing a file outside the project (GHSA-2vj2-hwgx-6f23)
Fixed in codebase-memory-mcp 0.9.0 (2026-07-08) by commit 72e6a14, part of #941, which rejects a base_branch that starts with a dash. Still in place in 0.12.1 and on main. 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); we recommend 0.12.1 (2026-10-16).
- Severity
- MEDIUM
- Status
- Patched
- Weaknesses
- CWE-88Improper Neutralization of Argument Delimiters in a Command
- GitHub advisory
- GHSA-2vj2-hwgx-6f23
Published by the maintainer on 2026-11-17 - CVE
- CVE-2026-114496
- 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, the release the maintainer verified and recommends. 0.9.0 is the first fixed release. Update the copy your MCP client launches (npm, PyPI or the release binary), then restart the client so it starts the new server.
- If you ran an older version with untrusted input reaching the agent (shared repos, web pages, issue text an agent reads), check for files you did not expect that hold
git diffoutput, in places the server's user can write. - Until you upgrade, do not let an agent call
detect_changeson input you do not trust, and run the server as a user that cannot write to sensitive files.
Summary
codebase-memory-mcp is an MCP server that indexes a code base into a graph for AI coding agents. Its detect_changes tool lists the files changed against a base branch by running git diff --name-only <base_branch>...HEAD in the project folder. The base_branch value (and since, which is routed into it) came from the tool call and was checked for shell metacharacters, but not for a leading dash. git reads an argument that starts with a dash as an option, not a branch name, even inside quotes. One git diff option writes the diff to a file of the caller's choosing, so a tool call could create or overwrite a file outside the project.
Affected versions
codebase-memory-mcp before 0.9.0, on every package channel listed on the advisory (npm, PyPI and the release binaries). The bug is reached through the detect_changes MCP tool, so the attacker needs a way to shape that tool call: their own access to the server, or text an agent reads and then acts on (prompt injection).
Impact
- File write outside the project. A caller of
detect_changescan create or overwrite a file with git diff output at a path they choose, with the permissions of the server process. This is the impact shown on the advisory. - No code run shown. Running arbitrary code was not demonstrated. The written content is diff output, not text the caller fully controls, which limits what an overwrite can do.
- Easy to reach. The bad value is a single tool argument and passes the existing shell check, so no special setup is needed beyond a project the server has indexed.
Scored 5.5 (CVSS 3.1 AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:H/A:N) on the advisory.
Affected code
Permalinks at 7071310, the parent of the fix commit on main.
detect_changestool schema withbase_branchandsince: src/mcp/mcp.c#L485-L489sincerouted intobase_branch: src/mcp/mcp.c#L5368-L5378- The only check on
base_branch, for shell metacharacters and not a leading dash: src/mcp/mcp.c#L5384-L5390 base_branchplaced in the revision position ofgit diff: src/mcp/mcp.c#L5418-L5435- Command run: src/mcp/mcp.c#L5437
Fix
- 72e6a14 ("mcp: reject an option-like base_branch in detect_changes"), part of #941, rejects any
base_branchthat starts with a dash, next to the shell metacharacter check, before git is run. A real git branch name never starts with a dash. It adds a regression test,detect_changes_rejects_option_like_base_branch. Released in 0.9.0. - In 0.12.1 and on current
main,sincestill goes throughbase_branchfirst, so both pass the same leading-dash check, and the regression test is still in the suite.
Detection (for defenders)
If your MCP client logs tool calls, look for detect_changes calls whose base_branch or since starts with -. On disk, look for unexpected files holding git diff output (lines starting with diff --git, --- and +++), or config files whose content was replaced by such output. A fixed server answers such calls with base_branch contains invalid characters. A working exploit is withheld.
Timeline
- Maintainer commits the fix (72e6a14) and merges #941, after our private report through GitHub PVR (GHSA-2vj2-hwgx-6f23).
- codebase-memory-mcp 0.9.0 released with the fix.
- codebase-memory-mcp 0.12.1 released; the maintainer later names it the verified upgrade target.
- Maintainer publishes GHSA-2vj2-hwgx-6f23 with CVE-2026-114496; 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 72e6a14
- Fixed release: codebase-memory-mcp 0.9.0; recommended: 0.12.1
- GitHub advisory: GHSA-2vj2-hwgx-6f23
- CVE: CVE-2026-114496 (assigned by the GitHub CNA)
- Affected repository: DeusData/codebase-memory-mcp