Summary
Chamilo LMS suffers from an unrestricted file upload issue in the exercise sound upload feature, where a teacher can upload a PHP file while spoofing the Content-Type header as audio/mpeg.
Because the file keeps its .php extension and is stored in a web-accessible directory, this condition can lead to remote code execution as the web server user when the file is accessed.
Affected context
The vulnerability occurs in Chamilo LMS instances that expose the exercise sound upload functionality to authenticated teacher roles.
It manifests where uploaded content is trusted based on the HTTP Content-Type header, and where uploaded files are saved using their original filenames and extensions into directories that are directly served by the web server.
In such environments, if server-side validation does not enforce strict file type, extension, and execution policies, a PHP file uploaded through this feature may later be executed as application code.
Exploit preconditions
- Attack surface: HTTP upload endpoint used for exercise sound/audio uploads in Chamilo LMS.
- Required access: Valid authenticated teacher (or higher) account with permission to create or modify exercises that accept sound uploads.
- Trigger point: Submitting an upload request containing a PHP file while setting the
Content-Typeheader toaudio/mpeg(or a similarly accepted type). - Why exploitation is possible:
- The server relies on the client-provided Content-Type header rather than independently validating the file content and extension.
- The uploaded file is stored with its original
.phpextension in a web-accessible directory. - The web server is configured to interpret
.phpfiles as executable scripts, so a subsequent HTTP request to the uploaded file path executes the file.
Why this happens
This vulnerability stems from insufficient server-side validation of uploaded files in the exercise sound upload functionality.
Instead of enforcing a strict allowlist of file extensions and verifying the actual file type at the server, the implementation trusts the Content-Type header supplied by the client and preserves the original filename and extension.
Combined with saving uploads into a web-accessible directory where .php files are executed by the web server, this behavior matches CWE-434: Unrestricted Upload of File with Dangerous Type.
Abstractly, the insecure pattern is: user-controlled file data plus user-controlled filename and extension, stored in an executable context, without robust validation or separation between data and code.
Potential impact
- Remote code execution as the web server user (
www-data) through uploaded PHP scripts. - Full compromise of the Chamilo LMS application context, including reading or modifying application data.
- Pivoting to access or manipulate sensitive information stored in the LMS database (e.g., course content, user records, grades), depending on existing permissions.
- Use of the compromised server as a foothold for further attacks within the hosting environment or internal network, subject to isolation and hardening controls.
- Deployment of persistent webshells that facilitate long-term unauthorized access and post-exploitation activities.
General mitigation guidance
Effective mitigation focuses on tightening upload handling, restricting execution surfaces, and reducing trust in client-controlled metadata:
- Strict file type and extension allowlists:
- Enforce a server-side allowlist of permitted file extensions for the exercise sound feature (e.g.,
.mp3,.wav) and reject any other extensions. - Normalize filenames (e.g., generate server-side names) and strip or replace disallowed characters and extensions rather than preserving the original client-provided name.
- Content validation independent of client headers:
- Do not rely on the
Content-Typeheader supplied by the client. - Verify uploaded content using server-side mechanisms such as file signatures, MIME detection libraries, or media-specific parsing where feasible.
- Non-executable storage locations:
- Store all user-uploaded files outside of web-executable directories so they cannot be interpreted as scripts by the web server.
- Configure the web server so that user-uploaded paths never execute code (e.g., disable script execution in upload directories).
- Separation of code and user content:
- Maintain clear separation between application code directories and user-upload directories.
- Apply web server rules (e.g., for PHP or other interpreters) that only execute code from explicitly designated locations controlled by the deployment process.
- Principle of least privilege and hardening:
- Run the web server and PHP interpreter with the least privileges necessary, restricting filesystem permissions for upload directories.
- Apply general hardening (e.g., disabling dangerous PHP functions where compatible with the application) to reduce the impact if a malicious file is somehow executed.
How teams detect issues like this
Organizations can employ several approaches to detect similar unrestricted file upload risks:
- Static analysis and code review:
- Search for upload handlers that:
- Use client-controlled filenames directly when saving files.
- Do not enforce a strict extension allowlist.
- Trust
$_FILES['type']or HTTPContent-Typewithout independent inspection. - Look for code paths saving uploads to directories under the document root that are also configured to execute scripts.
- Configuration and policy checks:
- Review web server and PHP configurations to ensure that upload directories are not marked as executable for server-side scripts.
- Enforce policies that separate user content directories from code directories in deployment templates and infrastructure-as-code.
- Dynamic testing and QA:
- Incorporate security tests in QA that attempt to upload non-permitted file types (e.g.,
.php,.phtml) through media or document upload features. - Verify that such uploads are rejected or stored in a way that prevents execution, and that the application responds with appropriate errors.
- Monitoring and logging:
- Monitor access logs for suspicious requests to upload paths or unexpected script execution within upload directories.
- Enable application-level logging around upload features to detect anomalous file types or repeated upload attempts that violate expected patterns.
Automated security scanning tools—both static analyzers and dynamic web vulnerability scanners—can augment manual review by flagging risky upload endpoints and executable upload directories, but should be combined with human validation.

