CVE-2022-23947
Executive Summary
CVE-2022-23947 is a stack-based buffer overflow vulnerability in the Gerber Viewer component of KiCad EDA 6.0.1 and master commit de006fc010. The flaw resides in the parsing of gerber and excellon DCodeNumber data, where a specially-crafted file can trigger memory corruption and lead to arbitrary code execution. An attacker can deliver a malicious gerber or excellon file to a user, who would need to open it in KiCad's Gerber Viewer for exploitation to succeed. Given the CVSS score of 7.8 (High severity), successful exploitation grants an attacker the same privileges as the logged-in user, potentially leading to full system compromise. This vulnerability is particularly relevant to electronics manufacturers, PCB designers, and engineering firms that routinely exchange and open gerber files as part of their workflow.
This record — and 170,000+ others — are available via the ValtersIT API. One endpoint replaces five: NVD + GitHub CVE + CISA KEV + EPSS + Nuclei + Exploit-DB, unified.
No signup required
Technical Analysis
KiCad EDA is an open-source electronics design automation suite widely used for schematic capture and PCB layout. The Gerber Viewer component is a dedicated utility for previewing manufacturing files (gerber and excellon drill files) before fabrication. These files are standard in the electronics industry and are often shared between designers and fabrication houses.
The vulnerability is a stack-based buffer overflow in the DCodeNumber parsing functionality. Gerber and excellon file formats include D-codes (DCodeNumbers) that define aperture shapes, tool definitions, and drawing operations. The parsing logic responsible for reading and interpreting these numeric codes fails to properly validate input length before copying data into a fixed-size stack buffer. When a malicious file contains an excessively long or malformed DCodeNumber sequence, the parsing routine writes beyond the allocated stack boundary, overwriting adjacent stack memory including the saved return address and possibly other critical control structures.
The NVD description identifies the affected builds as KiCad EDA 6.0.1 and master commit de006fc010, indicating the vulnerability exists in both the stable 6.0.x release branch and the development master branch as of early 2022. Since gerber and excellon files are typically received from external sources (manufacturers, contractors, collaborators), the attack surface is significant: a user merely previewing an untrusted file could trigger the overflow.
The technical details of the exact function names, stack buffer sizes, and variable declarations are not provided in the NVD description. The vulnerability class — stack-based buffer overflow — suggests a classic memory corruption pattern where a fixed-size allocation (likely used during tokenized parsing of the file stream) is overwritten by crafted input. Successful exploitation would require hijacking control flow, typically by overwriting the saved return address to redirect execution to attacker-controlled shellcode placed elsewhere in the input file.
Exploitation Scenarios
No public PoC or exploit code has been confirmed for CVE-2022-23947 (POC_STATUS: Unknown). The following attack chain is inferred from the vulnerability class and the NVD description, not from observed real-world exploitation.
Step 1 — Reconnaissance/Target Identification: The attacker identifies targets in the PCB design and manufacturing ecosystem — electronics engineers, PCB designers, hardware startups, and fabrication houses that use KiCad EDA. The targeting can be broad (phishing campaigns with malicious gerber files attached to emails) or focused (directed attacks against specific companies where intellectual property theft or sabotage of manufacturing files would cause significant damage). Social engineering would likely revolve around pretexts such as "PCB fabrication files for quote," "design review files," or "updated drill files from the manufacturer."
Step 2 — Triggering the Vulnerability: The attacker crafts a malicious gerber or excellon file containing a DCodeNumber field that exceeds the fixed-size buffer allocated in the parsing routine. The file is delivered to the victim, who opens it in KiCad's Gerber Viewer (the intended use case for such files). When the viewer's parsing code encounters the oversized DCodeNumber, it copies the input into a stack buffer without bounds checking, causing a stack overflow. The trigger is as simple as opening the file — no administrative privileges or special conditions are required beyond the victim running KiCad.
Step 3 — Payload/Execution: The overflow corrupts the stack, including the saved return address of the affected parsing function. The attacker controls the data overwriting the stack, allowing them to redirect program execution to code within the malicious file itself or to ROP (Return-Oriented Programming) gadgets in the KiCad binary. The payload executes with the privileges of the user running KiCad. Since the entire gerber/excellon file content is attacker-controlled, there is ample space for shellcode or ROP chains to be embedded within the file structure itself.
Step 4 — Post-Exploitation Impact: Once code execution is achieved, the attacker operates with the victim's user privileges. Potential post-exploitation activities include: exfiltration of locally stored PCB design files and intellectual property; installation of backdoors for persistent access; lateral movement within the victim's network; and in targeted industrial contexts, manipulation of design files sent to manufacturers, potentially introducing hardware-level Trojans or defects. The confidentiality, integrity, and availability impacts are all rated High in the CVSS vector.
Impact Assessment
The CVSS v3.1 score of 7.8 (High severity) reflects a locally-exploitable, low-complexity flaw that requires no privileges but does require user interaction (opening a malicious file). The attack vector is Local (AV:L), meaning the attacker must deliver a file to the victim's system; this is typical for file-parsing vulnerabilities.
Impact subscores from the vector:
- Confidentiality Impact: High (C:H) — successful exploitation can lead to full file system access and data exfiltration under the victim's user context.
- Integrity Impact: High (I:H) — attacker can modify or delete files, alter design documents, or implant backdoors.
- Availability Impact: High (A:H) — in addition to malicious code execution, the overflow may also crash the Gerber Viewer, but full availability loss is possible through attacker-controlled actions (e.g., system shutdown, destructive payloads).
Affected systems: KiCad EDA 6.0.1 (stable release) and master commit de006fc010 (development branch). Organizations running earlier 6.0.x releases or the specific master commit are at risk. The EPSS score of 0.01460 places this vulnerability in the 71.1st percentile of exploited CVEs — meaning it is above-average in exploitation likelihood but not among the most actively exploited.
Blast radius is moderate-to-high. KiCad is free and open-source, widely used in the hobbyist/education sector, startups, and increasingly in professional engineering firms where cost-sensitive designs are produced. The electronics manufacturing supply chain is the most critical consideration: gerber and excellon files are the standard exchange format for PCB fabrication, meaning the vulnerability sits at a common trust boundary where files from untrusted sources are routinely opened for inspection. An attacker compromising this boundary could impact multiple companies concurrently if they can distribute a malicious file to several targets.
Detection Guidance
Given the file-parsing nature of this vulnerability, detection strategies should focus on (1) network-level inspection of gerber/excellon file transits, (2) host-level monitoring of KiCad process behavior and anomalous memory access patterns, and (3) endpoint detection of abnormal file metadata or content signatures.
Sigma Rule
title: Suspicious KiCad Gerber Viewer Process Behavior
id: 8a3f2c10-716a-4d24-9b57-42d1b50b8a10
status: experimental
description: Detects anomalous KiCad Gerber Viewer process behavior that may indicate exploitation of CVE-2022-23947 stack-based buffer overflow
references:
- https://nvd.nist.gov/vuln/detail/CVE-2022-23947
author: vartersit.com Threat Intelligence
date: 2024/01/15
logsource:
category: process_creation
product: windows
detection:
selection_kicad:
Image|contains:
- '\kicad-cli.exe'
- '\gerbview.exe'
- '\kicad.exe'
selection_extension:
CommandLine|contains:
- '.gbr'
- '.pho'
- '.excellon'
- '.drl'
- '.nc'
selection_childproc:
ParentImage|contains: 'kicad'
condition: selection_kicad and selection_extension
fields:
- CommandLine
- ParentImage
- Image
falsepositives:
- Legitimate opening of gerber/drill files for design review
level: low
tags:
- attack.t1203
- cve.2022-23947
YARA Rule
rule CVE_2022_23947_Gerber_DCodeNumber_Overflow {
meta:
author = "valtersit.com Threat Intelligence"
description = "Detects suspicious gerber/excellon files with oversized DCodeNumber fields potentially targeting CVE-2022-23947"
cve = "CVE-2022-23947"
date = "2024-01-15"
severity = "high"
strings:
// DCode markers commonly found in gerber files (G code or D code prefixes)
$dcode1 = /D[0-9]{3,}/
$dcode2 = "DCode"
$dcode3 = /(G54|G55|G70|G71|G90|G91)/
// Excellon drill file markers
$excellon1 = "M48"
$excellon2 = "METRIC"
$excellon3 = "INCH"
// Look for extremely long runs of digits (potential buffer overflow trigger)
$longnum = /[0-9]{200,}/
// Cyclic patterns that might indicate overflow padding
$cyclic1 = "AAAA"
$cyclic2 = "BBBB"
$cyclic3 = "41414141"
condition:
any of ($dcode*) and any of ($excellon*) and any of ($longnum*) or
(any of ($dcode*) and any of ($cyclic*)) or
(any of ($excellon*) and any of ($cyclic*))
}
Suricata IDS Rule
alert tcp any any -> any any (msg:"CVE-2022-23947 - KiCad Gerber Viewer Stack Overflow Attempt"; flow:established,to_server; content:"D"; depth:1; pcre:!"/D[0-9]{1,3}(?!\d)/"; pcre:"/D\d{" < 200; content:"|0d 0a|"; within:200; detection_filter:track by_src, count 5, seconds 60; reference:cve,2022-23947; reference:url,https://nvd.nist.gov/vuln/detail/CVE-2022-23947; classtype:attempted-user; sid:10000001; rev:1;)
Elastic Detection
event.category:process AND event.action:executed AND
process.name:(gerbview.exe OR kicad-cli.exe OR kicad.exe) AND
process.command_line:(*.gbr OR *.pho OR *.drl OR *.excellon OR *.nc) AND
NOT event.outcome:success
NOTE: The above EQL rule assumes standard Elastic ECS fields. For host-based detection of the actual overflow (Windows), monitor Application Error Logs for KiCad crashes with exception code 0xC0000005 (Access Violation) or 0xC0000409 (Stack Buffer Overflow):
event.provider:"Application Error" AND event.code:"1000" AND
winlog.event_data.faulting_application:(*kicad* OR *gerbview*) AND
winlog.event_data.faulting_module:(*kicad* OR *gerbview*)
Splunk SPL Query
index=windows sourcetype=ProcessCreation
(Image=*\\gerbview.exe OR Image=*\\kicad.exe OR Image=*\\kicad-cli.exe)
(CommandLine=*.gbr OR CommandLine=*.pho OR CommandLine=*.drl OR CommandLine=*.excellon OR CommandLine=*.nc)
| table _time, Image, CommandLine, User, ParentImage
| sort - _time
// Additional query for KiCad process crashes (buffer overflow indicators)
index=windows sourcetype=XmlWinEventLog source="Windows Event Log"
EventCode=1000
Message=*kicad* OR Message=*gerbview*
For file-based detection on Windows:
index=windows sourcetype=WinEventLog:Security
EventCode=4663
ObjectName=*.gbr OR ObjectName=*.drl OR ObjectName=*.pho
Message=*DELETE* OR Message=*WRITE*
Wazuh OSSEC Rule
<group name="kicad," cve="CVE-2022-23947,">
<rule id="100321" level="12">
<if_sid>550</if_sid>
<match>kicad|gerbview</match>
<regex>\.gbr|\.drl|\.pho|\.excellon|\.nc</regex>
<description>KiCad Gerber Viewer detected opening a file with suspicious extension - potential CVE-2022-23947 exploitation</description>
<group>vulnerability_attempt,</group>
<mitre>
<id>T1203</id>
</mitre>
</rule>
<rule id="100322" level="14">
<if_sid>100321</if_sid>
<match>Stack buffer overflow|Buffer overflow|0xc0000409|0xc0000005</match>
<description>KiCad process crashed with buffer overflow indicator - possible exploitation of CVE-2022-23947</description>
<group>vulnerability_attempt,</group>
</rule>
<rule id="100323" level="10">
<if_sid>550</if_sid>
<program_name>kicad|gerbview</program_name>
<description>KiCad process execution - monitor for anomaly (CVE-2022-23947 related)</description>
<group>kicad_monitoring,</group>
</rule>
</group>
Mitigation & Patch Guidance
Patch confidence for CVE-2022-23947 is 2/4 (CLAIMED — single source claims patch not independently confirmed). The only referenced patch source is Debian, but no specific advisory or package version has been confirmed.
Immediate Mitigations:
- Restrict the opening of gerber/excellon files from untrusted sources. Implement a policy requiring files to be received from known vetted manufacturers or internal teams.
- Use an alternative viewer for untrusted gerber files, or open files in a sandboxed environment (e.g., Docker container, virtual machine, or a dedicated low-privilege user account) to contain potential exploitation.
- Monitor KiCad process crashes and anomalous file access patterns as an early warning.
- Keep KiCad installations separate from critical corporate data and access to internal resources.
Patch/Upgrade Steps:
- Monitor the KiCad release channels (GitHub releases, official mailing lists) for versions newer than 6.0.1 that contain a confirmed fix.
- Check Debian security tracker (security-tracker.debian.org) for updated KiCad packages with CVE-2022-23947 fix references.
- When a patched version is confirmed, upgrade all KiCad installations. The specific patched version is NOT confirmed — do not assume any current version is safe until the patch is independently verified.
- Verify the integrity of downloaded packages via checksums or signatures from the official vendor.
Long-Term Hardening:
- Establish a file-screening gateway for incoming engineering files (gerber, excellon, STEP, IDF) — scan for malformed content and unusual structures before they reach users.
- Apply the principle of least privilege to engineering workstations — run KiCad under a standard user account, not an administrator account.
- Implement application whitelisting/control to restrict which processes can execute on engineering workstations.
- Educate engineering staff about phishing risks involving design file pretexts — they are the last line of defense against social engineering.
- Maintain a comprehensive patch management program for all engineering software, including open-source tools.
- Consider security-focused fuzzing of KiCad's file parsers to identify and report other potential vulnerabilities before they are discovered by threat actors.
References
- NVD Entry — https://nvd.nist.gov/vuln/detail/CVE-2022-23947
- KiCad Official Website — https://www.kicad.org (check for security advisories and release announcements)
- Debian Security Tracker — https://security-tracker.debian.org/tracker/CVE-2022-23947
- KiCad GitHub Repository — https://github.com/KiCad/kicad-source-mirror (monitor for fix commits referencing DCodeNumber parsing)
- CISA Known Exploited Vulnerabilities Catalog — https://www.cisa.gov/known-exploited-vulnerabilities-catalog (CVE-2022-23947 NOT listed, indicating no confirmed exploitation in the wild as of the catalog's publication)
Threat Actor/Campaign Evidence: No known threat actor campaigns, exploits-in-the-wild, or active exploitation have been publicly documented for CVE-2022-23947 at the time of this report. The EPSS score of 0.01460 indicates a moderate likelihood of exploitation attempts, and the vulnerability class (stack-based buffer overflow in file parsing) is commonly targeted by both crimeware and APT actors due to the ease of file-based delivery and the prevalence of gerber files in cross-organization communication. Organizations in the electronics supply chain should treat this as a realistic threat vector and apply mitigations accordingly.
What is this? Security researchers use these exact search queries on Shodan.io (a search engine for internet-connected devices) to find vulnerable systems globally. You can copy these dorks to see if your organization's IP space is exposed.