Summary
A path traversal vulnerability in Emlog's ZIP extraction logic allows archive entries containing directory traversal sequences (../) to be written outside the intended extraction directory.
An authenticated administrator who uploads a crafted plugin, template, or backup ZIP can overwrite arbitrary files on the server, including PHP files, which can lead to remote code execution.
Affected context
This vulnerability occurs in Emlog deployments that allow administrators to upload and import ZIP archives for plugins, templates, or backups.
The affected emUnZip() function uses the underlying ZIP library's extractTo() method without validating or normalizing the file names inside the archive.
When ZIP entries contain traversal patterns (such as ../), extracted files can end up outside the intended application directories and into other locations on the server's filesystem, depending on the web server's permissions and document root layout.
Exploit preconditions
- Attack surface: Web-based admin interfaces that accept ZIP uploads (e.g., plugin upload, theme/template upload, backup import).
- Required access: Valid authenticated administrative account or any role permitted to upload and import ZIP archives.
- Trigger point: Uploading a crafted ZIP archive and invoking the import/extraction operation so that emUnZip() processes the archive entries.
- Why exploitation is possible: The emUnZip() function passes archive contents directly to
$zip->extractTo($path)without checking for directory traversal sequences, absolute paths, or other unsafe file names. The filesystem honors these paths, enabling writes outside the intended extraction directory.
Why this happens
The root cause is unvalidated file path handling during ZIP extraction, corresponding to CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
Instead of normalizing and constraining each entry's path to a known-safe base directory, the implementation trusts the paths embedded within the ZIP file.
Attackers can embed entries like ../some/target.php or similar constructs, which the extraction API interprets literally, resulting in files being written outside the designated plugin/template/backup directory.
This insecure pattern emerges whenever server-side archive extraction relies on user-controlled metadata (file names inside ZIPs) without canonicalization, validation against a whitelist, or rejection of traversal constructs and absolute paths.
Potential impact
- Overwriting or creating arbitrary files within the web server's accessible filesystem.
- Deployment of PHP webshells or other malicious scripts, enabling remote code execution under the web server's privileges.
- Tampering with application configuration files, potentially altering authentication, routing, or security options.
- Destruction or corruption of site content, templates, or plugins by overwriting critical files.
- Lateral movement or further privilege escalation if sensitive scripts or cron jobs are modified.
General mitigation guidance
Effective mitigation focuses on constraining file extraction paths and treating archive metadata as untrusted input:
- Normalize and canonicalize each ZIP entry path before extraction and ensure it remains within a predefined base directory (e.g., using realpath-style checks and prefix validation).
- Explicitly reject archive entries that contain
.., absolute paths, drive letters, or special device paths. - Implement an allowlist of acceptable file extensions and directories for plugin/template/backup contents, skipping or blocking anything else.
- Extract files into a temporary directory first, validate the resulting structure, and only then move approved files into the live application directories.
- Run the web server and application with least-privilege filesystem permissions so that even if traversal occurs, the process cannot write to sensitive system locations.
- Consider disabling or tightly restricting ZIP-based uploads in high-risk environments, or gating them behind stronger operational controls and review.
How teams detect issues like this
Detection typically combines code-level analysis with operational monitoring:
- Static analysis: Search for calls to archive extraction APIs (e.g.,
$zip->extractTo()or similar) that operate on user-provided archives without per-entry path normalization and validation. Flag uses where entry names are trusted directly. - Code review signals: Look for file operations that:
- Trust file names from ZIP contents or other archive formats.
- Lack checks for
.., absolute paths, or symbolic links before writing. - Do not verify that resulting paths stay within an expected base directory.
- Runtime monitoring: Track unexpected file creations or modifications outside expected plugin/template/backup directories following admin upload actions.
- Policy enforcement: Introduce CI/CD checks or pre-merge security gates that require safe path handling patterns for any new file upload or extraction functionality. Automated SAST tools can help highlight archive extraction patterns and path traversal risks.

