Summary
Chamilo versions prior to 1.11.30 contain an SQL injection vulnerability in the course copy session selection logic that processes POST parameters.
By injecting crafted values into specific POST fields, an attacker may modify the structure of backend SQL queries, potentially leading to unauthorized data access, data modification, or full compromise of the LMS database.
Affected context
The vulnerability occurs in Chamilo's course copy functionality, specifically in /main/coursecopy/copy_course_session_selected.php, where user-controlled POST parameters (including resource[document][...] and login-related fields) are incorporated into SQL queries.
It is relevant in deployments where these endpoints are accessible over the web and where user input is not strictly constrained or sanitized before reaching the query-building logic.
The issue becomes especially risky when the application runs with database credentials that have broad privileges over the Chamilo schema.
Exploit preconditions
- Attack surface: Web-facing Chamilo instance exposing
/main/coursecopy/copy_course_session_selected.php. - Required access: Ability to send crafted POST requests; in many LMS setups this is feasible for authenticated users who can access course copy features, though misconfigurations might expose it more broadly.
- Trigger point: Submission of specially crafted POST parameters (e.g.,
resource[document][...]and login parameters) that are concatenated into SQL statements without proper neutralization. - Why exploitation is possible: The server-side code interpolates user input directly into SQL query strings or relies on insufficient validation, instead of using strict parameter binding and type-safe query construction, enabling manipulated input to alter query logic.
Why this happens
This vulnerability stems from building SQL queries by directly embedding user-supplied POST parameter values into the query string.
Instead of treating user input strictly as data (e.g., via prepared statements with bound parameters and explicit type enforcement), the application uses dynamic SQL composition where special characters and fragments of SQL can change the intended query semantics.
This pattern corresponds to CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection'), where input validation and query parameterization are insufficient to prevent attacker-controlled query modification.
Potential impact
- Extraction of sensitive information from the Chamilo database (user accounts, course content, grades, personal data).
- Unauthorized modification or deletion of course data, users, or enrollments.
- Creation of new privileged accounts or escalation of existing privileges within the LMS.
- Corruption of application state, leading to service disruption or data integrity issues.
- In environments with reused or over-privileged database credentials, potential pivoting to other databases or services.
General mitigation guidance
Mitigation centers on ensuring all SQL operations are constructed in a way that user input can never alter query structure.
Recommended patterns include:
- Using parameterized queries (prepared statements) everywhere, with placeholders for all user-controlled values and no string concatenation for SQL logic.
- Enforcing strict server-side validation and normalization of POST parameters, including whitelisting allowed values, types, and ranges for resource identifiers and login fields.
- Applying least-privilege principles to database accounts used by the application, limiting their ability to perform destructive or cross-schema operations.
- Centralizing database access layers to enforce safe query-building APIs, making unsafe ad hoc SQL construction difficult or impossible.
- Treating all client-supplied values, even those from authenticated users and complex form structures, as untrusted data requiring the same protective controls.
How teams detect issues like this
Effective detection generally relies on a combination of code-level analysis and runtime monitoring:
- Static analysis rules targeting direct string concatenation into SQL statements, especially where
$_POSTor equivalent request parameters flow into query construction. - Manual code reviews focusing on database access layers and controller logic handling course copy, session management, and login-related parameters.
- Automated scanning with application security testing tools that probe for SQL injection by sending crafted payloads to endpoints like
/main/coursecopy/copy_course_session_selected.php. - Logging and monitoring for anomalous SQL patterns, such as unexpected syntax, always-true conditions, or unusually complex queries originating from web requests.
- Policy enforcement in CI/CD pipelines that blocks changes introducing raw SQL interpolation without parameterization.

