Summary
Chamilo Learning Management System versions prior to 1.11.30 contain an error-based SQL injection vulnerability in the /main/exercise/hotpotatoes.php script, reachable via the userFile POST parameter.
An attacker who can submit crafted POST requests to this endpoint may be able to manipulate database queries, potentially exposing or altering sensitive LMS data under certain conditions.
Affected context
The vulnerability occurs in Chamilo LMS instances that expose the /main/exercise/hotpotatoes.php script and process POST requests containing a userFile parameter.
It is relevant in deployments where user-supplied values from this parameter are interpolated into SQL queries without adequate sanitization or parameterization.
Actual risk depends on how the LMS is published (internet-facing vs internal), authentication requirements for accessing the exercise endpoint, and database privileges assigned to the application account.
Exploit preconditions
- Attack surface: HTTP(S) interface, specifically POST requests to
/main/exercise/hotpotatoes.php. - Required access: Ability to reach the Chamilo web interface and submit POST requests with a
userFileparameter (authentication requirements depend on instance configuration). - Trigger point: Server-side handling of the
userFilevalue when building and executing SQL queries related to the exercise/hotpotatoes feature. - Why exploitation is possible: The application constructs SQL statements using attacker-controlled input from
userFilewithout consistently using parameterized queries or robust validation, enabling error-based SQL injection.
Why this happens
This issue stems from constructing SQL queries by concatenating raw input from the userFile POST parameter into query strings.
When user-controlled values are embedded directly in SQL without proper binding, quoting, or type enforcement, attackers can inject additional SQL syntax to alter the intended query structure.
This aligns with CWE-89: SQL Injection, where the core bug class is treating input as trusted SQL code instead of data, and relying on ad-hoc escaping or no validation at all.
Potential impact
- May allow attackers to read sensitive information from the LMS database, such as course content or user-related data.
- Could enable modification or deletion of exercise records and related tables, affecting assessment integrity.
- Can potentially lead to creation or escalation of LMS user accounts, depending on database schema and privileges.
- Might allow discovery of database structure and configuration details through error-based responses.
- In some environments, could be chained with other weaknesses to gain broader access to underlying infrastructure.
General mitigation guidance
Mitigation generally focuses on eliminating direct string concatenation of user input into SQL statements and constraining input semantics:
- Use parameterized queries (prepared statements) for all database interactions involving external input, including the
userFileparameter and related fields. - Apply strict input validation and canonicalization, ensuring that only expected formats, types, and ranges are allowed for exercise-related parameters.
- Adopt a data access layer or ORM configured to treat all input as data, not executable SQL, and to enforce query parameterization by default.
- Limit database account privileges so that the LMS connection can perform only the minimum required operations, reducing impact if injection occurs.
- Implement centralized input-handling utilities and secure coding guidelines so that new features reuse safe query-building patterns.
How teams detect issues like this
Detection can leverage both code-centric and behavior-centric approaches:
- Static analysis: Scan PHP code for dynamic SQL construction that interpolates
$_POST,$_REQUEST, or similar superglobals into query strings, especially inhotpotatoes.phpand exercise-related modules. - Code review: Flag any direct concatenation of user input into SQL, absence of prepared statements, or custom escaping routines in database access code.
- Runtime monitoring: Use web application firewalls (WAFs) or request inspection tools configured with SQL injection rules to alert on suspicious patterns in the
userFileparameter. - Database logging: Monitor database logs for anomalous queries, syntax errors, or unusual access patterns originating from the application account.
- CI/CD checks: Integrate automated security testing and linting into the development pipeline to detect new instances of raw SQL construction before deployment.

