# GHSA-97GP-5F3J-VWQR: ZIP Slip / Path Traversal in CourseRestorer leads to arbitrary file write and RCE by any course teacher (\< 2.0.3, \< 1.11.40)

- Database: GitHub
- Severity: CVSS 9.0 (Critical)
- Published: 2026-07-07
- Modified: 2026-09-16

## Tracked as

- [CVE-2026-61532](https://cve.now/CVE-2026-61532.md): Chamilo LMS path traversal in CourseRestorer enables code execution

## Affected versions

- chamilo/chamilo-lms (Packagist): through 2.0.2

## Description

### Summary

`CourseRestorer` writes files extracted from a user-supplied legacy course backup ZIP without confining the destination to the extraction directory. Any course teacher (the standard instructor role — no admin required) can upload a crafted ZIP whose entry names contain `..` segments and cause `file_put_contents()` to write attacker-controlled bytes to arbitrary paths on the webserver filesystem. This yields **remote code execution** as the PHP-FPM user, e.g. by dropping a PHP webshell under `public/` or by overwriting Symfony compiled cache files under `var/cache/<env>/` that are auto-loaded on the next request.

Confirmed by static analysis against tag `2.0.2`.

### Impact

- **Vulnerability class:** Path traversal / ZIP slip (CWE-22) leading to arbitrary file write (CWE-73) and, via PHP-executable write locations, remote code injection (CWE-94).
- **Who is impacted:** Every Chamilo LMS deployment that allows non-administrator users to import course backups — i.e. essentially all default deployments, since the "import course" feature is part of the standard teacher toolkit and is gated only by `api_is_allowed_to_edit()`.
- **Attacker prerequisites:** A single teacher account on the target portal. No admin role, no chained vulnerability, no victim interaction beyond the attacker uploading their own crafted backup.
- **Worst case:** Full remote code execution as the PHP-FPM user, leading to total compromise of the Chamilo host: read/modify all course content and grades across the platform, dump the entire user database (PII, password hashes), pivot to other services on the host, and persist via cron / webshell.
- **Scope:** Changed — a course-scoped, low-privilege capability escalates to the security authority of the entire portal/host.

**Workarounds for operators pending a patch**

- Restrict the "Import course backup" feature to platform administrators only, e.g. by removing the capability from non-admin roles or by webserver-level ACLs on `/main/course_copy/` and the corresponding API endpoints under `CourseMaintenanceController`.
- Audit `var/cache/`, `public/main/plugin/`, and the document storage root for unexpected files written by recent backup imports.
- Ensure the PHP-FPM user does not have write access to `public/` outside the documented uploads directory; this removes the easiest RCE primitive but does not stop the `var/cache/` primitive.

### Credits 
- **Reporter:** Nguyen Manh Thuan (manhthuan.2902@gmail.com)
- **Discovery date:** 2026-05-20 
- **Disclosure:** Coordinated with Chamilo maintainers

## References

- https://github.com/chamilo/chamilo-lms/security/advisories/GHSA-97gp-5f3j-vwqr

Page: https://cve.now/GHSA-97GP-5F3J-VWQR
