NewApp Monitoring is liveSign up free
AgentbeamBeta
AI agent vulnerability · Other MCP servers and tools

CVE-2026-49986: Cortex has Untrusted Project Bootstrap Code Execution via `CLAUDE_PROJECT_DIR`

highCVSS 4.0 7.1GHSA-gvpp-v77h-5w8g

The Cortex MCP server (`neuro-cortex-memory`) treated Claude Code's `CLAUDE_PROJECT_DIR` as a trusted Cortex checkout. A malicious repository with two marker files could make the `open_visualization` tool run its own `visualize_bootstrap.py`, which is code execution as the local user. Versions up to 3.17.0 are affected. Upgrade to 3.18.0.

Published Jul 1, 2026 · Analysis Oct 25, 2026

What an attacker can do

_find_dev_source() in mcp_server/handlers/open_visualization.py builds a list of candidate source roots from CORTEX_DEV_ROOT and CLAUDE_PROJECT_DIR. Claude Code sets the second one to whatever project the user has open. _is_cortex_root() accepts a directory if it has an mcp_server/ folder and a ui/unified-viz.html file. Nothing checks a git remote, a signature or a developer opt-in.

When the tool runs, the handler executes mcp_server/server/visualize_bootstrap.py from that directory with subprocess.run([sys.executable, ...]). A second path in mcp_server/server/http_launcher.py rsyncs files from the same directory into the Cortex plugin cache, which could give persistence.

The attacker needs the victim to open a crafted repository in Claude Code, with Cortex installed, and then call open_visualization, for example through /cortex-visualize. The attacker's Python then runs with the user's own rights. It can read SSH and GPG keys, environment secrets and source code, and change or delete files. The reporter's proof of concept writes a sentinel file to show the bootstrap ran.

Who is affected

Affected: pip neuro-cortex-memory up to and including 3.17.0. The advisory lists 3.17.0 or newer as the tested version for the proof of concept. You are exposed if the Cortex MCP plugin is installed and you open repositories you do not trust.

pip show neuro-cortex-memory

The attack runs only when the open_visualization tool is invoked.

neuro-cortex-memory

Ecosystem
PyPI
Affected
<= 3.17.0
Fixed in
3.18.0
Check
pip show neuro-cortex-memory

How to fix it

Upgrade to neuro-cortex-memory 3.18.0.

pip install --upgrade "neuro-cortex-memory>=3.18.0"

The advisory page names 3.17.1 as the patched release, while the package data lists 3.18.0. A later version includes the earlier one. The reporter's suggested fix removes CLAUDE_PROJECT_DIR from the candidate list and honors CORTEX_DEV_ROOT only when CORTEX_DEV_SOURCE_SYNC=1 is set. It applies the same change to http_launcher.py. Until you upgrade, do not run /cortex-visualize inside a repository you do not trust.

How to tell if you were hit

Look in the project directory you had open for mcp_server/server/visualize_bootstrap.py and ui/unified-viz.html. A repository that is not Cortex but has both is suspicious. Check for Python child processes started by the Cortex MCP server around the time open_visualization was called. Review the Cortex plugin cache directory for files you did not install. Beam records agent shell commands, file access and MCP tool calls, so the open_visualization call and what it spawned can be reviewed there.

Original advisory

From the GitHub Advisory Database (CC BY 4.0).

Untrusted Project Bootstrap Code Execution via CLAUDE_PROJECT_DIR

Summary

The Cortex MCP server (neuro-cortex-memory) treats the CLAUDE_PROJECT_DIR environment variable — automatically set by Claude Code to the currently open project directory — as a trusted Cortex developer checkout. When the open_visualization tool is invoked, _find_dev_source() resolves the user's active project directory as a candidate Cortex source root. The only validation performed by _is_cortex_root() is a check for the presence of an mcp_server/ subdirectory and a ui/unified-viz.html file. An attacker who places these two marker files in a malicious repository can cause Cortex to execute an arbitrary mcp_server/server/visualize_bootstrap.py from that directory via subprocess.run([sys.executable, ...]), achieving code execution with the privileges of the victim's local user process. CVSS v3.1 Base Score: 7.8 (High).

Details

The vulnerability originates in _find_dev_source() inside mcp_server/handlers/open_visualization.py. The function builds a list of candidate directories by iterating over the environment variables CORTEX_DEV_ROOT and CLAUDE_PROJECT_DIR:

# mcp_server/handlers/open_visualization.py:73-76
for env in ("CORTEX_DEV_ROOT", "CLAUDE_PROJECT_DIR"):
    v = os.environ.get(env)
    if v:
        candidates.append(Path(v))

CLAUDE_PROJECT_DIR is set automatically by the Claude Code IDE extension to whichever directory the user has currently open. This means any project the user opens is silently treated as a candidate Cortex source root.

Each candidate is then validated by _is_cortex_root() (lines 65–70), which only verifies that the directory contains an mcp_server/ subdirectory and a ui/unified-viz.html file — trivial markers that an attacker can replicate:

# mcp_server/handlers/open_visualization.py:65-70
def _is_cortex_root(path: Path) -> bool:
    return (path / "mcp_server").is_dir() and \
           (path / "ui" / "unified-viz.html").is_file()

There is no git remote identity check, no cryptographic signature verification, no release path allowlist, and no explicit developer opt-in requirement. Once a directory passes _is_cortex_root(), the handler constructs a bootstrap path and executes it unconditionally:

