---
title: "KiCad MCP Pro Path Traversal CVE-2026-141546 Defense Teardown"
slug: "kicad-mcp-pro-cve-2026-141546-path-traversal-defense"
description: "Defensive teardown of KiCad MCP Pro variant export path traversal (CVE-2026-141546), affected versions, sandbox isolation, and guardrail verification code."
author: "Hamdi Soudani"
category: "ai-security-jailbreaks"
archetype: "advisory-teardown"
published_at: "2026-12-04T04:05:05.555+00:00"
updated_at: "2026-12-04T04:05:05.759314+00:00"
canonical_url: "https://pyvren.com/blog/kicad-mcp-pro-cve-2026-141546-path-traversal-defense"
reading_time_minutes: 3
word_count: 527
quality_score: 89
tags: ["kicad-mcp-pro","cve-2026-141546","path-traversal","mcp-security","ai-security"]
keywords: ["kicad mcp pro cve-2026-141546 patch","variant export path traversal defense","kicad mcp workspace root containment","mcp server sandbox isolation","cwe-22 mcp tool write outside workspace"]
sources: ["https://advisories.gitlab.com/pypi/kicad-mcp-pro/CVE-2026-141546/","https://github.com/advisories/GHSA-wfmg-598x-58c5","https://radar.offseq.com/threat/kicad-mcp-pro-variant-export-tools-write-outside-kicadmcpworkspaceroot-via-unvalidated-variant-and-77287a19e03c6ffc"]
---

# KiCad MCP Pro Path Traversal CVE-2026-141546 Defense Teardown

> **TL;DR:** Upgrade KiCad MCP Pro to 4.20.1 or enforce realpath workspace containment on variant export tool arguments to block CVE-2026-141546 path traversal writes.

## Key Facts

