GHSA-c5c6-37vq-pjcq baserCMS Path Traversal Leads to Arbitrary File Write and RCE via Theme File API
SummaryA path traversal vulnerability exists in the baserCMS 5.x theme file management API (`/baser/api/admin/bc-theme-file/theme_files/add.json`) that allows arbitrary file write.An authenticated administrator can include `../` sequences in the `path` parameter to create a PHP file in an arbitrary directory outside the theme directory, which may result in remote code execution (RCE).Affected Code**File**: `plugins/bc-theme-file/src/Service/BcThemeFileService.php`Attack ScenarioThe attacker compromises an administrator account (password leak, brute force, etc.)Obtains an access token via API loginSpecifies `path: "../../../../webroot/"` in the theme file creation APIA PHP file is created in the webrootThe attacker accesses the created PHP file to achieve RCEReproduction StepsVulnerability Details| Item | Details |
|------|---------|
| CWE | CWE-22: Path Traversal, CWE-73: External Control of File Name or Path |
| Impact | Arbitrary file write, Remote Code Execution (RCE) |
| Attack Prerequisites | Administrator privileges + API enabled (`USE_CORE_ADMIN_API=true`), or chaining with XSS, etc. |
| Reproducibility | High (PoC verified) |
| Test Environment | baserCMS 5.x (Docker environment) |Additional Notes on Attack Prerequisites**When API is enabled** (`USE_CORE_ADMIN_API=true`): API calls can be made externally using JWT token authentication. Direct exploitation is possible.**Default settings** (`USE_CORE_ADMIN_API=false`): Direct external API calls are prohibited. CSRF protection is also active, so this vulnerability alone cannot be exploited. An exploit chain involving XSS or similar is required.Recommended FixRather than relying on simple string replacement or blacklist checks of input, the canonicalized path (using `realpath()`, etc.) should be verified to be within the theme base directory after file creation or immediately before writing. If the path falls outside the boundary, the operation should be rejected.The specific implementation location and method are left to the project's design decisions.Comparison with Other CMSWordPress's theme editor only allows editing within `wp-content/themes/` and does not permit writes outside that directory. [CVE-2019-8943](https://www.sonarsource.com/blog/wordpress-image-remote-code-execution/) was reported as a path traversal vulnerability in `wp_crop_image()` that allowed writing cropped image output to an arbitrary directory by including `../` in the filename.This vulnerability is not a matter of "administrators being able to execute arbitrary code" by design, but rather stems from a security boundary violation where "the theme editing function can write outside the theme directory (to webroot, config, etc.)."ResourcesOWASP Path Traversal: <https://owasp.org/www-community/attacks/Path_Traversal>WordPress RCE via Path Traversal (CVE-2019-8943): <https://www.sonarsource.com/blog/wordpress-image-remote-code-execution/>Jira Path Traversal (CVE-2025-22167): <https://nvd.nist.gov/vuln/detail/CVE-2025-22167>This advisory was translated from Japanese to English using GitHub Copilot.
CVSS v3.1 score: 7.2