← MCP server and skill grades

CodeGraphContext

CodeGraphContext/CodeGraphContext

F
Type
MCP server
Scanned
Nov 13, 2026
Version
6ed71a9f03f8
Files read
1075

CodeGraphContext...Wait—NO! Almost generated text outside JSON! Let's make sure the actual output starts directly with { and ends with }. Let's emit ONLY the JSON string now. `{

Findings

1 critical5 high5 medium19 low
  1. CriticalArbitrary environment variable injection and code execution via untrusted repo mcp.json

    src/codegraphcontext/cli/main.py:354

    _load_credentials() runs on cgc mcp start, cgc index, and most CLI commands, unconditionally reading mcp.json from the current working directory and exporting every key in mcpServers.CodeGraphContext.env into os.environ (unless already set in the parent shell or ~/.codegraphcontext/.env), while expanding any key containing PATH relative to the current directory. A malicious cloned repository with a checked-in mcp.json can set PYTHONPATH=. (or LD_PRELOAD, DYLD_INSERT_LIBRARIES, GIT_EXEC_PATH) so child processes such as the FalkorDB Python worker or git rev-parse execute attacker code from the repo, or set CGC_ALLOW_ALL_PATHS=true and FALKORDB_HOST to disable path sandboxing and exfiltrate indexed source code.

    Fix: Do not load mcp.json from the current working directory into os.environ, or restrict loaded keys strictly to safe non-security CGC configuration keys in DEFAULT_CONFIG (excluding CGC_ALLOW_ALL_PATHS, CGC_ALLOWED_ROOTS, ALLOW_DB_DELETION, DB host/URI keys, and OS/Python loader variables) and gate project config loading behind explicit user opt-in.

  2. HighRead-only Cypher filter bypass via backtick-quoted identifiers and missing KuzuDB keywords

    src/codegraphcontext/utils/cypher_readonly.py:108

    is_read_only_cypher() strips backtick-quoted identifiers (...) by replacing them with spaces and then allows forbidden keywords (CREATE, MERGE, DELETE, SET, LOAD, COPY, CALL) whenever the preceding token is AS, :, ., or $. Because the backtick-quoted identifier vanishes from the token stream, valid Cypher queries such as MATCH (n) WITH n AS n DELETE n, MATCH (f:Function) WITH f AS f SET f.source = 'x', MATCH (n) WHERE n:File DETACH DELETE n, or WITH 1 AS x CALL ... leave AS or : immediately before the write/procedure keyword and pass validation. Furthermore, KuzuDB/LadybugDB commands EXPORT, IMPORT, and ATTACH are missing from _FORBIDDEN_KEYWORDS, allowing EXPORT DATABASE '/arbitrary/dir' directly. On KuzuDB, LadybugDB (default on Windows and fallback on Unix), and Nornic DB—which lack server-enforced read-only sessions—an agent tricked via prompt injection can mutate or wipe the graph or write database exports to disk via execute_cypher_query.

    Fix: Replace backtick-quoted identifiers with a synthetic identifier placeholder (such as __IDENT__) instead of whitespace so token adjacency is preserved, add EXPORT, IMPORT, ATTACH, and INSTALL to _FORBIDDEN_KEYWORDS, and open Nornic sessions with default_access_mode='READ'.

  3. HighCypher injection in find_dead_code via SQL-style quote escaping on a read-write session

    src/codegraphcontext/tools/code_finder.py:1010

    CodeFinder.find_dead_code() builds its decorator filter by interpolating each string in exclude_decorated_with into Cypher using SQL quote doubling (p.replace("'", "''")) without escaping backslashes or using query parameters. Because Cypher uses backslash escapes (\') rather than SQL's doubled quotes, an input containing \' becomes \''—an escaped quote followed by an unescaped closing quote—breaking out of the string literal on Neo4j, FalkorDB, KuzuDB, and LadybugDB. Since find_dead_code runs on a read-write session without is_read_only_cypher() and is placed in alwaysAllow by cgc mcp setup, prompt injection can execute arbitrary write Cypher, delete or alter graph data, trigger Neo4j LOAD CSV requests, or run KuzuDB COPY ... TO file writes.

    Fix: Pass exclude_decorated_with as a bound Cypher list parameter ($exclude_decorators) instead of interpolating strings into the query text, and run read-only analysis queries in a READ session.

  4. HighCypher injection via .cgc bundle property keys on KuzuDB and LadybugDB

    src/codegraphcontext/core/database_embedded_kuzu.py:1232

    When importing a .cgc bundle via cgc load or the load_bundle MCP tool, cgc_bundle.py validates node labels and relationship types but passes node and edge property dicts as $props. On KuzuDB and LadybugDB, EmbeddedSessionWrapper._translate_query() rewrites SET n += $props and SET r = $props by interpolating each property key k directly into the Cypher string (f'{node_var}.{k} = ${clean_k}'). For all relationships ([r:...], where label is None) and for node labels with no SCHEMA_MAP entry (such as DbTable, Datasource, ExternalClass, GradleModule), allowed_props is falsy, allowing arbitrary keys from edges.jsonl or nodes.jsonl to inject raw Cypher. This is compounded by the public bundle registry allowing unauthenticated uploads via website/api/publish.ts.

    Fix: Validate every property key k in _translate_query() and _validate_bundle_identifiers() against _CYPHER_IDENTIFIER_RE (^[A-Za-z_][A-Za-z0-9_]*$) before interpolating it into SET clauses, and fail closed when a label is missing from SCHEMA_MAP.

  5. HighVS Code extension trusts workspace executable settings and sends unescaped paths to shells

    extensions/vscode/src/mcp/client.ts:65

    In extensions/vscode/package.json, cgc.executable and cgc.pythonPackagePath do not set scope to machine or application. Opening a cloned repository containing .vscode/settings.json can override cgc.executable or PYTHONPATH, causing CgcMcpClient.ensureStarted()—which runs automatically on extension activation—to execute attacker-controlled binaries or Python modules. In addition, SidebarControlPanel.launchVizServer(), toggle-watch, and SetupPanel._handleTest() concatenate executable and repository paths directly into terminal.sendText() and child_process.exec() without shell escaping.

    Fix: Set "scope": "machine" on cgc.executable and cgc.pythonPackagePath in extensions/vscode/package.json, use execFile/spawn with argument arrays instead of child_process.exec, and quote or pass arguments via terminal shellPath/shellArgs instead of raw string concatenation in terminal.sendText.

  6. HighSymlinked files in indexed repositories escape the repository boundary and expose external file contents

    src/codegraphcontext/tools/indexing/persistence/writer.py:425

    When indexing a repository, language parsers open symlinked files using the symlink's extension (for example, a symlink named leak.py pointing to ~/.aws/credentials or ~/.ssh/id_ed25519). Because Tree-sitter is error-tolerant and PythonTreeSitterParser attaches the full raw text of the file to the synthetic <module> Function node when INDEX_SOURCE is enabled (on by default, with REDACT_SECRETS off by default), the target file's contents are captured verbatim. In GraphWriter.add_file_to_graph, _normalize_path resolves the symlink and detects via relative_to() raising ValueError that the target lies outside the repository root, yet it only logs a warning and still writes the external File and Function nodes into the graph database. This lets a malicious repository bypass CGC_ALLOWED_ROOTS and expose arbitrary local files to MCP queries or bundle exports.

    Fix: Skip symlinked files during file discovery and parsing, and return early in GraphWriter.add_file_to_graph and add_minimal_file_node whenever file_path_obj.relative_to(repo_path_obj) raises ValueError.

  7. MediumHTTP API gateway binds to 0.0.0.0 unauthenticated by default with wildcard CORS on REST tool endpoints

    src/codegraphcontext/api/app.py:128

    cgc api start binds to 0.0.0.0:8000 by default and disables authentication unless CGC_API_KEY is manually set. Although the /api/v1/mcp endpoints validate the Origin header against localhost to prevent browser cross-origin and DNS-rebinding attacks, the REST endpoints mounted at /api/v1 (/api/v1/tools/call, /api/v1/query, /api/v1/index, /api/v1/repositories) omit require_mcp_transport_security and are wrapped in CORSMiddleware with allow_origins=['*']. When the gateway is running without an API key, anyone on the local network or any website the user visits in their browser can invoke MCP tools and run Cypher queries to read indexed source code.

    Fix: Bind cgc api start to 127.0.0.1 by default, require CGC_API_KEY (or auto-generate one) unless an explicit --no-auth flag is passed, restrict allow_origins to trusted localhost origins, and apply require_mcp_transport_security to the /api/v1 router.

  8. MediumLocal visualizer UI automatically opens a public Supabase Realtime tunnel exposing the local code graph

    website/src/pages/Explore.tsx:464

    When a user runs cgc visualize (or --visual CLI flags), the local server opens /explore?backend=http://localhost:8000 and loads the user's private local code graph (including file paths, symbols, relationships, and fileContents) into the browser. Even in local backend mode and without user consent, Explore.tsx automatically connects to a hardcoded public Supabase instance (husyiuqyswpudlyuskno.supabase.co) using a public anon key committed to the repo, subscribes to a non-private broadcast channel named cgc-tunnel-<6-char Math.random() token>, sends keepalives every 15 seconds, and answers incoming query-request and tool-call-request broadcasts for repo 'playground' using the local graph data. Anyone who guesses or learns the weak 6-character Math.random() session ID can remotely query the user's private code graph.

    Fix: Disable the Supabase KuzuCoordinator tunnel completely when running against a local backend unless the user explicitly enables it, generate session tokens with crypto.getRandomValues() using at least 128 bits of entropy, and use authenticated/private channels.

  9. MediumUnsandboxed custom prompt loading from repo .cgc/config.json allows prompt injection and arbitrary file reads

    src/codegraphcontext/cli/project_config.py:210

    During the MCP initialize handshake, build_system_prompt() automatically reads .cgc/config.json from the current working directory and loads the contents of every file listed in its prompts array into result.serverInfo.systemPrompt without user confirmation or is_path_allowed() validation. A cloned repository with a crafted .cgc/config.json can inject instructions into serverInfo.systemPrompt or reference arbitrary absolute or parent-traversal file paths (such as ~/.ssh/id_rsa or ~/.codegraphcontext/.env) so their contents are returned in the initialize response.

    Fix: Enforce is_path_allowed() so prompt files must resolve inside the project root, and require explicit user trust before loading .cgc/config.json prompts from a repository.

  10. Mediumanalyze_architectural_evolution MCP tool bypasses path sandbox to read git history anywhere on disk

    src/codegraphcontext/server.py:494

    Unlike add_code_to_graph, watch_directory, generate_report, and discover_codegraph_contexts, analyze_architectural_evolution_tool does not check repo_path with is_path_allowed() before passing it to EvolutionTimeline.analyze_hotspots() and EvolutionTimeline.get_growth_trend(), which run git log in cwd=repo_path. A prompt-injected agent can read commit hashes, author names, dates, and commit subjects from any git repository on the user's filesystem outside CGC_ALLOWED_ROOTS.

    Fix: Validate Path(repo_path).resolve() with is_path_allowed() in analyze_architectural_evolution_tool (and simulate_metrics_tool / simulate_architectural_change_tool) before accessing the repository.

  11. Mediumadd_package_to_graph imports parent Python packages via importlib.util.find_spec before sandbox checks

    src/codegraphcontext/tools/package_resolver.py:59

    _get_python_package_path() calls importlib.util.find_spec(package_name) before indexing_handlers.py checks is_path_allowed(). For dotted package names (such as pkg.sub), Python's find_spec() imports and executes pkg/__init__.py in the MCP server process. When the server is launched via python -m codegraphcontext mcp start (the fallback written by setup_wizard.py when cgc is not on PATH), the current working directory is on sys.path[0], allowing a prompt-injected agent to execute __init__.py inside an untrusted workspace.

    Fix: Resolve top-level package directories by inspecting sys.path / importlib.metadata distributions without calling find_spec() on dotted submodule names, and exclude the current working directory from package resolution.

  12. LowLocal visualizer server lacks authentication and Host header validation

    src/codegraphcontext/viz/server.py:760

    viz/server.py serves /api/graph (which returns full fileContents for indexed files) and /api/file without authentication or Host/Origin rejection middleware. While CORSMiddleware restricts Access-Control-Allow-Origin to localhost, it does not block DNS-rebinding attacks against 127.0.0.1:8000 from a browser tab, and scripts/docker-entrypoint.sh binds viz mode to 0.0.0.0:8080, exposing indexed source code and /api/ai_query to the network.

    Fix: Add Host and Origin validation middleware (matching _TransportSecurityMiddleware in api/app.py) to viz/server.py and require a session token or API key when binding to non-loopback interfaces.

  13. Lowcgc mcp setup writes plaintext credentials to ./mcp.json and auto-approves destructive tools

    src/codegraphcontext/cli/setup_wizard.py:188

    configure_mcp_client() (cgc mcp setup) copies all loaded configuration values—including NEO4J_PASSWORD, FALKORDB_PASSWORD, NORNIC_PASSWORD, and CGC_API_KEY—into ./mcp.json in the current working directory without restrictive file permissions (0o600) and prints the unmasked JSON to the terminal, risking accidental git commits or local credential exposure. It also adds delete_repository, add_code_to_graph, add_package_to_graph, and execute_cypher_query to tools.alwaysAllow.

    Fix: Omit secret keys (passwords and CGC_API_KEY) when printing or writing ./mcp.json (relying on ~/.codegraphcontext/.env with 0o600 permissions), and remove destructive or state-changing tools like delete_repository from default alwaysAllow lists.

  14. LowREADME recommends piping an unpinned remote shell script from main to bash

    README.md:317

    The installation troubleshooting section instructs users to run curl -sSL https://raw.githubusercontent.com/CodeGraphContext/CodeGraphContext/main/scripts/post_install_fix.sh | bash, executing an unverified script from a mutable git branch that modifies shell startup files (~/.bashrc, ~/.zshrc, PowerShell $PROFILE).

    Fix: Pin the script URL to an immutable release tag or commit SHA and document checksum verification or manual PATH instructions.

  15. LowDocker Compose visualization service binds unauthenticated server to all network interfaces

    docker-compose.yml:85

    Unlike the falkordb and neo4j services in the same file, which bind to 127.0.0.1, the viz service publishes port 8080 on all host interfaces (0.0.0.0:8080). Because the visualization server has no authentication, starting the viz profile exposes the indexed code graph and stored source code to anyone on the local network.

    Fix: Bind the visualization port to localhost only by changing the port mapping to 127.0.0.1:8080:8080.

  16. LowCommand and code injection via untrusted git tags and inputs in on-demand bundle workflow

    .github/workflows/generate-bundle-on-demand.yml:221

    The on-demand bundle workflow clones an arbitrary user-requested GitHub repository, reads its latest tag with git describe, and interpolates steps.repo-meta.outputs.tag (as well as github.event.inputs.repo_url) directly into bash and Python scripts. Because Git allows characters such as quotes, dollar signs, parentheses, and backticks in tag names, a crafted tag in a submitted repository can execute arbitrary code in a CI job holding contents: write permissions and Hugging Face registry write tokens. Rated low because CI workflows do not run on an installer's machine directly.

    Fix: Pass workflow inputs and step outputs through environment variables instead of inline template interpolation, and validate repository names and git tags against a strict allowlist regex.

  17. LowHosted website MCP relay uses unauthenticated broadcast channels and low-entropy session tokens

    website/api/v1/mcp/messages.ts:326

    The website's serverless MCP endpoint allows wildcard CORS without authentication and relays tool calls and responses to a user's browser over a Supabase Realtime broadcast channel named with a 6-character Math.random() token using the public anon key. Anyone holding the public anon key who guesses or observes a session token can query repositories cached in that browser tab or inject spoofed tool responses. Rated low because this endpoint belongs to the hosted web app rather than the locally installed package.

    Fix: Use cryptographically random high-entropy session tokens, require authenticated Supabase Realtime channels with Row-Level Security, and authenticate callers to the MCP HTTP endpoint.

  18. LowDocumentation instructs piping an unpinned remote shell script into bash

    README.md:317

    The troubleshooting section in README.md and its translations tells users to curl a shell script from the mutable main branch on GitHub directly into bash without pinning a commit hash or verifying a checksum.

    Fix: Document manual PATH setup or pipx ensurepath instead of curl | bash, or pin the script URL to an immutable commit SHA with a verified checksum.

  19. LowUnpinned remote shell script piped to bash in README

    README.md:317

    The troubleshooting section of README.md tells users to fetch scripts/post_install_fix.sh from the mutable main branch on GitHub and pipe it directly into bash. Because the URL is not pinned to a specific commit hash or release tag, a compromise of the repository's main branch would run attacker-controlled shell commands on the machine of anyone who runs that fix.

    Fix: Instruct users to add Python's user scripts directory (such as ~/.local/bin) to PATH directly, or pin the script URL to an immutable commit SHA and advise reviewing it before execution.

  20. LowCore dependency pins end-of-life protobuf 3.20.x with known denial-of-service flaws

    pyproject.toml:77

    pyproject.toml pins protobuf to >=3.20,<3.21 (last updated in 2022) as a required dependency. All 3.20.x releases are end-of-life and vulnerable to denial-of-service bugs when parsing deeply nested protobuf data (such as CVE-2024-7254 and CVE-2025-4565), which affects SCIP index parsing when SCIP_INDEXER is enabled and forces an outdated library into the Python environment.

    Fix: Regenerate the SCIP protobuf bindings (scip_pb2.py) with a modern protoc compiler and update the protobuf dependency constraint to a currently supported release.

  21. LowWorkspace settings can override executable paths in the VS Code extension

    extensions/vscode/package.json:124

    The VS Code extension manifest declares cgc.executable, cgc.pythonPackagePath, and cgc.neo4jUri without setting scope to machine. In VS Code, omitting scope lets a .vscode/settings.json file inside a cloned repository override those settings once the user trusts and opens the folder, allowing a repository to point the extension at an attacker-supplied executable or remote database.

    Fix: Set "scope": "machine" on cgc.executable, cgc.pythonPackagePath, and cgc.neo4jUri in extensions/vscode/package.json so workspace settings files cannot override them.

  22. LowUnpinned curl-to-bash script in README troubleshooting guide

    README.md:317

    The README troubleshooting section instructs users—and any AI agent following the README—to download post_install_fix.sh from the mutable main branch and pipe it directly into bash without pinning a commit hash or verifying a checksum. If the main branch were ever compromised, running that command would execute arbitrary shell code on the user's computer.

    Fix: Pin the script URL to an immutable release tag or commit SHA and verify its SHA-256 checksum before running it, or replace it with standard PATH setup commands such as pipx ensurepath.

  23. LowUnpinned curl-to-bash troubleshooting script in README

    README.md:317

    The README troubleshooting section instructs users to download scripts/post_install_fix.sh from the mutable main branch on GitHub and pipe it directly into bash without pinning a commit hash or verifying a checksum. If the repository's main branch were ever compromised, anyone running that command would execute attacker-controlled shell commands even if they installed a clean release from PyPI.

    Fix: Pin the script URL to an immutable commit SHA or release tag and verify a SHA-256 checksum before execution, or move the PATH check into a built-in CLI subcommand.

  24. LowVS Code extension executable settings lack machine scope

    extensions/vscode/package.json:124

    The companion VS Code extension manifest declares cgc.executable, cgc.pythonPackagePath, and cgc.neo4jUri without setting scope to machine, causing VS Code to default them to window scope. Unless the extension's TypeScript code explicitly ignores workspace-level values, a malicious .vscode/settings.json inside a cloned repository can override the executable path or database URI when opened in VS Code.

    Fix: Add "scope": "machine" to cgc.executable, cgc.pythonPackagePath, and cgc.neo4jUri in extensions/vscode/package.json so workspace settings files cannot override them.

  25. LowVS Code extension allows workspace settings to override executable paths

    extensions/vscode/package.json:124

    The VS Code extension defines the cgc.executable and cgc.pythonPackagePath settings without setting scope to machine, so VS Code defaults them to window scope. If a user installs the VS Code extension and opens a cloned repository inside a trusted workspace or trusted parent folder, a malicious .vscode/settings.json file in that repository can point cgc.executable or cgc.pythonPackagePath to an attacker-controlled program that runs on the user's computer.

    Fix: Add "scope": "machine" to cgc.executable, cgc.pythonPackagePath, and cgc.neo4jUri in extensions/vscode/package.json so workspace .vscode/settings.json files cannot override them.

  26. LowREADME instructs running an unpinned remote shell script via curl | bash

    README.md:317

    The troubleshooting section tells users to fix PATH issues by downloading scripts/post_install_fix.sh from the mutable main branch on GitHub and piping it straight into bash. If the repository's main branch is ever compromised or altered, anyone or any AI agent running that troubleshooting command will execute arbitrary shell code without version pinning or checksum verification.

    Fix: Pin the script URL to an immutable commit hash or release tag and verify a SHA-256 checksum before running it, or provide standard PATH instructions instead of piping curl to bash.

  27. LowCore dependency pins protobuf to an end-of-life 3.20.x release

    pyproject.toml:77

    The package pins protobuf to >=3.20,<3.21, a branch that stopped receiving updates in 2022 and misses security fixes in newer protobuf 4.x, 5.x, and 6.x releases for denial-of-service flaws when parsing untrusted protobuf data. Installing CodeGraphContext into a shared Python environment also downgrades protobuf for other installed tools.

    Fix: Upgrade protobuf compatibility and code generation to support current maintained protobuf releases (for example >=5.29.5 or >=6.31.1).

  28. LowUnpinned remote shell script piped directly to bash in README

    README.md:317

    The troubleshooting section instructs users to fix a missing command by downloading scripts/post_install_fix.sh from the mutable main branch on GitHub and piping it directly into bash without commit pinning or checksum verification. If the repository or branch were compromised, anyone running this troubleshooting snippet—or an AI agent following the README—would execute arbitrary commands.

    Fix: Pin the script URL to an immutable commit SHA or release tag with SHA-256 verification, or replace the curl-pipe-bash snippet with standard PATH instructions such as pipx ensurepath.

  29. LowVS Code extension executable path settings lack machine scope

    extensions/vscode/package.json:124

    The cgc.executable and cgc.pythonPackagePath settings omit "scope": "machine", so VS Code defaults them to window scope. If a user opens a cloned repository and trusts the workspace, a .vscode/settings.json file inside that repository can override cgc.executable to point to an attacker-controlled script or binary.

    Fix: Add "scope": "machine" to both cgc.executable and cgc.pythonPackagePath in extensions/vscode/package.json so workspace settings files cannot override executable paths.

  30. LowCore dependencies pin end-of-life protobuf 3.20.x

    pyproject.toml:77

    The package pins protobuf to >=3.20,<3.21 for all installations. The 3.20.x branch reached end-of-life in 2022 and contains unpatched denial-of-service flaws when parsing untrusted Protocol Buffers payloads (such as CVE-2024-7254 and CVE-2025-4565), which could crash indexing when parsing a crafted .scip file and forces a downgrade in shared Python environments.

    Fix: Upgrade the protobuf dependency constraint to a supported release series (for example >=5.29.5 or >=6.31.1) and regenerate any protobuf bindings if needed.