Summary
Mautic 7's campaign import feature contains a path traversal flaw in its ZIP extraction logic that allows uploaded archive contents to escape the intended temporary directories.
An authenticated user with campaign import privileges can leverage this to write arbitrary PHP files into sensitive application paths, potentially achieving remote code execution under the web server user's privileges.
Affected context
This issue arises in Mautic 7 instances that enable campaign imports and process user-supplied ZIP archives on the server side.
The vulnerable code is part of the campaign import pipeline, where uploaded ZIP files are unpacked into temporary directories before being consumed by the application.
The problem appears when file paths from the ZIP entries are insufficiently normalized and validated, allowing traversal outside the intended temporary folder when the archive is extracted.
Any deployment where authenticated users can access the campaign:imports:create permission and upload ZIP files is potentially exposed, especially if the web server user can write to application or cache directories.
Exploit preconditions
- Attack surface: HTTP(s) interface for Mautic 7's campaign import functionality.
- Required access: Authenticated account with the
campaign:imports:createprivilege or equivalent access to the campaign import feature. - User-controlled input: A crafted ZIP archive whose internal file paths include traversal sequences (for example, directory climbing patterns) targeting sensitive directories.
- Trigger point: The server-side ZIP extraction routine invoked during campaign import, which writes ZIP contents to the filesystem.
- Why exploitation is possible: The extraction logic does not correctly canonicalize and validate archive entry paths against the intended base directory, allowing paths that resolve outside the temporary folder and into application-controlled locations (e.g., web-accessible directories or PHP-included paths). Because the application accepts and writes these paths, an attacker can plant or overwrite PHP files and later trigger their execution.
Why this happens
The root cause is improper handling of file paths during archive extraction, mapping to CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') and CWE-73: External Control of File Name or Path.
The implementation trusts the file names and directory structures embedded in the uploaded ZIP file and concatenates these paths with a base directory without robust normalization, canonicalization, and boundary checks.
This allows traversal sequences to escape the intended temporary folder and write files anywhere the web server user has permissions.
Combined with Mautic's use of PHP files within the application and cache layers, this path traversal becomes an arbitrary PHP file write scenario, aligning with CWE-98: Improper Control of Filename for Include/Require Statement in PHP Program once a written file is loaded or executed by the runtime.
Potential impact
- Arbitrary PHP file creation or modification in web-accessible or autoloaded directories.
- Remote Code Execution under the privileges of the web server user.
- Overwriting of critical configuration files, potentially altering authentication, routing, or plugin behavior.
- Corruption or poisoning of cache or temporary components to change application logic flow.
- Escalation from a limited campaign import role to full compromise of the Mautic instance.
- Lateral movement within the hosting environment if other applications share the same filesystem or user context.
General mitigation guidance
Effective mitigation focuses on robust path handling and minimizing the impact of any file writes that do occur:
- Enforce strict path normalization: Before writing files from an archive, normalize the target path (e.g., using canonical path resolution) and reject any entry that resolves outside a predefined safe base directory.
- Deny traversal patterns by design: Implement positive validation on archive entry names (e.g., only allow relative paths without parent directory components and without absolute path prefixes) instead of attempting to strip traversal sequences.
- Restrict write locations: Limit extraction and import operations to dedicated directories that are not web-accessible and are not part of the application's executable or configuration paths.
- Disallow executable content in imports: Treat campaign import data as content only; avoid loading or executing any imported files as PHP or dynamic code.
- Apply least privilege to the web server user: Configure the web server user so it cannot write to application source, configuration, or other sensitive directories, even if the code attempts to do so.
- Harden deployment configuration: Where possible, serve the Mautic codebase from read-only mounts, and separate writable upload/cache directories from code and configuration trees.
How teams detect issues like this
Organizations can use a combination of code-based and operational detection techniques:
- Static analysis and code scanning:
- Flag uses of ZIP or archive extraction APIs where entry names are directly concatenated with filesystem paths.
- Look for patterns lacking canonical path checks or comparisons against a restricted base directory.
- Detect any logic that writes files under web root or PHP include paths based on user-controlled inputs.
- Code review practices:
- Examine all import and upload pathways that unpack archives or handle file system writes.
- Verify that path normalization and boundary checks are present and enforce a single, well-defined extraction root.
- Review whether imported paths can intersect with directories that contain executable or configuration files.
- Runtime and log monitoring:
- Monitor for unexpected file creations or modifications in application and cache directories, especially around campaign imports.
- Enable auditing or file integrity monitoring on code, configuration, and plugin directories to detect anomalous writes.
- Security testing and CI/CD controls:
- Incorporate dynamic tests that attempt to import archives with traversal entries as part of security regression testing.
- Integrate automated tools into CI pipelines to catch insecure archive extraction patterns and path handling issues.

