Summary
PrestaShop's back-office theme and module archive imports may allow authenticated employees to write files outside their intended directories. If an attacker can submit a crafted theme configuration or module archive, files may be placed in web-accessible locations and PHP files could be executed.
Affected context
The issue occurs in back-office theme and module archive import workflows. It may be present when theme names from config/theme.yml influence file paths, or when module archives are extracted before their contents are validated. Successful exploitation depends on the import process allowing files to escape the intended destination and, for code execution, on the written PHP file being accessible and executable by the web server.
Exploit preconditions
- Attack surface: Back-office theme or module archive import functionality
- Required access: Authentication as an employee with permission to use the relevant import feature
- Trigger point: Processing a crafted theme configuration or uploaded module archive
- Why exploitation is possible: Path components may be accepted or archive contents extracted before destination paths and files are adequately validated
Why this happens
The underlying issue is insufficient control over paths derived from theme metadata or archive entries. When those paths are used for file writes without reliably constraining the resolved destination to an approved directory, traversal outside that directory may be possible. This maps to CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
Potential impact
- An attacker may write or overwrite files outside the intended import directory.
- PHP files placed in web-accessible locations could enable code execution under the web server's privileges.
- Application files or data could be modified, potentially affecting site integrity or availability.
General mitigation guidance
Defensive approaches generally focus on constraining all import writes to explicitly approved locations and validating paths before any extraction or file operation.
Common patterns include:
- Canonicalizing resolved paths and verifying they remain within the intended destination.
- Rejecting traversal components and unsafe path forms in theme metadata and archive entries.
- Validating archive contents before extraction, and extracting into isolated temporary locations.
- Avoiding executable permissions or web access for imported files where they are not required.
- Limiting import permissions and running file-processing components with least privilege.
- Applying resource and file-system boundaries to reduce the impact of mistakes.
How teams detect issues like this
High-level detection approaches include:
- Static analysis for file operations using untrusted path components without canonicalization and destination-boundary checks.
- Code review of archive extraction order, theme-name handling, and validation performed before writes.
- Tests and security policies that reject archive entries resolving outside approved import directories.
- Monitoring import activity and file-system changes in web-accessible locations for unexpected files.

