Skip to main content
Menu
Advisories

kicad_create_new_project: name escapes KICAD_MCP_WORKSPACE_ROOT and overwrites existing KiCad files without confirm_overwrite

GHSA-H93V-CCRJ-58FWPublished Updated GitHub

Description

Remediation (maintainer verified)

Upgrade to kicad-mcp-pro 4.15.1 or later. Version 4.15.1 was published on PyPI and npm on 2026-11-14.

The fix validates project names and output paths before creating files, prevents writes outside the selected project directory, rejects symlink escapes, and avoids replacing existing KiCad project files unless overwriting is explicitly confirmed. Regression tests cover traversal, absolute names, unexpected output paths, symlinks, and non-overwrite behavior.

The affected range recorded below begins at the earliest independently verified affected package version (3.34.6); earlier published versions have not been exhaustively assessed.

---

Summary

The MCP tool kicad_create_new_project(path, name, confirm_overwrite) checks path against the workspace root, but builds the project directory and file paths from name without any check. An absolute name or one containing .. writes the new .kicad_pro, .kicad_pcb and .kicad_sch files outside KICAD_MCP_WORKSPACE_ROOT. The overwrite guard looks at the new project directory, not at the files, so existing KiCad files at the target are replaced with empty templates without confirm_overwrite.

Affected: kicad-mcp-pro 4.10.0, commit 47365fa8d46c0931fab3c393c068148b736be13f (main, 2026-11-09). Severity (my estimate): High under your SECURITY.md ("unauthorized file access" / "destructive board mutation without consent").

Details

tools/project_creation.py: CreateProjectInput.name is only length-checked (1..120).

project/creation.py, ProjectCreationService.create(): base_dir = Path(path).expanduser().resolve() if cfg.workspace_root is not None: self.assert_within(cfg.workspace, base_dir) # only path is checked project_dir = base_dir / name # name is not if project_dir.exists() and any(project_dir.iterdir()) and not confirm_overwrite: refuse project_dir.mkdir(parents=True, exist_ok=True) project_file, pcb_file, sch_file = new_project_files(project_dir, name) # project_dir / f"{name}.kicad_pro" etc. ...write_text(...) x3 cfg.apply_project(project_dir, ...) # validates the workspace, but only now

With pathlib, base / "/victim/board" is /victim/board, and Path("/victim/board") / "/victim/board.kicad_pcb" is /victim/board.kicad_pcb. So assert_within passes (path is inside the workspace), the overwrite guard checks the new empty directory /victim/board, the three files are written next to it replacing any existing /victim/board.kicad_*, and only then does apply_project raise and roll back the settings. name="../../outside/board" behaves the same. Without a workspace root, an absolute name still skips the overwrite confirmation.

Suggested fix:

  1. Validate name as a single file-name component: reject absolute values, path separators and "..".
  2. Run assert_within(cfg.workspace, project_dir) and on each of the three files before any mkdir / write_text.
  3. Make the overwrite guard check the files that will be written, not only the directory.
  4. Add tests for an absolute name, "../x", and an existing <name>.kicad_pcb next to an empty directory.

Related, lower impact: utils/library_tables.py:100 builds pretty_dir / f"{footprint}.kicad_mod" without checking footprint, so the footprint tools can read a .kicad_mod file outside the library directories via "../". Only the path and the (model ...) line are returned, so this is minor.

Proof of concept

Setup: KICAD_MCP_WORKSPACE_ROOT=/ws, an existing project /victim/board.kicad_pro, /victim/board.kicad_pcb, /victim/board.kicad_sch (outside /ws), and no directory /victim/board.

Tool call: kicad_create_new_project(path="/ws", name="/victim/board")

Expected (from the code):

  • /victim/board/ is created.
  • /victim/board.kicad_pro, .kicad_pcb and .kicad_sch are overwritten with the empty templates.
  • The call then returns an error from apply_project, but the overwrite has already happened.

Variant: name="../../outside/board" writes /outside/board.kicad_*.

Found by static review only (plus checking the pathlib behaviour in plain Python). I did not run the server or test any installation; please confirm on your side.

Impact

Path traversal (CWE-22) leading to overwrite of KiCad project files, and creation of directories, outside the configured workspace, without the overwrite confirmation. Anyone who can call MCP tools on the server is affected, including an agent steered by prompt injection from a datasheet, a component description or a project file. This defeats the documented boundary in docs/configuration.md ("When KICAD_MCP_WORKSPACE_ROOT is set, project artifact reads and writes must stay under that root") and can destroy board and schematic designs.

Credit: Mohamad Njadat (GitHub: njadtmohmad). Happy to help test a fix.

Affected versions

References

GitHub · oaslananka/kicad-mcp-pro