/

CVE-2025-50191

Severity:

HIGH RISK

(7.2)

SQL Injection in Chamilo hotpotatoes.php Exercise Handler

CVE-2025-50191

Analyzed

Vulnerability type

Category:

SQL Injection

CWE:

CWE-89

Impact:

Database Compromise / Data Exposure

Severity:

HIGH RISK

(7.2)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

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 userFile parameter (authentication requirements depend on instance configuration).
  • Trigger point: Server-side handling of the userFile value 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 userFile without 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 userFile parameter 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 in hotpotatoes.php and 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 userFile parameter.
  • 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.

Sources

SourceLink
github.comgithub.com/chamilo/chamilo-lms/commit/06155f128395acc6745af826150a0bb2b4a68496
github.comgithub.com/chamilo/chamilo-lms/releases/tag/v1.11.30
github.comgithub.com/chamilo/chamilo-lms/security/advisories/GHSA-82qx-25j7-5639

Frequently asked

questions

Yes, it can be remotely exploitable if the Chamilo instance is reachable over the network and the /main/exercise/hotpotatoes.php endpoint can be invoked with attacker-controlled POST data.

That depends on how the LMS is configured. If access to the exercise feature requires login, attackers generally need at least a low-privileged account. In more permissive setups, it may be reachable without authentication.

Refactor all affected database calls to use parameterized queries or an ORM that enforces binding, and ensure that exercise-related inputs such as userFile are validated against strict whitelists. Avoid any dynamic SQL built from concatenated request parameters.

Establish a standard data-access layer that forbids raw SQL concatenation, apply secure coding guidelines for handling input, run automated security tests and static analysis in CI, and perform regular security-focused code reviews for high-risk modules like authentication, exercises, and grading.

Find out what's already
exploitable in your codebase.