CVE-2026-141546: KiCad MCP Pro Variant Export Tools Write Outside Vulnerability
MODERATECVE-2026-141546 is a MODERATE (CVSS 5.0) variant export tools write outside vulnerability (CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')) affecting KiCad MCP Pro libraries in the PyPI ecosystem. The issue involves variant export tools write outside kicad_mcp_workspace_root via unvalidated variant and output_name arguments. Remediation is available by upgrading affected packages to version 4.20.1.
CVE-2026-141546 at a Glance
Security Impact
CVSS: 5.0
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:L/AC:L/PR:L/UI:R/S:U/C:N/I:H/A:N).
How to Fix CVE-2026-141546
To remediate this vulnerability, upgrade all affected KiCad MCP Pro dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
pip install kicad-mcp-pro>=4.20.1
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
pip show kicad-mcp-pro
How to Check if You Are Affected
To determine whether your Python environment is affected by CVE-2026-141546, inspect your installed packages using pip:
pip show kicad-mcp-pro
Analyze the terminal output to locate any version of KiCad MCP Pro in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 4.20.1), your application is affected.
Note: The pip show kicad-mcp-pro command checks currently installed packages in your active Python environment.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'), where the product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory. In KiCad MCP Pro, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2026-141546 Affected KiCad MCP Pro Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
kicad-mcp-pro
|
PyPI |
< 4.20.1
|
4.20.1
|
References
Frequently Asked Questions
What is CVE-2026-141546?
Which KiCad MCP Pro versions are affected?
What version fixes CVE-2026-141546?
Is kicad-mcp-pro affected?
What is the CVSS score of CVE-2026-141546?
What CWE is associated with CVE-2026-141546?
How can I check PyPI dependencies for CVE-2026-141546?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-wfmg-598x-58c5",
"modified" : "2026-12-03T02:28:48Z",
"published" : "2026-12-03T02:28:48Z",
"aliases" : [ "CVE-2026-141546" ],
"summary" : "KiCad MCP Pro: Variant export tools write outside KICAD_MCP_WORKSPACE_ROOT via unvalidated variant and output_name arguments",
"details" : "## Summary\n\nThe three variant export tools build their output path by joining an unvalidated tool argument onto the output directory, so the write lands wherever that argument points. `KICAD_MCP_WORKSPACE_ROOT` does not contain it.\n\nBoth `variant` and `output_name` work. `variant` has a suffix appended (`_bom.csv`, `_gerber`), while `output_name` has none, so with `output_name` the caller controls the entire final path component.\n\nIt overwrote a pre-existing file outside the workspace root, wrote to an absolute path outside it, and created directories outside it with no KiCad installed at all.\n\nThis is the same class as GHSA-h93v-ccrj-58fw, which was fixed in 4.15.1, in a module that fix did not touch. PR #1720 changed only `src/kicad_mcp/project/creation.py` and two test files, and added no shared guard, so the pattern survives in 4.20.0.\n\n## Affected versions\n\nTested on:\n\n- Repository: https://github.com/oaslananka/kicad-mcp-pro\n- Commit: 70ae5a77b644f039f83e82caa6d4b6b54e54c044 (main, 2026-11-18)\n- Package version: `kicad-mcp-pro` 4.20.0 from PyPI (latest). Everything below ran against the installed wheel; the checkout only supplied line numbers, which match.\n- Python version: 3.13.18\n- OS: Linux (Debian, in Docker)\n\n## Impact\n\nAnyone who can call these MCP tools can write and overwrite files outside the configured workspace root. That is the attacker model your own advisory for GHSA-h93v-ccrj-58fw describes, including an agent steered by prompt injection from a datasheet, a component description or a project file.\n\nAttacker requirements:\n\n- One MCP tool call with chosen arguments.\n- A schematic-capable profile. The tools are **not** in the `default` profile. I enumerated `tools_for_profile` at runtime: they appear in `agent_full`, `builder`, `critic`, `expert`, `full`, `high_speed`, `power`, `schematic`, `schematic_authoring`, `schematic_only` and `simulation`. Your `.env.example:48` documents `KICAD_MCP_PROFILE=full`, and `server.py:2388-2399` materialises the `full` catalog for programmatic hosts.\n- An active project. No KiCad GUI, no IPC connection, no second user, and no authentication step.\n\n## What the documentation promises\n\n`docs/configuration.md:221-226`, \"Workspace Safety\":\n\n> When `KICAD_MCP_WORKSPACE_ROOT` is set, project artifact reads and writes must stay under that root.\n\nAlso `docs/errors.md:34` describes `UNSAFE_PATH` as \"A requested path escapes the workspace\", `docs/integration/kicad-studio.md:95` says the variable \"constrains project artifact reads and writes\", and the tool's own docstring at `tools/variants.py:343` says the BOM goes \"into the project output directory\".\n\n## Reproduction\n\nThe PoC is local and non-destructive: everything is written inside a container, and `/work/outside` stands in for a location outside the configured root.\n\n```bash\npython -m venv .venv && .venv/bin/pip install kicad-mcp-pro==4.20.0\n# /work/ws is KICAD_MCP_WORKSPACE_ROOT, /work/ws/proj is the active project\n# (a copy of tests/fixtures/benchmark_projects/pass_minimal_mcu_board),\n# /work/outside is outside the root\n.venv/bin/python -I poc_variants.py\n```\n\nFirst, the controls. The documented resolver and your own `pcb_export_stats` both refuse the same strings:\n\n```text\nresolve_within_project('../../../outside/control.csv') REFUSED: UnsafePathError: The requested path '/outside/control.csv' escapes workspace root '/work/ws/proj'.\nresolve_within_project('/work/outside/control.csv') REFUSED: UnsafePathError: The requested path '/work/outside/control.csv' escapes workspace root '/work/ws/proj'.\nensure_output_dir('../../outside') REFUSED: UnsafePathError: Output subdirectories cannot contain parent traversal.\nexport_board_stats('../../../outside/stats.json') REFUSED: ValueError: Output name must be a single file name, not a path.\nvariant_export_bom('prod') -> /work/ws/proj/output/variants/prod_bom.csv\n```\n\nOverwriting a file outside the root. `/work/outside/victim_bom.csv` contained `ORIGINAL-CONTENT-DO-NOT-TOUCH` before the call:\n\n```text\nvariant_create('../../../../outside/victim') -> Created design variant '../../../../outside/victim' in /work/ws/proj/demo.kicad_pro.\nvariant_export_bom('../../../../outside/victim') -> Variant BOM exported to /work/ws/proj/output/variants/../../../../outside/victim_bom.csv (2 populated component(s)).\n\n--- /work/outside/victim_bom.csv now contains ---\nreference,value,footprint,populated,dnp\nR1,10k,Resistor_SMD:R_0805,True,False\nR2,22k,Resistor_SMD:R_0805,True,False\n\noverwritten outside the workspace root: True\n```\n\nAn absolute variant name, no traversal needed:\n\n```text\nvariant_export_bom('/work/outside/abs') -> Variant BOM exported to /work/outside/abs_bom.json (2 populated component(s)).\nexists: True\n```\n\nDirectory creation outside the root, with no kicad-cli present at all:\n\n```text\nvariant_export_manufacturing_package('../../../../outside/mfg')\ntool raised after the directory was created: FileNotFoundError: kicad-cli is not available. ...\ncreated outside root: /work/outside/mfg_gerber True\n```\n\nFor `output_name` I pointed `KICAD_MCP_KICAD_CLI` at a stub that only creates the file it is told to create with `--output`, since kicad-cli is not installed in the container. **That part uses a simulated CLI and I am labelling it as such.** What is under test is the path your code hands to `--output`, which is pure Python. The manifest write in the third case is your own `write_text`, not the stub.\n\n```text\nvariant_export_schematic(output_name='../../../../outside/pwned_by_output_name.pdf') -> exists outside root: True\nvariant_export_schematic(output_name='/work/outside/abs_output_name.pdf') -> exists outside root: True\nvariant_export_manufacturing_package(output_name='../../../../outside/pkg.json') -> exists outside root: True\n\nstate of /work/outside\n /work/outside/abs_output_name.pdf (31 bytes)\n /work/outside/pkg.json (257 bytes)\n /work/outside/pwned_by_output_name.pdf (31 bytes)\n```\n\nExpected safe behavior:\n\n```text\nAll of the above raise UnsafePathError, or reject the argument as not being a\nsingle file name, exactly as the four controls do.\n```\n\n## Root cause\n\n`src/kicad_mcp/tools/variants.py`, line numbers identical in the wheel and the checkout:\n\n```python\n351: out_file = out_dir / f\"{variant}_bom.{fmt}\"\n451: out_file = out_dir / (output_name or f\"{variant}_schematic.pdf\")\n515: manifest_path = out_dir / (output_name or f\"{variant}_manufacturing.json\")\n526: gerber_dir = out_dir / f\"{variant}_gerber\"\n557: drill_dir = out_dir / f\"{variant}_drill\"\n```\n\n`variant` reaches `variant_create` at `:261`, where the only check is `:263-264`, `if not name.strip()`. It is then stored verbatim as a JSON key and never treated as a path, so nothing rejects a traversal or an absolute path at creation time. `variant_export_bom` at `:342` does not validate it either; `format` is allowlisted at `:345-346`, and `variant` is not.\n\n`output_name` reaches `:435` and `:486` unvalidated.\n\nThe writes are `_write_bom` at `:353` (reaching `path.write_text` at `:218` and `:228`), `manifest_path.write_text` at `:599`, `gerber_dir.mkdir` at `:527`, and the `--output` argument passed to kicad-cli at `:462` and `:472`.\n\n`cfg.ensure_output_dir(\"variants\")` at `:350` does not help: `config.py:582-596` validates the base with `assert_within(self.workspace, base)` and the subdir with `relative_subpath(subdir)`, and it only ever sees the literal `\"variants\"`. The attacker-controlled string is appended afterwards. Under pathlib, `..` segments survive the join and an absolute path replaces the base entirely.\n\nThe check that is missing here exists elsewhere in the project. `src/kicad_mcp/export/board_stats.py:49-55`:\n\n```python\nout_file = out_dir / (output_name.strip() if output_name else \"board_stats.json\")\nif \"/\" in str(out_file.relative_to(out_dir)) or \"\\\\\" in str(out_file.relative_to(out_dir)):\n raise ValueError(\"Output name must be a single file name, not a path.\")\n```\n\n`tools/footprint.py:42`, `tools/symbol.py:82` and `tools/jobset.py:79` use the other idiom, `Path(...).name`. `tools/variants.py` imports `resolve_under` at `:14` and calls it only for the import path at `:97`, never for an output path.\n\n## Suggested fix\n\nReject `variant` values that are not a single path component at `variant_create`, and run `output_name` and the derived paths through `get_config().resolve_within_project(...)`, or the `Path(...).name` idiom already used in `footprint.py`, `symbol.py` and `jobset.py`, in all three export tools before any `write_text`, `mkdir`, or `--output`.\n\n## Not claimed\n\n- Windows drive and UNC forms. `reject_foreign_windows_path` (`path_safety.py:84-94`) is never called on these arguments, but I had no Windows host, so I am not claiming it.\n- Any confidentiality impact.\n\n## Disclosure\n\nThis report was prepared with AI assistance; every result above comes from a run the reporter executed against the 4.20.0 wheel, and the one simulated component (the kicad-cli stub) is labelled where it appears.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:L/AC:L/PR:L/UI:R/S:U/C:N/I:H/A:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "PyPI",
"name" : "kicad-mcp-pro"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "4.20.1"
} ]
} ],
"database_specific" : {
"last_known_affected_version_range" : "<= 4.20.0"
}
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/oaslananka/kicad-mcp-pro/security/advisories/GHSA-wfmg-598x-58c5"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-141546"
}, {
"type" : "WEB",
"url" : "https://github.com/oaslananka/kicad-mcp-pro/pull/1806"
}, {
"type" : "WEB",
"url" : "https://github.com/oaslananka/kicad-mcp-pro/commit/1ddb8ce1d3a8a67d4670f947a582d07c9ba29130"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/oaslananka/kicad-mcp-pro"
}, {
"type" : "WEB",
"url" : "https://github.com/oaslananka/kicad-mcp-pro/releases/tag/mcp-server-v4.20.1"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-22" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2026-12-03T02:28:48Z",
"nvd_published_at" : "2026-12-02T19:18:01Z"
}
}