Summary
Chamilo LMS course restoration can use paths from an imported legacy course backup without consistently restricting file operations to the extraction directory. A course teacher who imports a crafted backup may cause attacker-controlled files to be written elsewhere, potentially enabling code execution by the PHP process.
Affected context
The issue occurs in Chamilo LMS course restoration components that process paths supplied by a legacy course backup. It may affect deployments where a course teacher can import such a backup and the restoration process does not consistently verify that resolved paths remain within the intended extraction directory. Writes to PHP-executable or automatically loaded locations could increase the impact.
Exploit preconditions
- Attack surface: Course backup import and restoration in Chamilo LMS
- Required access: An account with permission to import a course backup, such as a course teacher
- Trigger point: Processing files and paths from a crafted legacy backup
- Why exploitation is possible: Path values are not consistently confined to the extraction directory, allowing file operations to target locations outside it
Why this happens
The underlying flaw is insufficient validation and confinement of paths derived from an imported archive. If parent-directory segments are accepted without resolving and checking the final destination against the intended extraction root, file operations can escape that directory. This maps primarily to CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'). It also relates to CWE-73: External Control of File Name or Path; code execution may follow if attacker-controlled content is written to a location interpreted as executable code.
Potential impact
- Attacker-controlled files could be written outside the intended course extraction directory.
- PHP code could be executed with the privileges of the PHP process if a suitable executable or automatically loaded location is writable.
- Course data, user data, or credentials could be exposed or altered.
- The application host could be compromised, depending on its configuration and process privileges.
General mitigation guidance
Defensive patterns include resolving each destination to a canonical path and verifying that it remains beneath the intended extraction root before performing file operations. Reject traversal components and unexpected path forms, and use archive extraction mechanisms that enforce destination confinement by default. Treat imported backups as untrusted input, apply strict file and path validation, and avoid placing restored content in executable or automatically loaded locations. Restrict the PHP process and restoration workflow to the minimum filesystem permissions needed.
How teams detect issues like this
Review archive restoration code for paths built from imported filenames and for file operations that lack canonical-path containment checks. Static analysis can flag archive extraction, path joining, and file-write operations where externally controlled paths reach filesystem APIs without validation. Code review should examine handling of parent-directory segments, symlinks, and destination roots. Policies can require safe extraction libraries and tests that verify writes remain within approved directories.

