# GHSA-X636-4CX8-QG64: Affected: kicad-mcp-pro 3.35.1 (PyPI) and main at f25db866f1223fe38fec86a63d955b455f82f0ad (i.e. after the #969 discovery change)

- Database: GitHub
- Severity: high (stated by ghsa, no CVSS score)
- Published: 2026-09-28
- Modified: 2026-09-28

## Affected versions

- kicad-mcp-pro (PyPI): from 3.15.0, fixed in 3.35.2

## Description

Affected: `kicad-mcp-pro` 3.35.1 (PyPI) and `main` at f25db866f1223fe38fec86a63d955b455f82f0ad (i.e. after the #969 discovery change). Verified on KiCad 10.0.6, macOS arm64, Python 3.13, MCP Python SDK over stdio, `KICAD_MCP_WORKSPACE_ROOT` unset (the default). Both builds behave identically for this issue.

## Summary

When the server is started with `--project-dir`, `scan_project_dir` / `select_canonical_kicad_file` (`src/kicad_mcp/discovery.py`) choose the active `.kicad_sch` / `.kicad_pcb`. The chosen path is never checked against the project (or workspace) root, so if the selected file is a **symlink pointing outside the project**, every file-backed tool follows it — for reads *and for writes*.

Explicit path arguments are already confined: `sch_get_symbols(sheet_file="link.kicad_sch")` on an escaping symlink is refused with "The requested path '…' escapes workspace root". Only the **auto-selected** active file skips that check.

The reliable trigger is a symlink **named after the project stem** (`<project>.kicad_sch`). git preserves symlinks, so a cloned repository or unpacked archive can ship one. Note that #969 (merged, "prefer the file matching the `.kicad_pro` stem") does **not** fix this and makes the stem-named case the *actively selected* one: discovery now prefers `<stem>.kicad_sch`, and if that entry is a symlink, it is chosen. (An extra, merely alphabetically-first symlink alongside the real file is **not** selected on either build, so the "sorts first" description from the first draft is not a reliable trigger; the stem-named symlink is.)

## Impact

Two effects, both with the malicious project opened via `--project-dir` and `KICAD_MCP_WORKSPACE_ROOT` unset (the default):

- **Write-through, outside the project (the elevating finding).** In a write-capable mode, editing the auto-selected schematic modifies the symlink's target *outside* the project. Verified by sha256 of the outside file before/after each call, with the in-project symlink left intact (the write went *through* the link, it was not replaced). Reproduced on both 3.35.1 and main, in `expert`/`experimental` and in `build`/`write`, for `sch_add_symbol`, `sch_update_properties` and `sch_modify_property` (4/4 write calls per build).
- **Read-through.** In the default `readonly` profile the auto-selected outside schematic is parsed and returned to the MCP client. Confirmed with a canary: a symbol Value placed in an outside schematic surfaced verbatim in `sch_get_symbols`.

Not found: linking a **non-KiCad** file (a `.env`-style file with canary tokens) as the active `.kicad_sch`/`.kicad_pcb`/`.kicad_pro` did **not** leak its bytes — 0 of 36 read responses across both builds contained any line of the file, including error text. So this is not an arbitrary-file-read of non-KiCad content; the disclosure is limited to files KiCad can parse as a design.

Data returned by read tools goes to the victim's own MCP client, so exfiltration needs a second step (for example prompt-injected text in the malicious project, or a report the agent saves back into the project and the user later commits). The write-through effect needs no second step: it changes a file on disk outside the project. In both cases the attacker must name the target path in advance via the symlink.

Suggested severity: **High** — an incorrect permission boundary that allows out-of-project file writes (and reads of KiCad designs) when a write-capable mode is used on an attacker-supplied project. It is not Critical in the default configuration (default mode is `readonly`, so only the read-through applies there) and it requires the user to open a crafted project, but the write-through crosses the documented "active project directory is the trusted I/O scope" boundary without consent. Final rating is yours.

## Reproduction (write-through, the High finding)

1. `cp -r <kicad>/demos/pic_programmer proj` and rename `proj/pic_programmer.*` → `proj/board.*`.
2. Put a schematic to be tampered with outside the project: `cp <some>.kicad_sch outside/victim.kicad_sch`.
3. Replace the project's own schematic with a stem-named symlink to it:
   `rm proj/board.kicad_sch && ln -s ../outside/victim.kicad_sch proj/board.kicad_sch`
4. `sha256sum outside/victim.kicad_sch` (record it).
5. Start the server on `proj` in a write mode (e.g. `--profile build --mode write`), `KICAD_MCP_WORKSPACE_ROOT` unset, and call `sch_add_symbol` (or `sch_update_properties`) with **no** `sheet_file` argument, so it targets the auto-selected active schematic.
6. `sha256sum outside/victim.kicad_sch` again: it changed, `proj/board.kicad_sch` is still a symlink, and the tool reported success naming `…/outside/victim.kicad_sch` as the target.

Read-through (default profile) is the same setup with the symlink target carrying a recognisable symbol Value; `sch_get_symbols` returns it.

## Workspace-root note

With `KICAD_MCP_WORKSPACE_ROOT` set to the project, `kicad_get_project_info` still returned normally in my test (it did not fail closed, and did not leak). I did not exercise a write under a set workspace root, so I cannot say whether the root reliably blocks the write-through. Please do not treat the workspace-root variable as a mitigation for this issue without confirming it; the fix below is independent of it.

## Suggested fix (recommended)

In discovery, apply the existing confinement check — `assert_within(project_dir or workspace_root, candidate.resolve())` — to every auto-discovered project, schematic and board file, skipping (or refusing) any candidate that resolves outside the root. This is the same check already enforced for explicit path arguments; the gap is only that auto-selected files bypass it. #969's stem preference does not close it, because a stem-named entry can itself be a symlink.

## References

- https://github.com/oaslananka/kicad-mcp-pro/security/advisories/GHSA-x636-4cx8-qg64

Page: https://cve.now/GHSA-X636-4CX8-QG64

Wrong or missing data? Send feedback: POST https://cve.now/api/v1/feedback (see https://cve.now/agents#feedback).
