Summary
Ghidra versions before 12.0.4 contain a path traversal flaw in the theme import feature that trusts file paths inside user-supplied ZIP archives.
By crafting a malicious theme package with directory traversal sequences, an attacker may write files outside the theme directory, potentially enabling code execution or tampering with sensitive user configuration files.
Affected context
This vulnerability manifests when Ghidra processes theme ZIP archives provided by users and extracts their contents to the local filesystem.
It is relevant in environments where users can import untrusted or third-party themes and where Ghidra runs with access to user home directories or other sensitive paths.
The risk increases when Ghidra is executed with elevated privileges or in shared workstations where multiple users may interact with the same account or configuration.
Exploit preconditions
- Attack surface: Ghidra theme import functionality (ZIP theme file parsing and extraction).
- Required access: Ability to supply or trick a user into importing a crafted theme ZIP (local file or downloaded package).
- Trigger point: User initiates a theme import, causing Ghidra to extract ZIP contents.
- Why exploitation is possible: The extraction logic does not adequately normalize and validate archive entry paths, allowing traversal sequences (e.g.,
../) to direct file writes outside the intended theme directory.
Why this happens
The underlying issue is an improper restriction of the target path for files extracted from user-controlled ZIP archives.
The theme import code trusts embedded file paths and fails to canonicalize and validate them against an allowed base directory before writing to disk.
This aligns with CWE-22: Improper Limitation of a Pathname to a Restricted Directory, where user-supplied path components can escape a designated directory and affect unintended files or locations.
Potential impact
- Overwriting user configuration files such as shell startup scripts (e.g.,
.bashrc) that may lead to code execution on next login or shell spawn. - Modifying SSH configuration files (e.g.,
.ssh/authorized_keys) to add attacker-controlled keys and enable unauthorized remote access. - Planting or modifying scripts and binaries in user-writable paths that are later executed in the normal course of operations.
- Corrupting Ghidra configuration or theme data, potentially causing application instability or influencing analysis behavior.
- Tampering with log files or other local data to hide malicious activity or mislead incident investigations.
General mitigation guidance
Effective mitigation is centered around strict path handling and reducing the trust boundary of imported artifacts.
Common defensive patterns include:
- Canonicalizing each archive entry path and verifying that it resides within the intended theme directory before extracting.
- Rejecting any archive entry that contains traversal sequences, absolute paths, or path prefixes that resolve outside the designated directory.
- Using high-level file extraction utilities or libraries that support secure extraction modes with enforced base directories.
- Running Ghidra under a user account with the minimum necessary filesystem privileges and avoiding execution with elevated rights.
- Encouraging users to import themes only from trusted sources and treating theme packages as potentially executable content from a security perspective.
How teams detect issues like this
Organizations can approach detection by combining code-centric and system-centric techniques:
- Static analysis: Search for ZIP extraction routines that concatenate archive entry names with filesystem paths without canonicalization or base-path checks; flag use of naive directory creation and file writing in import utilities.
- Code review: Examine theme or plugin import code paths for validation of file names, rejection of
..segments, absolute paths, and unusual path prefixes; ensure strict comparison against a whitelisted base directory. - Runtime monitoring: Observe filesystem activity for unexpected writes triggered by Ghidra in locations outside its configuration or theme directories, especially following theme imports.
- Policy enforcement: Establish secure coding guidelines for resource extraction and integrate automated checks (e.g., SAST tools, custom linters) into CI pipelines to catch future path traversal patterns early.

