Summary
Chamilo LMS versions prior to 1.11.38 contain a path traversal flaw in main/exercise/savescores.php where user-controlled input is concatenated directly into filesystem paths.
An attacker who can control the test parameter may be able to traverse directories and delete arbitrary files on the server, potentially impacting availability and integrity of the LMS environment.
Affected context
The vulnerability occurs in the score-saving functionality of Chamilo LMS, specifically in main/exercise/savescores.php.
It manifests when the application constructs file paths using $_REQUEST['test'] without normalizing or validating the resulting path.
In deployments where the web server process has broad filesystem permissions and user-controlled parameters reach this script, crafted input can influence which files are targeted for deletion.
Exploit preconditions
- Attack surface: HTTP interface exposed by Chamilo LMS, targeting
main/exercise/savescores.php. - Required access: Ability to send HTTP requests that reach the vulnerable script; in many LMS deployments this may require at least an authenticated user role capable of accessing exercises.
- Trigger point: The
testrequest parameter ($_REQUEST['test']) is received and concatenated into a filesystem path used in deletion logic. - Why exploitation is possible: The application constructs file system paths directly from user input without canonicalization, normalization, or checks for directory traversal sequences, allowing
../patterns to escape the intended directory.
Why this happens
This issue stems from direct use of unvalidated user input in filesystem path construction, aligning with CWE-22: Improper Limitation of a Pathname to a Restricted Directory.
The $_REQUEST['test'] parameter is concatenated into a path used by file deletion routines without canonicalizing the path or verifying that it remains within an allowed base directory.
As a result, directory traversal sequences can redirect file operations to unintended locations, enabling deletion of files outside the intended exercise-related storage area.
The behavior also relates to CWE-73: External Control of File Name or Path, where external input controls which file is operated upon.
Potential impact
- Deletion of course materials, exercises, or uploaded resources relied on by students and instructors
- Removal of configuration files that can disrupt application behavior or cause denial of service
- Deletion of log files, hindering forensic analysis and incident response
- Potential corruption of backups or temporary data if these are accessible to the application user
- Broader system instability if the web server user has permissions to delete critical system or application files
General mitigation guidance
Effective mitigation focuses on constraining how user input influences filesystem paths and reducing file operation privileges:
- Restrict file operations to a predefined base directory and enforce that any resolved path remains within this directory after canonicalization.
- Normalize and validate user input used in file paths, rejecting or sanitizing any segments containing directory traversal sequences, absolute paths, or unexpected characters.
- Use indirect references (such as opaque IDs mapped to server-side paths) instead of allowing clients to specify file or path names directly.
- Implement least-privilege for the web server or PHP user so it only has write/delete permissions in directories that truly require it.
- Centralize file access routines behind helper APIs that enforce validation and policy checks consistently across the codebase.
How teams detect issues like this
Organizations can detect similar vulnerabilities by combining code analysis and operational monitoring:
- Static analysis: Configure rules to flag concatenation of
$_GET,$_POST, or$_REQUESTvalues into filesystem APIs (e.g.,unlink,fopen,file_put_contents,include) without prior validation or normalization. - Code review: During manual review, look for file operations based on request parameters and verify that they use whitelisting, canonicalization, and base-directory checks.
- Security testing: Use targeted dynamic testing to probe for directory traversal sequences in parameters that influence file operations, watching for errors or unexpected behavior.
- Runtime monitoring: Monitor application logs and server logs for suspicious patterns such as
../sequences in request parameters, repeated file deletion errors, or access to unexpected directories.

