Dec 3, 2026·9 min read·6 visits
KiCad MCP Pro versions prior to 4.20.1 fail to validate the 'variant' and 'output_name' parameters in three variant export tools after verifying the workspace root. An attacker or untrusted AI agent with access to a schematic-capable profile and an active project can use relative path traversal or absolute paths to write files and create directories outside KICAD_MCP_WORKSPACE_ROOT. Upgrading to version 4.20.1 remediates the flaw.
CVE-2026-141546 (GHSA-wfmg-598x-58c5) is a path traversal vulnerability (CWE-22) in KiCad MCP Pro prior to version 4.20.1. Three variant export tools in src/kicad_mcp/tools/variants.py construct target output paths by joining unvalidated user-supplied arguments directly onto the validated output directory using Python's pathlib.Path concatenation operator. A caller invoking these tools with path traversal sequences or absolute file paths can bypass the KICAD_MCP_WORKSPACE_ROOT confinement boundary to create directories and write or overwrite arbitrary files on the host filesystem.
KiCad MCP Pro (oaslananka/kicad-mcp-pro) is an open-source Model Context Protocol (MCP) server that connects AI agents and automated clients to KiCad Electronic Design Automation (EDA) schematic capture and printed circuit board (PCB) workflows. Because AI agents execute tool calls autonomously based on user prompts or external context, the server enforces a filesystem sandbox governed by the KICAD_MCP_WORKSPACE_ROOT configuration setting. All file generation and manipulation routines are designed to remain isolated within this configured workspace directory.
In versions prior to 4.20.1, a path traversal vulnerability classified under CWE-22 (Improper Limitation of a Pathname to a Restricted Directory) exists within the hardware variant management module located at src/kicad_mcp/tools/variants.py. Specifically, three MCP tool functions—variant_export_bom, variant_export_schematic, and variant_export_manufacturing_package—accept caller-controlled string parameters (variant and output_name) to determine the filenames of generated build artifacts.
These functions first invoke workspace validation helpers to ensure that the base variants subdirectory resides inside KICAD_MCP_WORKSPACE_ROOT. However, after establishing the validated base directory, the functions concatenate the unvalidated variant or output_name strings directly onto the directory path object. No canonicalization, character filtering, or post-join boundary verification is performed prior to executing file and directory write operations.
As a result, an MCP client or AI agent operating via prompt injection can supply relative traversal sequences (../ or ..\), absolute filesystem paths, or paths targeting symbolic links to break out of the workspace boundary. Successful exploitation allows the caller to create directories and write or overwrite files anywhere on the local filesystem accessible to the OS user running the MCP server process.
The root cause of CVE-2026-141546 lies in the order of path validation operations and the semantics of Python's pathlib.Path division operator (/) when handling untrusted path segments. In src/kicad_mcp/tools/variants.py, the server establishes a safe base directory by calling cfg.ensure_output_dir("variants") or _ensure_output_dir("variants"). This call verifies that <KICAD_MCP_WORKSPACE_ROOT>/variants is within the authorized boundary and ensures the directory exists on disk.
Once the out_dir (Path instance) is returned, the export tools construct target artifact paths using expressions such as out_dir / f"{variant}_bom.{fmt}" or out_dir / (output_name or f"{variant}_schematic.pdf"). When the right-hand operand of the pathlib.Path join operator contains parent directory traversal references (..), the operating system resolves the path relative to out_dir, ascending out of the variants directory and escaping KICAD_MCP_WORKSPACE_ROOT.
Furthermore, Python's pathlib.Path implementation follows POSIX and Windows path joining conventions regarding anchored paths. If the right-hand operand supplied via output_name (or variant when no prefix precedes it) begins with a root separator (/) or a Windows drive/UNC specification (such as C:\ or \\server\share), pathlib.Path completely discards the left-hand out_dir object and returns the right-hand absolute path directly.
In addition to traversal and absolute path overrides, the vulnerable code paths did not verify whether the target destination inside out_dir was a symbolic link pointing to an external file or directory. In variant_export_manufacturing_package, the server also invokes directory creation routines (gerber_dir and drill_dir) derived from the unvalidated variant string, permitting arbitrary directory creation outside the workspace.
Prior to commit 1ddb8ce1d3a8a67d4670f947a582d07c9ba29130, the three affected functions in src/kicad_mcp/tools/variants.py joined user-controlled arguments directly to out_dir without sanitization. Below is the vulnerable implementation pattern across the three tools:
# Vulnerable implementation in src/kicad_mcp/tools/variants.py (< 4.20.1)
# 1. variant_export_bom
out_dir = cfg.ensure_output_dir("variants")
# Flaw: 'variant' is interpolated directly into the filename and joined to out_dir
out_file = out_dir / f"{variant}_bom.{fmt}"
rows = _bom_rows(state, variant)
_write_bom(out_file, rows, fmt)
# 2. variant_export_schematic
out_dir = _ensure_output_dir("variants")
# Flaw: 'output_name' can be an absolute path or traversal sequence,
# and 'variant' can contain traversal sequences if output_name is omitted
out_file = out_dir / (output_name or f"{variant}_schematic.pdf")
# 3. variant_export_manufacturing_package
out_dir = _ensure_output_dir("variants")
# Flaw: Multiple file and directory targets constructed from unvalidated inputs
manifest_path = out_dir / (output_name or f"{variant}_manufacturing.json")
gerber_dir = out_dir / f"{variant}_gerber"
drill_dir = out_dir / f"{variant}_drill"
bom_path = out_dir / f"{variant}_bom.csv"To remediate this flaw in version 4.20.1 (Pull Request #1806), the maintainer introduced the _safe_variant_export_path validation helper and routed all variant artifact path constructions through it:
# Patched implementation in src/kicad_mcp/tools/variants.py (4.20.1)
def _safe_variant_export_path(output_dir: Path, variant: str, filename: str) -> Path:
"""Keep variant-generated artifacts within their designated output directory."""
for value in (variant, filename):
if (
not value
or value in {".", ".."}
or any(char in value for char in ("/", "\\", ":", "\x00"))
):
raise ValueError("Variant export names must be single filename components.")
# resolve_under canonicalizes the path, rejects absolute paths, and prevents symlink escapes
return resolve_under(output_dir, filename, allow_absolute=False)> [!NOTE]
> The patch applies a two-layer defense. First, it enforces syntactic validation on both variant and filename, rejecting empty strings, ., .., forward slashes (/), backslashes (\), colons (:), and null bytes (\x00). Second, it delegates final path resolution to resolve_under(output_dir, filename, allow_absolute=False), which canonicalizes the destination path and verifies that it does not traverse outside output_dir via pre-existing symbolic links.
Assessing fix completeness: the syntactic blocklist combined with canonical boundary verification via resolve_under effectively neutralizes relative path traversal, POSIX/Windows absolute path injection, UNC share paths, drive-letter prefixes, and symlink redirection across all three export tools.
Exploiting CVE-2026-141546 requires specific operational preconditions on the target KiCad MCP Pro instance. First, the MCP server must be running with a tool profile that exposes schematic and variant tools; these three tools are not enabled in the default restricted profile. Second, an active KiCad project must be loaded into the current server session state so that the variant export routines pass initial project state checks before reaching the path construction logic.
In a typical deployment, exploitation occurs either through a malicious local MCP client or via indirect prompt injection against an AI agent connected to the MCP server (for example, an LLM reading untrusted schematic metadata, issue descriptions, or third-party component libraries that instruct the agent to export a variant with crafted arguments).
When invoking variant_export_bom, the attacker controls the variant parameter, which is suffixed with _bom.<fmt>. While the suffix restricts exact filename selection in variant_export_bom, an attacker can still create or overwrite files with _bom.csv, _bom.json, or _bom.xml suffixes in arbitrary writable directories:
{
"name": "variant_export_bom",
"arguments": {
"variant": "../../../../tmp/pwned",
"format": "csv"
}
}In contrast, variant_export_schematic and variant_export_manufacturing_package accept the optional output_name parameter without appending a forced suffix when output_name is provided. This gives the caller full control over both the target directory path and the exact filename extension:
{
"name": "variant_export_manufacturing_package",
"arguments": {
"variant": "default",
"output_name": "../../../../home/developer/.ssh/authorized_keys"
}
}The unit test suite committed in tests/unit/test_variant_export_path_safety.py demonstrates the full range of cross-platform payloads capable of escaping the workspace prior to version 4.20.1:
# Traversal and absolute path payloads verified by regression tests:
unsafe_variant_values = [
"../outside",
r"..\outside",
"/absolute",
r"C:\absolute",
r"\\server\share\outside",
"nested/child",
r"nested\child",
".",
"..",
]
unsafe_output_names = [
"../outside.pdf",
r"..\outside.pdf",
"/absolute.pdf",
r"C:\absolute.pdf",
r"\\server\share\outside.pdf",
]CVE-2026-141546 is rated at a CVSS v3.1 base score of 5.0 (Medium) with the vector CVSS:3.1/AV:L/AC:L/PR:L/UI:R/S:U/C:N/I:H/A:N. The Local (AV:L) attack vector, Low privileges required (PR:L), and Required user interaction (UI:R) reflect that an attacker must interact with a local MCP server session where a user has configured a schematic-capable profile and opened an active KiCad project.
The primary technical impact is High Integrity loss (I:H). By leveraging output_name in variant_export_schematic or variant_export_manufacturing_package, an attacker can overwrite arbitrary files writable by the user running the MCP server. In variant_export_manufacturing_package, the written file contains JSON manifest data, while variant_export_schematic writes schematic export output and creates parent or sibling directories (<variant>_gerber and <variant>_drill).
On developer workstations where KiCad MCP Pro typically executes under the developer's primary user account, arbitrary file overwrite outside KICAD_MCP_WORKSPACE_ROOT can corrupt critical project files, overwrite configuration scripts (such as .bashrc, .zshrc, or Git hooks), or tamper with other repositories on the filesystem. Even when exact file content structure is constrained to JSON, CSV, or PDF headers, overwriting configuration files or planting files in sensitive directories compromises host integrity.
No direct confidentiality impact (C:N) occurs from the write operation itself, as the exported file contents are written to disk rather than returned from external files outside the workspace. Similarly, while overwriting critical user files can disrupt local workflows, the official advisory claims no direct availability score (A:N).
Users and administrators operating KiCad MCP Pro must upgrade to version 4.20.1 or later, which incorporates commit 1ddb8ce1d3a8a67d4670f947a582d07c9ba29130. Because KiCad MCP Pro is distributed across both Python (PyPI) and Node.js (npm) package ecosystems, ensure all local installations and cached tool runners (uvx or npx) are updated.
# Update via pip (PyPI)
pip install --upgrade "kicad-mcp-pro>=4.20.1"
# Update via uv / uvx
uv cache clean kicad-mcp-pro
uvx kicad-mcp-pro@4.20.1
# Update via npm
npm install kicad-mcp-pro@4.20.1> [!IMPORTANT]
> If you use ephemeral execution tools such as uvx or npx without pinning exact version numbers in your MCP client configuration (e.g., claude_desktop_config.json or .mcp.json), clear the local package cache and explicitly pin kicad-mcp-pro@4.20.1 to prevent executing a cached vulnerable release.
For environments where immediate upgrading is not possible, restrict the MCP server configuration to the default profile, which does not expose variant_export_bom, variant_export_schematic, or variant_export_manufacturing_package. Additionally, execute the MCP server inside an unprivileged container or sandboxed OS environment where filesystem write permissions are mounted read-only everywhere except the designated KICAD_MCP_WORKSPACE_ROOT directory.
CVSS:3.1/AV:L/AC:L/PR:L/UI:R/S:U/C:N/I:H/A:N| Product | Affected Versions | Fixed Version |
|---|---|---|
kicad-mcp-pro (PyPI) oaslananka | < 4.20.1 | 4.20.1 |
kicad-mcp-pro (npm) oaslananka | < 4.20.1 | 4.20.1 |
| Attribute | Detail |
|---|---|
| CVE ID | CVE-2026-141546 (GHSA-wfmg-598x-58c5) |
| Weakness Class | CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') |
| CVSS v3.1 Score | 5.0 Medium (CVSS:3.1/AV:L/AC:L/PR:L/UI:R/S:U/C:N/I:H/A:N) |
| Affected Component | src/kicad_mcp/tools/variants.py (variant_export_bom, variant_export_schematic, variant_export_manufacturing_package) |
| Attack Vector | Local / MCP Tool Invocation with crafted 'variant' or 'output_name' arguments |
| Primary Impact | Arbitrary File Write / Overwrite and Directory Creation outside KICAD_MCP_WORKSPACE_ROOT |
| Exploit Status | Proof-of-Concept (Regression tests in PR #1806) |
| Patched Version | 4.20.1 (Commit 1ddb8ce1d3a8a67d4670f947a582d07c9ba29130) |
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.
CVE-2026-141553 (GHSA-x9x8-xcv7-5x5g) is a medium-severity path traversal and arbitrary file overwrite vulnerability in termux-sync prior to version 1.3.8. During backup restoration, the cmd_restore function computes the extraction containment boundary as the parent directory of the target backup folder ($PREFIX or .../files) rather than the specific subdirectory itself. Consequently, a crafted backup archive (such as usr_etc.tar.gz) can extract files into sibling directories like $PREFIX/bin, overwriting system executables such as $PREFIX/bin/sh and achieving arbitrary code execution within the Termux user context.
CVE-2026-14534 (GHSA-m6fh-58r7-x697, PYSEC-2026-2149) is a high-severity security verification bypass in Trail of Bits Fickling up to version 0.1.10. Fickling is a Python pickle decompiler and static analysis tool used to detect malicious payloads in serialized objects and machine learning models. The vulnerability stems from an incomplete module blocklist (CWE-184) within Fickling's static analysis engine, which omitted the Python standard library modules _posixsubprocess, site, and atexit. Because Fickling classifies unblocked standard library imports as benign, malicious pickle streams utilizing these modules receive a LIKELY_SAFE verdict. When applications rely on fickling.load() or fickling.loads() as a defensive gate prior to deserialization, the bypass allows untrusted pickle bytecode to pass directly into Python's native pickle.loads(), resulting in arbitrary code execution (CWE-502).
CVE-2026-141555 (GHSA-vfhw-gfwp-vxfj) is a Cross-Site Scripting (XSS) vulnerability in the Python HTML sanitization library lxml-html-clean prior to version 0.4.7. The vulnerability stems from a parser differential between libxml2 and HTML5 browser parsing engines when handling HTML comments nested within raw-text and escapable raw-text elements (such as <noscript>, <textarea>, <title>, and <iframe>). When the cleaner is instantiated with the non-default configuration comments=False, an attacker can embed a closing tag inside an HTML comment to prematurely terminate the raw-text container in the client browser and execute arbitrary JavaScript.
CVE-2026-141556 (GHSA-5gvf-7wqf-r4cv) is an input sanitization bypass vulnerability resulting in Cross-Site Scripting (XSS) in lxml-html-clean versions through 0.4.6. When the Cleaner class is initialized with safe_attrs_only=False and javascript=True, the link sanitization mechanism relies exclusively on lxml.html.defs.link_attrs via doc.rewrite_links(). Because this attribute list omits the iframe srcdoc attribute and SVG SMIL animation value attributes (to, from, by, values), attackers can inject arbitrary HTML and JavaScript payloads that survive sanitization.
CVE-2026-140000 (also tracked as GHSA-j7r2-xppq-m353) is an uncontrolled resource consumption vulnerability in the faye/websocket-driver-node package prior to version 0.8.2. The StreamReader.read() implementation relies on Buffer.slice() when extracting small segments from incoming network buffers. Because Node.js Buffer slices share underlying memory with their parent ArrayBuffer, small fragmented WebSocket frames retain references to entire 16 KiB to 64 KiB TCP read buffers. An unauthenticated remote attacker can transmit a sequence of incomplete fragmented frames to prevent garbage collection of the parent TCP buffers, causing severe memory inflation and a denial of service via out-of-memory process termination.
CVE-2026-135390 is an authentication bypass vulnerability in the Pion DTLS Go library caused by improper validation of cached DTLS 1.2 sessions. When an application shares a single SessionStore across both outbound client connections and inbound server listeners, a remote server previously contacted by the application's client can reuse the negotiated session identifier and master secret to authenticate against the application's server listener via abbreviated session resumption, bypassing mutual TLS and Pre-Shared Key checks.