/

CVE-2025-50189

Severity:

HIGH RISK

(8.8)

SQL Injection in Chamilo Course Copy Login Handling

CVE-2025-50189

Analyzed

Vulnerability type

Category:

SQL Injection

CWE:

CWE-89

Impact:

Unauthorized Database Access and Manipulation

Severity:

HIGH RISK

(8.8)

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 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 $_POST or 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.

Sources

SourceLink
github.comgithub.com/chamilo/chamilo-lms/commit/22bb81df8f7062da20a2f6248789f47b221ca705
github.comgithub.com/chamilo/chamilo-lms/commit/75ab03c938adc48a3cd8234d98fc340e1998aa81
github.comgithub.com/chamilo/chamilo-lms/commit/7903cef2eb41817c11a52ba6ac34a1d454bc5ef7
github.comgithub.com/chamilo/chamilo-lms/releases/tag/v1.11.30
github.comgithub.com/chamilo/chamilo-lms/security/advisories/GHSA-vxx3-648j-7p4r

Frequently asked

questions

Exploitability depends on how accessible the course copy and related login flows are. In many deployments, authenticated users with course management capabilities can reach the vulnerable endpoint, making insider or low-privileged user attacks plausible.

Often, yes—access to the course copy functionality is typically gated by authentication and role-based permissions. However, if the endpoint is exposed or misconfigured, an unauthenticated attacker might be able to send crafted POST requests as well.

The most robust approach is to replace any dynamic query construction with parameterized queries, ensuring all user inputs are bound as parameters and never used to build SQL logic. Complement this with strict server-side validation and database least-privilege.

Adopting a secure data access layer that enforces parameterization by design, combined with coding standards, automated static analysis, and security-focused code reviews, helps prevent new SQL injection vectors from being introduced in other parts of the LMS.

Find out what's already
exploitable in your codebase.