Summary
A path traversal flaw in the FacturaScripts plugin upload mechanism allows files inside ZIP archives to be extracted outside the intended plugins directory.
By crafting malicious paths within a plugin ZIP, an attacker can write arbitrary PHP files to web-accessible directories, potentially achieving remote code execution wherever the web server has write and execute permissions.
Affected context
The vulnerability exists in the plugin installation workflow of FacturaScripts, specifically in the Plugins::add() logic implemented in Plugins.php.
It affects deployments where administrators or users with plugin management rights can upload ZIP archives that are then extracted on the server.
The check performed by testZipFile() only verifies that the ZIP appears to contain a single top-level folder but does not sanitize or normalize the paths of files within that folder, allowing traversal sequences (../) to escape the plugins directory during extraction.
Exploit preconditions
- Attack surface: HTTP endpoint or administrative interface that accepts plugin ZIP uploads.
- Required access: Ability to upload a plugin ZIP (typically authenticated admin or any user role allowed to install or update plugins).
- Trigger point: Uploading and installing a specially crafted ZIP archive via the plugin installation feature.
- Why exploitation is possible: The extraction routine trusts the internal paths of ZIP entries after only a superficial root-folder check.
It does not normalize paths or reject traversal patterns like ../, so archive contents can be written to arbitrary locations under the web server's writeable directory tree.
Why this happens
The core issue is an insufficient validation of input (CWE-20) combined with unrestricted upload / write of files to the filesystem (CWE-434) during ZIP extraction.
The testZipFile() function attempts to ensure that the archive contains a single root directory by splitting entry names with explode() and checking that only one top-level folder exists.
However, it never validates or canonicalizes the full file paths of each entry before extraction.
As a result, file names such as ValidPluginName/../../shell.php pass the root-folder count check but, when extracted, the ../../ segments cause a path traversal outside the plugins directory.
This pattern corresponds to a classic "Zip Slip" vulnerability, where the archive extraction process fails to constrain the output path to a safe, predefined directory.
Potential impact
- Arbitrary file write anywhere under directories writable by the web server process.
- Overwriting existing application PHP files to inject malicious code.
- Uploading new web shells or backdoors, enabling remote code execution.
- Tampering with configuration files or logs, potentially aiding persistence or data exfiltration.
- Escalation from limited administrative access to full server compromise within the web stack's privilege boundary.
General mitigation guidance
Effective mitigation focuses on enforcing strict path safety and constraining archive extraction:
- Normalize and canonicalize each ZIP entry path before extraction, and reject any path that escapes the intended plugins directory (e.g., disallow
.., absolute paths, or drive prefixes). - Construct extraction targets by joining a trusted base directory with validated relative names and verify that the resulting canonical path still resides within that base.
- Enforce a whitelist of allowed file types and extensions for plugin contents and skip or reject unexpected executable types.
- Run the web server and application under dedicated, least-privilege accounts with minimal write permissions to reduce the blast radius of arbitrary file writes.
- Consider extracting archives to a temporary, non-web-accessible directory first, performing validation, and only then copying approved files into the plugins directory.
How teams detect issues like this
Detection can combine code-level analysis with runtime monitoring:
- Static analysis: Look for archive extraction routines that use ZIP/TAR libraries without subsequent path normalization checks or without rejecting
..segments, absolute paths, or unusual prefixes in entry names. - Code review signals: Any plugin or extension installer that writes files based on archive contents should be examined for:
- Direct use of entry names to build file paths.
- Lack of canonicalization and boundary checks against a fixed base directory.
- Absence of file type filtering or enforcement of a strict plugin structure.
- Runtime monitoring: Track unexpected file creations or modifications in web-root directories following plugin uploads or administrative actions.
- Policy enforcement: Integrate security gates in CI/CD to flag unsafe archive extraction patterns, and use automated scanning tools that specifically detect Zip Slip-style vulnerabilities.

