Summary
Ghidra before 12.0.3 improperly treats annotation directives embedded in automatically extracted binary data as trusted input, allowing attacker-controlled @execute annotations to be rendered as active UI elements.
When an analyst clicks these apparently benign auto-generated comments (for example, in CFStrings from Mach-O binaries), Ghidra may execute arbitrary commands on the analyst's machine, turning routine reverse-engineering activity into a potential code execution vector.
Affected context
This vulnerability affects environments where Ghidra is used to analyze untrusted or potentially malicious binaries, particularly formats where auto-analysis generates comments from embedded strings (such as CFStrings in Mach-O files).
The @execute annotation mechanism, designed for trusted user-authored comments, is also applied to comments originating from binary content, causing data extracted from the sample to be interpreted as active, clickable commands in the UI.
The issue surfaces during normal analyst interaction with the disassembly or decompiler views when clicking on these annotated comments.
Exploit preconditions
- Attack surface: Ghidra desktop application UI, primarily within disassembly/decompiler panes and auto-generated comments.
- Required access: Ability to supply a crafted binary to a Ghidra analyst (e.g., via malware samples, shared files, or repositories).
- User interaction: The analyst must open the malicious sample in Ghidra and click on the auto-generated comment or annotation containing the @execute directive.
- Trigger point: Ghidra's auto-analysis pipeline extracts binary data (e.g., strings) into comments; the UI then parses and treats @execute annotations within those comments as actionable.
- Why exploitation is possible: The annotation parsing logic does not distinguish between trusted, user-authored comments and comments derived from untrusted binary data, allowing attacker-controlled content to inherit command-execution semantics.
Why this happens
The core issue is a failure to enforce a proper trust boundary between data derived from untrusted binaries and the privileged annotation features intended for trusted user input.
Ghidra's annotation system interprets the @execute directive embedded in comments as instructions to run commands on the host, but the same parsing logic is applied to comments generated from automatically extracted binary content.
This aligns with CWE-78: Improper Neutralization of Special Elements used in an OS Command, as attacker-controlled text from the binary is effectively promoted into an OS command context without appropriate neutralization, filtering, or separation of trusted versus untrusted sources.
Potential impact
- Execution of attacker-controlled commands on the analyst's workstation.
- Installation of malware or backdoors within the analysis environment.
- Exfiltration or tampering of sensitive analysis artifacts, such as projects, scripts, or proprietary samples.
- Lateral movement from the analyst's machine into broader internal networks.
- Undermining trust in analysis results, including potential manipulation of investigation outcomes.
General mitigation guidance
Resilient mitigations focus on separating trusted annotations from untrusted data and reducing the privileges of any command-execution mechanisms:
- Treat all content derived from binaries (e.g., strings, auto-generated comments) as untrusted and exclude it from annotation or command-execution parsing.
- Restrict or disable @execute-like features by default, especially in environments that routinely handle untrusted input.
- Introduce explicit trust elevation steps for any annotation that can trigger commands, such as requiring manual creation or confirmation before it becomes executable.
- Constrain execution contexts (for example, sandboxing or least-privilege execution) for any mechanism that can launch host commands, so that even if misused, impact is limited.
- Apply consistent input-neutralization and encoding rules to any data that moves from binary content into UI components that can affect system state.
How teams detect issues like this
Detection approaches can focus on both source-level patterns and runtime behavior:
- Code review: Examine the annotation parsing and command-dispatch paths to confirm that only explicitly trusted sources can introduce @execute or similar directives; look for flows where comment strings from binary analysis feed into annotation handlers.
- Static analysis: Define rules or queries to flag instances where UI text or comments derived from untrusted input are passed into command execution APIs or annotation interpreters without clear validation or trust checks.
- Configuration and policy checks: Periodically validate that high-risk features like command-executing annotations are disabled or tightly constrained in standard analyst configurations.
- Runtime monitoring: On hardened analysis workstations, use host-based monitoring to profile and alert on unexpected child processes spawned from Ghidra, especially in response to UI interactions with comments or annotations.

