Ghidra — Swift Demangler Arbitrary Code Execution via Shared Project Files (CVE-2026-18718)
Published: 2026-08-09 • Researcher: sn0x-sharma (@sn0x-sharma)
- Severity
- High
- CVE
- CVE-2026-18718
- Category
- misc
- Affected product
- Ghidra (NSA reverse engineering framework), Swift Demangler analyzer
- Affected versions
- Ghidra ≤ 12.1.2
- Disclosed
- 2026-08-09
- Patch status
- Patched
Tags
References
- https://github.com/NationalSecurityAgency/ghidra/security/advisories/GHSA-pcfh-853f-q3gh
- https://github.com/NationalSecurityAgency/ghidra/commit/c03a70d
- https://nvd.nist.gov/vuln/detail/CVE-2026-18718
- https://github.com/sn0x-sharma/CVE-2026-18718
- https://sn0xs-organization.gitbook.io/sn0x-order.org/bb-web-hunt/critical/how-i-found-a-0-day-in-ghidra-shared-project-file-became-a-code-execution-vector
- https://github.com/NationalSecurityAgency/ghidra/security/policy
Archive entry
intelseclab/poc-archiveOn this page
Metadata
| Field | Value |
|---|---|
| Date Added | 2026-08-09 |
| Last Updated | 2026-08-09 |
| Author / Researcher | sn0x-sharma (@sn0x-sharma) |
| CVE / Advisory | CVE-2026-18718 |
| Category | misc |
| Severity | High |
| CVSS Score | 7.5 (CVSSv3.1: AV:L/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:H) |
| Status | Patched |
| Tags | ghidra, nsa, reverse-engineering, swift, demangler, code-execution, project-file, analyzer, CWE-427, CWE-494, uncontrolled-search-path, supply-chain, research-tool, shared-project |
| Related | Thematically related to pocs/binary/2026-05-23_cve-2026-22681-chocopoc-ida-pro-theme-rce/ (ChocoPoC): both exploit the trust reverse engineers place in project files from colleagues and the internet. Open a project, run their code — an entire class of researcher-targeting attacks. |
Affected Target
| Field | Value |
|---|---|
| Software / System | Ghidra (NSA reverse engineering framework), Swift Demangler analyzer |
| Versions Affected | Ghidra ≤ 12.1.2 |
| Language / Platform | Java (Ghidra), Swift (demangler); research PoC in Python 3 (stdlib only, self-contained) |
| Authentication Required | No — the attack is delivered through a shared project file (.gzf, project directory, or cloned research repository). The victim opens the file; Ghidra runs the attacker’s code. |
| Network Access Required | None — the execution is entirely local, triggered by opening a project or importing a binary into a shared project |
Summary
Opening someone else’s Ghidra project is enough to execute their code — with no prompt, no signature check, and no integrity verification.
Ghidra 12.1.2 stores analyzer options inside the program database, and one of those options is a configurable filesystem path to a Swift toolchain directory. When the Swift Demangler analyzer runs, Ghidra resolves swift-demangle under that attacker-controlled path and executes it — twice: once with --version (a validation probe that fires during analyzer initialization) and once with each mangled symbol. The first execution happens before the user sees any analysis results, before any dialog, and with the same privileges as the Ghidra process.
A shared .gzf archive, a cloned research repository containing a .gar file, or a project directory passed between colleagues silently carries the attacker’s chosen path with it. The victim opens the project, the analyzer reads the stored option, resolves the binary, and executes it. On headless and CI setups — where Ghidra runs automated analysis with no human in the loop — there is no opportunity to notice.
The advisory was reported privately via GitHub Security Advisory (GHSA-pcfh-853f-q3gh), initially assessed as working-as-intended, then re-triaged after the researcher demonstrated a silent project-import reproduction path. Ghidra 12.1.3 fixes the issue by dropping the configurable tool directory entirely and resolving swift from the system PATH only.
Vulnerability Details
Root Cause
The Swift Demangler analyzer (SwiftDemanglerAnalyzer.java) restores a SWIFT_TOOL_DIR_OPTION string from the program database — state that was saved when the project was last used, and which a project author fully controls:
| |
SwiftNativeDemangler joins the directory with the literal filename swift-demangle and executes the resulting path:
| |
SINK 1 is a validation probe that fires during analyzer initialization — the attacker’s code runs before a single symbol is demangled, before the analysis task shows progress, and with no user prompt at any point.
Attack Vector
- Create a Ghidra project with the Swift Demangler analyzer enabled and
SWIFT_TOOL_DIR_OPTIONset to a directory the attacker controls (or a relative path like../../tmp/evilthat resolves on the victim’s machine). - Share the project — as a
.gzfarchive, a project directory, or a research repository containing program databases. - The victim opens the project. Ghidra restores the analyzer options from the saved program state, resolves
swift-demangleunder the attacker’s path, and executes it — no signature check, no integrity verification, no prompt. - On headless/CI, the same path triggers during automated analysis with nobody watching.
The PoC research framework also documents two related code-execution surfaces discovered during the same review — TraceRMI debugger-agent command injection and SevenZipJBinding native parser reachability — each with its own preconditions and risk level.
Impact
Arbitrary code execution in the Ghidra user’s context — typically the analyst’s own user account, with access to all files, network resources, and credentials available to that user. For reverse engineers analyzing malware, this is a particularly dangerous vector: the tool meant to keep them safe becomes the attack surface. On headless/CI pipelines, the impact extends to build artifacts, signed releases, and the integrity of the analysis pipeline itself.
Environment / Lab Setup
The research PoC is self-contained and does not require a Ghidra installation for the swift mode (the accepted advisory). It fabricates its own fake Swift toolchain and simulates the exact execution path Ghidra takes.
| |
Setup Steps
| |
Proof of Concept
See
CVE-2026-18718-POC.py(~1,100 lines),source-evidence.md, andLICENSEin this folder — mirrored byte-for-byte from sn0x-sharma/CVE-2026-18718. The upstream README is preserved asupstream-README.md.
Step-by-Step Reproduction
Run the Swift ACE mode (self-contained, no Ghidra needed):
Shell script1python3 CVE-2026-18718-POC.py --mode swift --execute --launch-calcVerify execution — the framework creates a fake
swift-demanglebinary, launches it with--version(exactly as Ghidra would at SINK 1), and records a marker file:Output10:15:09 | INFO | swift-ace: launching fake demangler as Ghidra would Swift demangler calc PoC (sn0x-sharma) 10:15:09 | INFO | [PASS ] swift-ace: Swift demangler sink reproduced; attacker binary executed. 10:15:09 | INFO | - Execution marker: artifacts/swift-demangler-calc/swift_demangler_calc_marker.txtCheck the marker proving the attacker binary ran:
Shell script1 2cat artifacts/swift-demangler-calc/swift_demangler_calc_marker.txt # ran with: --version
Exploit Code
The research framework is a single-file, class-structured Python entrypoint. Each reviewed surface is a separate component returning structured results:
CVE-2026-18718-POC.py
├── PlatformProfile OS-specific behaviour (calc command, chmod)
├── ResearchConfig run configuration + Ghidra-source resolver
├── SourceScanner read-only substring scanner over a Ghidra tree
├── EvidenceCollector owns artifacts/, records every file written
├── ResearchComponent base contract for a reviewed surface
│ ├── SwiftAnalyzer swift-ace — conditional ACE (self-contained)
│ ├── TraceManager tracermi-rce — conditional RCE evidence
│ └── SevenZipProbe sevenzip-reachability — parser reachability
├── EnvironmentValidator pre-flight checks
├── ReportGenerator deterministic summary
└── ResearchRunner orchestration: validate → run → report → exit codeThe Swift analyzer constructs a fake toolchain directory, writes a platform-appropriate swift-demangle binary that records its invocation arguments, and simulates the exact ProcessBuilder calls Ghidra makes.
Expected Output
10:15:09 | INFO | swift-ace: launching fake demangler as Ghidra would
Swift demangler calc PoC (sn0x-sharma)
10:15:09 | INFO | [PASS ] swift-ace: Swift demangler sink reproduced; attacker binary executed.
10:15:09 | INFO | - Execution marker: artifacts/swift-demangler-calc/swift_demangler_calc_marker.txtDetection and Indicators of Compromise
Remediation
| Action | Detail |
|---|---|
| Patch | Upgrade to Ghidra 12.1.3 or later. Commit c03a70d drops the configurable SWIFT_TOOL_DIR_OPTION and resolves swift from the system PATH only. The stored option is ignored even if a malicious project carries it. |
| Workaround | On unpatched versions: disable the Swift Demangler analyzer before opening projects you did not create. Check Analysis → Auto Analyze → Analyzers on every imported project. Do not open .gzf archives or project directories from untrusted sources. |
| Verification | Confirm the Ghidra version is 12.1.3 or later; verify that SwiftNativeDemangler.java resolves swift via findOnPath() rather than constructing a File(swiftToolDir, "swift-demangle"). |
References
Notes
Verified this session by reading the full research framework source (CVE-2026-18718-POC.py, ~1,100 lines). The tool is a single-file Python entrypoint with no third-party dependencies. It is structured as an auditable research framework — each of the three reviewed surfaces is a separate class, the orchestration is explicit, and the output is deterministic. The swift mode is fully self-contained (fabricates its own fake toolchain); the tracermi and sevenzip modes optionally reference a Ghidra source tree for source-to-sink annotation.
Malware screen — clean. No obfuscated payloads, no remote downloaders, no credential exfiltration, no miner, no setup.py/install-time side effects. Every process launch is opt-in behind --execute; the calculator is behind --launch-calc. The fake swift-demangle binary records its invocation arguments to a marker file — it performs no network activity, no filesystem modification beyond the artifacts directory, and no privilege escalation. The sevenzip mode can emit a benign ZIP archive for testing (--harmless-zip), and the tracermi mode writes calc-only payload shapes (Java Runtime.exec() opening the platform calculator) — neither mode performs any actual exploitation.
Author track record: sn0x-sharma reported the vulnerability responsibly through GitHub Security Advisory (GHSA-pcfh-853f-q3gh). The advisory was initially assessed as working-as-intended, then re-triaged and accepted after the researcher demonstrated a silent project-import reproduction path. The fix was committed as c03a70d and released in Ghidra 12.1.3. CVE-2026-18718 was assigned in week 7 of the disclosure timeline. The researcher published this framework after coordinated disclosure against a patched version.
Thematic pairing: This entry and ChocoPoC (CVE-2026-22681, IDA Pro theme RCE, already in this archive) form a pair — both exploit the trust reverse engineers place in project files, themes, and configurations shared by colleagues and the internet. Open a project, run their code. The attack surface is the tool itself.
| |