GHSA-qxmc-6f24-g86g baserCMS has OS Command Injection Leading to Remote Code Execution (RCE)
SummaryIn the core update functionality of baserCMS, some parameters sent from the admin panel are passed to the `exec()` function without proper validation or escaping. This issue allows **an authenticated CMS administrator to execute arbitrary OS commands on the server (Remote Code Execution, RCE)**.This vulnerability is not a UI-level issue such as screen manipulation or lack of CSRF protection, but rather stems from **a design that directly executes input values received on the server side as OS commands**. Therefore, even if buttons are hidden in the UI, or even if CakePHP's CSRF/FormProtection (SecurityComponent) ensures that only legitimate POST requests are accepted, **an attack is possible as long as a request containing a valid token is processed within an administrator session**.Vulnerability Information| Item | Details |
| ---- | ------- |
| CWE | CWE-78: Improper Neutralization of Special Elements used in an OS Command |
| Impact | Remote Code Execution (RCE) |
| Severity | Critical |
| Attack Requirements | Administrator privileges required |
| Reproducibility | Reproducible (confirmed multiple times) |
| Test Environment | baserCMS 5.2.2 (Docker / development environment) |Affected Areas**Controller**`PluginsController::get_core_update()`**Service**`PluginsService::getCoreUpdate()`**Affected Endpoint**`/baser/admin/baser-core/plugins/get_core_update`Technical DetailsVulnerable Code FlowRelevant Code (Excerpt)**PluginsController.php****PluginsService.php**The `$php` parameter is user input, and **none** of the following countermeasures are in place:Restriction via allowlistValidation via regular expressionEscaping via `escapeshellarg()` or similarAttack ScenarioThe attacker logs in as a CMS administratorSends a POST request to the core update functionality in the admin panelSpecifies a string containing OS commands in the `php` parameter`exec()` is executed on the server side, running the arbitrary OS commandExample Attack Input (Conceptual)Verification Results (PoC)Execution ResultThe above confirms that OS commands can be executed with `www-data` privileges.Additional NotesReproducible through the legitimate flow in the admin panel (browser)Succeeds even with CSRF/FormProtection tokens included in a legitimate requestFailure cases (400/403) have also been investigated and differentiatedConfirmed reproducible via resending HTTP requests with tools such as curl (resending the same request containing valid tokens)ImpactIf this vulnerability is exploited, the following becomes possible:Retrieval of server informationReading/writing arbitrary filesRetrieval of application configuration information (DB credentials, etc.)OS-level operations beyond application permission boundariesAlthough administrator privileges are required, **this is a design issue where the impact extends from the application layer to the OS layer**, and the impact is considered significant.Recommended FixPrimary RecommendationDo not accept the PHP executable path from user inputFix the PHP executable on the server side using the `PHP_BINARY` constantSupplementary Fix RecommendationsApply `escapeshellarg()` escaping to other command-line arguments (version number, directory, etc.) as wellIf possible, consider using execution methods that do not involve shell interpretation (array format, Process class, etc.)Alternative (Not Recommended)Allowlist validation for the PHP executable pathCombined use of regex validation and `escapeshellarg()`However, **from the perspective of reducing the attack surface, a design that eliminates user input entirely is recommended**.Additional NotesThis issue is independent of UI display controls (showing/hiding buttons)As long as the endpoint exists, an attack is possible if a request containing valid tokens is processedThis is a problem stemming from the design-level handling of input, and cannot be prevented by CSRF or UI controls aloneConclusionDue to a design issue in baserCMS's core update functionality where user input is passed to `exec()` without validation, **Remote Code Execution (RCE) is achievable with administrator privileges**. This vulnerability can be fixed through input validation and design review, and prompt remediation is recommended.This advisory was translated from Japanese to English using GitHub Copilot.
CVSS v3.1 score: 9.1