# mcp_server/handlers/open_visualization.py:179-185
bootstrap_path = dev_src / "mcp_server" / "server" / "visualize_bootstrap.py"
if bootstrap_path.is_file():
    ...
    proc = subprocess.run(
        [sys.executable, str(bootstrap_path)],
    )

A secondary code-execution path exists in mcp_server/server/http_launcher.py:80-83 and 273-275, where the same CLAUDE_PROJECT_DIR-derived dev source is used to rsync attacker-controlled files into the Cortex plugin cache directory before serving them.

Entry point: MCP tool open_visualization, registered at mcp_server/tool_registry_core.py:194-207 (no authentication required at tool layer). The tool is reachable through the standard stdio MCP transport started in mcp_server/__main__.py:66.

PoC

Prerequisites

  • Cortex (neuro-cortex-memory ≥ 3.17.0) installed and importable.
  • Victim opens an attacker-controlled project directory in Claude Code (sets CLAUDE_PROJECT_DIR automatically) or the attacker otherwise controls CLAUDE_PROJECT_DIR.
  • Victim invokes /cortex-visualize or triggers the open_visualization MCP tool (e.g., by selecting a visualization command in the Claude Code interface).

Inline PoC

import asyncio, os, tempfile
from pathlib import Path
from mcp_server.handlers import open_visualization as ov

base = Path(tempfile.mkdtemp(prefix="cortex-malicious-project-"))
(base / "mcp_server" / "server").mkdir(parents=True)
(base / "ui").mkdir()
(base / "ui" / "unified-viz.html").write_text("<html>attacker</html>", encoding="utf-8")

sentinel = Path("/tmp/cortex-open-visualization-poc-owned")
if sentinel.exists():
    sentinel.unlink()

(base / "mcp_server" / "server" / "visualize_bootstrap.py").write_text(
    "from pathlib import Path\n"
    "Path('/tmp/cortex-open-visualization-poc-owned').write_text('executed', encoding='utf-8')\n"
    "print('bootstrap-ran')\n",
    encoding="utf-8",
)

os.environ["CLAUDE_PROJECT_DIR"] = str(base)
ov.launch_server = lambda _typ: "http://127.0.0.1:3458"
ov.open_in_browser = lambda _url: None

result = asyncio.run(ov.handler({}))
print(result.get("bootstrap"))
print(sentinel.read_text())

Expected output:

bootstrap-ran
executed

Recommended Remediation

Remove CLAUDE_PROJECT_DIR from the dev-source candidate list. Gate executable dev-source resolution behind an explicit opt-in flag so that only a developer who deliberately sets both CORTEX_DEV_SOURCE_SYNC=1 and CORTEX_DEV_ROOT can trigger the bootstrap path:

--- a/mcp_server/handlers/open_visualization.py
+++ b/mcp_server/handlers/open_visualization.py
-    candidates: list[Path] = []
-    for env in ("CORTEX_DEV_ROOT", "CLAUDE_PROJECT_DIR"):
-        v = os.environ.get(env)
-        if v:
-            candidates.append(Path(v))
+    candidates: list[Path] = []
+    if os.environ.get("CORTEX_DEV_SOURCE_SYNC") == "1":
+        v = os.environ.get("CORTEX_DEV_ROOT")
+        if v:
+            candidates.append(Path(v))
     candidates.append(Path.home() / "Documents" / "Developments" / "Cortex")

Apply the same change to mcp_server/server/http_launcher.py:80-83 to eliminate the secondary rsync execution path.

Impact

This is a local arbitrary code execution vulnerability. Any user who has the Cortex MCP plugin installed and opens (or is social-engineered into opening) an attacker-crafted project directory in Claude Code is at risk. When the victim invokes the open_visualization tool (e.g., via the /cortex-visualize slash command), attacker-controlled Python code runs immediately with the full privileges of the victim's local user account — the same privileges used by Claude Code and the Cortex MCP server process.

Consequences include but are not limited to:

  • Confidentiality: exfiltration of files, secrets, environment variables, and SSH/GPG keys accessible to the local user.
  • Integrity: modification or deletion of local files, source code, credentials, and plugin caches.
  • Availability: termination of local processes or destruction of user data.

The secondary path through http_launcher.py additionally allows the attacker to overwrite files in the Cortex plugin cache directory, potentially establishing persistence that survives after the malicious project is closed.

The attack requires the victim to invoke the visualization tool (UI:R), which is reflected in the CVSS score. No elevated privileges or prior authentication to any network service are required.

Credited to EQSTLab, useworld.

Questions

Is neuro-cortex-memory 3.17.0 affected by CVE-2026-49986?

Yes. Versions up to and including 3.17.0 are affected. The package data lists 3.18.0 as the patched version.

Does opening a malicious repository run the code by itself?

No. The victim or the agent must invoke the open_visualization tool, for example with /cortex-visualize. Opening the repo only sets CLAUDE_PROJECT_DIR.

Why do the sources disagree on the fixed version?

The advisory page says 3.17.1 or later. The package data says 3.18.0. Installing 3.18.0 or newer satisfies both.

References

How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. The analysis is written by an AI model from the sources listed above and checked by automated rules before it is published. Check versions against the vendor's advisory before you act. Methodology

More Other MCP servers and tools vulnerabilities

All Other MCP servers and tools entries