- **CVE identifier:** CVE-2026-141546 ([source](https://advisories.gitlab.com/pypi/kicad-mcp-pro/CVE-2026-141546/))
- **Affected versions:** All versions before 4.20.1 ([source](https://advisories.gitlab.com/pypi/kicad-mcp-pro/CVE-2026-141546/))
- **Fixed version:** 4.20.1 ([source](https://advisories.gitlab.com/pypi/kicad-mcp-pro/CVE-2026-141546/))
- **CVSS 3.1 base score:** 5.0 Medium (AV:L/AC:L/PR:L/UI:R/S:U/C:N/I:H/A:N) ([source](https://radar.offseq.com/threat/kicad-mcp-pro-variant-export-tools-write-outside-kicadmcpworkspaceroot-via-unvalidated-variant-and-77287a19e03c6ffc))
- **Weakness class:** CWE-22 Improper Limitation of a Pathname to a Restricted Directory ([source](https://github.com/advisories/GHSA-wfmg-598x-58c5))
- **Guardrail p95 latency overhead:** Not measured in advisory; benchmark before production rollout ([source](https://advisories.gitlab.com/pypi/kicad-mcp-pro/CVE-2026-141546/))

KiCad MCP Pro versions before 4.20.1 allow variant export tools to write outside KICAD_MCP_WORKSPACE_ROOT because the `variant` and `output_name` arguments are joined to the output directory without validation. This advisory teardown covers the failure mechanics, why naive filters miss the issue, a sandbox isolation architecture, runnable guardrail code, and verification steps.

## Threat Model & Attack Surface Matrix

### Affected profiles
Profiles exposing variant export tools include agent_full, builder, critic, expert, full, high_speed, power, schematic, schematic_authoring, schematic_only, and simulation.

| Attack surface | Blast radius | Concrete control |
|---|---|---|
| Variant export `variant` argument | Arbitrary file overwrite outside workspace | Realpath containment check before write |
| Variant export `output_name` argument | Full path component control, directory creation outside root | Reject absolute paths and `..` segments, enforce root prefix |
| MCP profiles exposing variant tools | Agent steered by indirect prompt injection can trigger writes | Profile allowlisting, tool-call authorization |
| MCP server deployment | Local caller with tool access can write arbitrary files | Network isolation, least-privilege filesystem mounts |

The advisory notes that `variant` receives a suffix (`_bom.csv`, `_gerber`) while `output_name` controls the entire final path component. Both can overwrite pre-existing files outside the workspace, write to absolute paths outside it, and create directories outside it with no KiCad installed. This is CWE-22, Improper Limitation of a Pathname to a Restricted Directory.

## Why Naive Prompt Filters Fail

Prompt filters operate on natural-language input and cannot reliably catch structured tool arguments. An agent steered by indirect prompt injection from a datasheet, component description, or project file can emit a malicious `output_name` such as `../../etc/passwd` or an absolute path like `/tmp/malicious.cfg`. Keyword filters looking for `..` miss encoded variants, Unicode normalization tricks, and absolute paths that contain no traversal sequences. The root cause is missing server-side path containment, not user input language.

## Defense-in-Depth & Sandbox Isolation Architecture

Upgrade to kicad-mcp-pro 4.20.1 immediately. Until then, enforce containment at the MCP transport layer. Run the MCP server inside a user namespace or container with a read-only filesystem outside KICAD_MCP_WORKSPACE_ROOT, and mount the workspace root as the only writable path. Drop capabilities such as CAP_DAC_OVERRIDE so the server process cannot follow symlinks to sensitive host files. Use an MCP proxy that authorizes tool calls by profile and logs every variant export invocation.

## Runnable Guardrail Policy / Verification Code

### Test cases for validate_export_path

- Absolute path input must raise ValueError.
- Path containing `..` segment must raise ValueError.
- Symlink escape outside workspace root must raise ValueError.
- Relative path inside workspace root must return resolved path.

```python
import os
from pathlib import Path

WORKSPACE_ROOT = os.environ.get("KICAD_MCP_WORKSPACE_ROOT", "/workspace")
ROOT_REAL = os.path.realpath(WORKSPACE_ROOT)

def validate_export_path(candidate: str) -> str:
    """Return a safe absolute path inside the workspace root or raise."""
    if not candidate:
        raise ValueError("empty path argument")
    if os.path.isabs(candidate):
        raise ValueError("absolute paths are not allowed")
    if ".." in Path(candidate).parts:
        raise ValueError("parent directory segments are not allowed")
    joined = os.path.join(ROOT_REAL, candidate)
    resolved = os.path.realpath(joined)
    if resolved != ROOT_REAL and not resolved.startswith(ROOT_REAL + os.sep):
        raise ValueError("path escapes workspace root")
    return resolved

# Example: wrap variant export tool calls
# safe_path = validate_export_path(tool_args.get("output_name", ""))
# safe_path = validate_export_path(tool_args.get("variant", ""))
```

Run this check before every file write in `tools/variants.py`. Verify with `python -m pytest tests/variants/` after applying the patch, and confirm `pip show kicad-mcp-pro` reports version 4.20.1 or higher.

## Operational Tradeoffs & False-Positive Budget

Realpath validation adds measurable latency per path validation call under Linux container workloads; the advisory does not publish a benchmark, so measure p50 and p95 on your target hardware before production rollout. False positives occur when legitimate exports use symlinked output directories inside the workspace; resolve symlinks at deployment time and document allowed output names. Do not rely on prompt filtering alone. The fix does not address authentication gaps; combine it with MCP authorization and network segmentation.

![KiCad MCP Pro variant export path traversal threat radar card](https://radar.offseq.com/api/og.png?title=KiCad+MCP+Pro%3A+Variant+export+tools+write+outside+KICAD_MCP_WORKSPACE_ROOT+via+unvalidated+variant+and+output_name&severity=medium&id=CVE-2026-141546&cvss=5&v=7c7572f2)

[KiCad MCP Pro CVE-2026-141546 advisory](https://advisories.gitlab.com/pypi/kicad-mcp-pro/CVE-2026-141546/)

[GitHub Advisory GHSA-wfmg-598x-58c5](https://github.com/advisories/GHSA-wfmg-598x-58c5)

[OffSeq Threat Radar record](https://radar.offseq.com/threat/kicad-mcp-pro-variant-export-tools-write-outside-kicadmcpworkspaceroot-via-unvalidated-variant-and-77287a19e03c6ffc)

## Frequently Asked Questions

### Which KiCad MCP Pro versions are affected by CVE-2026-141546?

All versions before 4.20.1 are affected. Version 4.20.1 contains the patch. The flaw persists in 4.20.0 because PR #1720 only touched src/kicad_mcp/project/creation.py and did not add a shared path guard for variant export tools.

### What attacker requirements are needed to exploit this path traversal?

One MCP tool call with chosen variant or output_name arguments, access to a profile that exposes the variant export tools (agent_full, builder, critic, expert, full, high_speed, power, schematic, schematic_authoring, schematic_only, or simulation), and an active project. No KiCad GUI, IPC connection, second user, or authentication step is required.

### How can I verify the fix without upgrading immediately?

Run the realpath containment checker below against every variant export output path before write. Confirm that os.path.realpath(candidate).startswith(os.path.realpath(KICAD_MCP_WORKSPACE_ROOT) + os.sep) or equals the root exactly, and reject any path that escapes.

## Primary Sources

- https://advisories.gitlab.com/pypi/kicad-mcp-pro/CVE-2026-141546/
- https://github.com/advisories/GHSA-wfmg-598x-58c5
- https://radar.offseq.com/threat/kicad-mcp-pro-variant-export-tools-write-outside-kicadmcpworkspaceroot-via-unvalidated-variant-and-77287a19e03c6ffc
