/

CVE-2025-32957

Severity:

HIGH RISK

(8.7)

Unrestricted File Upload in baserCMS Restore Function

CVE-2025-32957

Analyzed

Vulnerability type

Category:

Unrestricted File Upload

CWE:

CWE-434

Impact:

Remote Code Execution

Severity:

HIGH RISK

(8.7)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

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_once on 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, or include_once where 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.

Sources

SourceLink
basercms.netbasercms.net/security/JVN_20837860
github.comgithub.com/baserproject/basercms/releases/tag/5.2.3
github.comgithub.com/baserproject/basercms/security/advisories/GHSA-hv78-cwp4-8r7r

Frequently asked

questions

Yes, if an attacker can reach the restore endpoint and successfully upload a ZIP archive, they can potentially trigger remote code execution through a crafted PHP file.

Typically, the attacker must be able to use the backup restore function, which is often restricted to administrative or highly privileged users. However, misconfigurations, weak credentials, or compromised admin accounts can widen this access.

The safest pattern is to ensure that restore archives are treated purely as data: disallow executable content in uploaded backups, avoid including PHP files from uploads, and ensure extracted files are placed in non-executable locations with strict allowlisting of expected structures.

Design file upload and restore features with the assumption that all external inputs are untrusted. Enforce strong validation and allowlists for filenames and types, avoid dynamic inclusion or execution of user-supplied files, isolate upload directories from the webroot, and incorporate static analysis and security review into the development lifecycle for file handling code.

Find out what's already
exploitable in your codebase.