CMSimple 5.15 - Remote Code Execution (RCE) (Authenticated)
# Exploit Title: CMSimple 5.15 - Remote Command Execution
# Date: 04/28/2024
# Exploit Author: Ahmet Ümit BAYRAM
# Vendor Homepage: https://www.cmsimple.org
# Software Link: https://www.cmsimple.org/downloads_cmsimple50/CMSimple_5-15.zip
# Version: latest
# Tested on: MacOS
# Log in to SimpleCMS.
# Go to Settings > CMS
# Append ",php" to the end of the Extensions_userfiles field and save it.
# Navigate to Files > Media
# Select and upload shell.php
# Your shell is ready: https://{url}/userfiles/media/shell.php CMSimple 5.15 — Authenticated Remote Code Execution (RCE): Analysis, Risks, and Mitigations
This article examines the authenticated Remote Code Execution (RCE) pattern discovered in CMSimple 5.15, explains the technical root causes at a high level, summarizes real-world impact scenarios, and provides defensive guidance for administrators, developers, and incident responders. The emphasis is on mitigation, detection, and secure configuration rather than exploitation details.
Background and high-level overview
CMSimple is a lightweight PHP-based content management system. In some deployments, an administrative configuration option controlling permitted file extensions for user uploads can be altered so that executable extensions (such as .php) become accepted. When an upload directory is both writable and capable of executing PHP, this creates an authenticated file upload → execution chain that can result in RCE.
Authenticated RCE differs from unauthenticated bugs in that an attacker needs some level of legitimate access (for example, an administrative user or credentials obtained by other means) to trigger the condition. This increases the importance of protecting credentials and hardening admin pathways.
Impact and risk scenarios
- Remote code execution on the webserver, allowing arbitrary command execution or PHP code execution.
- Data theft: exfiltration of database contents, configuration files, and credentials.
- Persistence and lateral movement: installation of backdoors, web shells, or pivoting to internal services.
- Site defacement, spam hosting, or use of resources for malicious operations (cryptomining, DDoS).
- Reputational damage and potential regulatory exposure if sensitive data is exposed.
Technical root causes (conceptual)
- Improper validation or enforcement of an “allowed extensions” setting — a configuration value can be set to permit executable extensions.
- Upload directory located under web root and served by the PHP interpreter, enabling server-side execution of uploaded files.
- Insufficient access controls around the configuration interface and lack of robust authorization checks.
- Insufficient server-side filename validation, canonicalization checks, and MIME-type enforcement.
Detection and indicators of compromise (IoCs)
For defenders, look for anomalies related to file uploads and execution:
- New or unexpected files with executable extensions in media/upload folders.
- Changes to administrative configuration fields controlling allowed upload extensions.
- Web server logs showing POST upload activity followed by immediate GET requests to the same uploaded filename.
- Outbound network connections from the web host to suspicious destinations, or cron jobs created by web processes.
- Unusual PHP errors or suspicious query parameters immediately after an upload.
Example defensive search (conceptual): search access logs for uploads to media directories and for requests to newly created files with executable extensions. Do not use this to probe third-party sites without authorization; limit to your own estate.
Mitigations and hardening (practical defensive measures)
Mitigation should be layered. Apply these controls together to significantly reduce risk.
- Patch and update: Upgrade CMSimple to a version where the issue is fixed. Check the vendor advisory and apply security updates promptly.
- Restrict allowed upload extensions: Enforce a strict whitelist of safe extensions (images, documents) in code and configuration. Avoid allowing server-side executable extensions.
- Disable execution in upload directories: Configure the webserver so files in upload folders are not processed by the PHP interpreter. This is one of the most effective mitigations.
- Harden file permissions: Ensure upload directories are writable only by the web server user and restrict execution bit where possible.
- Move uploads outside webroot: Store user-uploaded content in directories not directly served, and expose files through a controlled proxy or sanitized delivery mechanism.
- Server-side validation: Validate file content (MIME type and magic bytes), sanitize filenames, and enforce size limits on the server side — never rely solely on client-side checks.
- Access control: Use strong authentication for admin panels, multi-factor authentication (MFA) for privileged accounts, and role-based access control (RBAC).
- Monitoring and alerting: Monitor uploads and configuration changes, generate alerts for any change to extension whitelists or for new executable files in media directories.
- Web application firewall (WAF): Deploy WAF rules to detect and block suspicious upload patterns and attempts to access uploaded executable files.
Web server configuration examples (defensive)
The following examples show how to prevent PHP execution inside an upload/media directory. These are defensive configurations — use them in your own environment and adapt to your server version and testing regimen.
# Apache (.htaccess or site config) - disable PHP execution in a directory
php_flag engine off
Require all denied
# Ensure directory listings are off
Options -Indexes
Explanation: The Apache snippet disables the PHP engine for requests in that directory (if mod_php is in use) and denies direct access to files with PHP-related extensions. It also disables directory listings. This prevents uploaded PHP files from being interpreted or served.
# Nginx - deny execution of PHP files in a specific location (e.g., /userfiles/media/)
location ^~ /userfiles/media/ {
# Do not pass PHP files to the PHP-FPM handler
location ~ \.php$ {
return 403;
}
# Serve static files only; return 404 for missing files
try_files $uri =404;
}
Explanation: The Nginx block ensures that any request for a .php file under the upload location is rejected with 403, and that only static files are served. It prevents the request from being forwarded to PHP-FPM.
Secure development and configuration practices
- Perform whitelist validation on server-side and normalize filenames before saving.
- Use content inspection (magic bytes) in addition to extension checks to reduce disguised payloads.
- Limit the privileges of the application process and database accounts used by the CMS.
- Adopt secure defaults for configuration values — do not expose critical toggles to unaudited interfaces.
- Implement audit logging for configuration changes and require multi-person review for sensitive changes in production.
Incident response and safe testing guidance
If you suspect exploitation:
- Isolate the host from the network while preserving forensic evidence.
- Collect web server logs, process lists, recent file modifications, and network connection history.
- Scan for unexpected executable files in upload directories and for web shell signatures.
- Rotate credentials used by the application and any exposed secrets; review backups for tampering.
For testing and research, always use an isolated lab or staging environment you own or have explicit permission to test. Do not perform unauthorised testing against third-party systems.
Vendor and disclosure information
| Item | Detail |
|---|---|
| Product | CMSimple (5.15 affected) |
| Primary risk | Authenticated file upload leading to server-side code execution |
| Mitigation | Apply vendor patch, remove executable extensions from upload whitelist, harden server config |
| Vendor | https://www.cmsimple.org |
Summary
The core lesson is that file upload features combined with permissive configuration can create a critical execution pathway. For CMS operators, prioritize updates, disable execution in upload directories, and enforce strict server-side validation and access controls. For developers, adopt secure defaults and defense-in-depth so that a single configuration change cannot lead to full server compromise.