Summary
baserCMS's backup restore feature accepts a user-supplied ZIP archive and automatically extracts its contents, then includes a PHP file using require_once without properly validating the filename or path.
An attacker who uploads a crafted ZIP archive containing malicious PHP code can have that code executed on the server when the restore process includes the file.
Affected context
This vulnerability occurs in the backup/restore functionality of baserCMS where administrators can upload ZIP archives to restore application data or configurations.
The risk is most pronounced in deployments where:
- The restore endpoint is reachable from untrusted networks
- Authentication and role-based access controls around restore operations are weak or misconfigured
- Uploaded archives are extracted into a location accessible by the PHP interpreter
Under these conditions, the restore flow may end up including an attacker-controlled PHP file without sufficient validation.
Exploit preconditions
- Attack surface: HTTP(S) endpoint exposing the baserCMS restore feature that accepts ZIP uploads.
- Required access: Ability to authenticate or otherwise reach and use the restore functionality (e.g., compromised admin credentials, lateral movement, or misconfigured access controls).
- Trigger point: Submission of a ZIP archive containing a crafted PHP file that will be included during the restore process.
- Why exploitation is possible: The restore logic both:
- Automatically extracts attacker-controlled ZIP contents, and
- Uses
require_onceon a PHP file from the archive without robust checks on filename, path, or file type.
Why this happens
The core issue aligns with CWE-434: Unrestricted Upload of File with Dangerous Type.
The restore mechanism implicitly trusts ZIP contents as benign backup data and does not enforce strict constraints on:
- Which files are extracted and where they are placed
- Which PHP files may be included and executed
By calling require_once on a PHP file taken from the uploaded archive without validating its origin, extension, path, or contents, the application allows attackers to smuggle executable code through a nominally benign backup file.
This pattern mixes data and code, treating externally supplied files as executable logic, which is an unsafe design.
Potential impact
- Execution of arbitrary PHP code in the context of the web server process
- Full compromise of the baserCMS instance and underlying application data
- Installation of webshells or backdoors for persistent access
- Modification or exfiltration of database contents and configuration secrets
- Use of the compromised server as a pivot for broader network attacks
General mitigation guidance
Addressing this class of issue generally involves strictly controlling file uploads and subsequent file handling:
- Restrict restore operations to trusted administrators and isolate the restore interface from public networks where possible.
- Validate uploaded archives rigorously, allowing only expected file types and structures within the ZIP.
- Avoid including or executing any PHP files from uploaded archives; treat backup contents as data, not code.
- If inclusion of PHP files is unavoidable, perform strict allowlisting:
- Predetermine acceptable filenames and paths
- Reject any file with unexpected extensions or directory traversal patterns
- Extract uploaded archives into directories that are:
- Not in the webroot
- Not executable or interpretable by the PHP engine
- Apply least-privilege permissions to the web server user and filesystem to minimize damage from a compromise.
How teams detect issues like this
Detection efforts can focus on both code-level patterns and runtime behavior:
- Static analysis / code review:
- Flag any use of
require,require_once,include, orinclude_oncewhere the target path is derived from user input or uploaded file names. - Review backup/restore and import/export paths for automatic extraction of archives and dynamic inclusion of PHP files.
- Identify file upload handlers that do not enforce extension allowlists or MIME-type checks.
- Configuration and policy checks:
- Enforce policies that backups and restore files must not contain executable code.
- Use CI/CD hooks or automated code review tools to detect new uses of dynamic file inclusion tied to external input.
- Runtime monitoring:
- Monitor web server logs for unusual calls to backup/restore endpoints.
- Alert on execution of PHP files from temporary or upload directories.

