Summary
A path traversal flaw in baserCMS's theme file management API allows authenticated administrators to write files outside the intended theme directory by abusing directory traversal sequences in request parameters.
When exploited, this can be used to create malicious PHP files in arbitrary locations on the server, potentially leading to remote code execution under the web server's privileges.
Affected context
The vulnerability appears in baserCMS deployments that expose the admin theme file management API endpoint at /baser/api/admin/bc-theme-file/theme_files/add.json.
It manifests when the application accepts file path input from authenticated administrators and constructs filesystem paths by concatenating the user-supplied value with a theme directory base path, without normalizing or restricting traversal components.
The issue is relevant in environments where PHP files created by the CMS or its APIs are interpreted by the web server and can be accessed over HTTP.
Exploit preconditions
- Attack surface: HTTP(S) requests to the admin theme file management API (
theme_files/add.json). - Required access: Valid authenticated administrator-level access to baserCMS (or compromise of such an account).
- Trigger point: Submission of a request containing
../-style path traversal sequences in the path parameter, causing file creation outside the intended theme directory. - Why exploitation is possible: The server-side logic trusts the supplied path parameter and concatenates it into filesystem paths without canonicalization or enforcement of a strict root directory, enabling arbitrary file write where the web server has permission.
Why this happens
At its core, this is a path traversal (CWE-22) combined with improper control of file system paths (CWE-73).
The API endpoint responsible for theme file creation takes a directory or file path parameter and uses it directly to build a filesystem path.
Without normalization, validation, or restriction to a known root, ../ segments allow escaping the theme directory and writing files elsewhere.
Because the API supports creating PHP files as part of theme management, placing such a file in a web-accessible location lets an attacker execute arbitrary code when the file is requested, turning a path traversal into authenticated remote code execution.
Potential impact
- Creation of arbitrary PHP files that can be executed by accessing them via the web server.
- Execution of arbitrary PHP code with the privileges of the web server process.
- Installation of web shells or backdoors for persistent access.
- Defacement or modification of website content by altering core or theme files.
- Lateral movement within the hosting environment if the web server account has access to additional resources.
- Exposure or manipulation of sensitive data stored or processed by the application.
General mitigation guidance
Effective mitigation typically focuses on strict path handling and separation of code and content:
- Normalize and canonicalize any user-supplied path components before use, rejecting paths that resolve outside an approved base directory.
- Enforce whitelisting of allowable directories and file types in file management APIs, particularly prohibiting executable file extensions (e.g.,
.php) from being created via web interfaces wherever possible. - Use dedicated storage locations for user- or admin-created files that are not treated as executable code by the web server (e.g., storing in non-PHP-executing directories or separate storage buckets).
- Apply rigorous authorization and logging for file management operations, reviewing abnormal directory targets or file types.
- Run the web server and application with least-privilege filesystem permissions so that even if a path check fails, write access is limited.
How teams detect issues like this
Detection generally combines code-level analysis with runtime monitoring:
- Static analysis and manual review can look for file operations that concatenate user-supplied path parameters with base directories without canonicalization and boundary checks.
- Code review checklists can include specific items for verifying that file management APIs validate directory traversal and enforce root directory constraints.
- Application logs can be monitored for file creation requests containing
../sequences or unusual directory targets, especially when associated with admin sessions. - File integrity monitoring on web-executable directories can flag unexpected new PHP files or changes to existing code files.
- Security testing pipelines and DAST tools can probe file upload and file creation endpoints for traversal behavior using benign test payloads.

