/

CVE-2026-30881

Severity:

HIGH RISK

(8.8)

SQL Injection in Chamilo LMS Statistics AJAX Endpoint

CVE-2026-30881

Analyzed

Vulnerability type

Category:

SQL Injection

CWE:

CWE-89

Impact:

Database Compromise / Data Exfiltration

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 LMS versions 1.11.34 and earlier contain a SQL injection vulnerability in the statistics AJAX endpoint, where the date_start and date_end parameters from $_REQUEST are concatenated directly into a raw SQL query.

Due to a flawed escaping workflow that restores attacker-controlled single quotes, an authenticated user can inject arbitrary SQL fragments, enabling blind time-based and conditional data extraction from the application's database.

Affected context

This vulnerability occurs in Chamilo LMS installations that expose the statistics AJAX endpoint and accept user-controlled date_start and date_end parameters from HTTP requests.

The affected code constructs SQL queries by directly interpolating these parameters into query strings, attempting to escape them but then undoing the escaping through string replacement.

Any environment where authenticated users can trigger statistics requests is potentially affected, particularly multi-tenant or externally accessible LMS deployments.

Exploit preconditions

  • Attack surface: HTTP(S) requests to the Chamilo LMS statistics AJAX endpoint.
  • Required access: Authenticated access to a role that can call the statistics feature (e.g., teacher, admin, or any user with statistics visibility).
  • User-controlled input: date_start and date_end taken from $_REQUEST (GET/POST) without proper, final sanitization.
  • Trigger point: Execution of a dynamically constructed SQL query that incorporates these parameters into conditions or clauses.
  • Why exploitation is possible: The application calls Database::escape_string() but then uses str_replace("\\'", "'", ...), which reintroduces usable single quotes, thereby neutralizing escaping and allowing attacker-supplied SQL syntax to be interpreted by the database.

Why this happens

The underlying bug is an instance of CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection').

Instead of using parameterized queries or prepared statements, the code builds SQL by concatenating raw user input from $_REQUEST variables into query strings.

Although an escaping function is invoked, a subsequent str_replace operation intentionally converts escaped single quotes back into plain quotes, effectively bypassing the protection and leaving special SQL characters unneutralized.

This pattern exemplifies fragile, hand-rolled input sanitization logic, where post-processing of "escaped" input reintroduces dangerous characters and turns otherwise benign parameters into SQL commands.

Potential impact

  • An attacker could extract sensitive information from the database using blind time-based or conditional queries (e.g., user records, course data).
  • The attacker may be able to enumerate or infer credential-related data (such as password hashes) stored in affected tables.
  • Under certain database configurations, the attacker could modify, insert, or delete records, impacting course content, grades, or user accounts.
  • The LMS's integrity and availability could be degraded through expensive or malicious queries, potentially leading to performance issues or partial denial of service.

General mitigation guidance

Effective mitigation focuses on eliminating dynamic SQL built from concatenated user input and relying on robust, framework-native safeguards:

  • Use parameterized queries / prepared statements for all database access, binding date_start, date_end, and similar values as parameters instead of interpolating them into SQL strings.
  • Define explicit input validation rules for date parameters, such as accepting only fixed formats (e.g., ISO date strings) and rejecting any unexpected characters or patterns.
  • Avoid custom escaping and unsafe string post-processing (e.g., str_replace on escaped strings); instead, delegate quote handling to the database abstraction layer or ORM.
  • Apply principle of least privilege to the database account used by the LMS so that, if injection occurs, the account has minimal rights and cannot perform dangerous administrative operations.
  • Centralize query construction patterns and enforce secure database access conventions in coding standards, reducing the likelihood that developers fall back to ad hoc string concatenation.

How teams detect issues like this

Organizations can identify and monitor this class of flaw using a combination of static, dynamic, and process-oriented techniques:

  • Static analysis: Configure SAST tools or custom rules to flag:
  • Raw concatenation of $_REQUEST, $_GET, or $_POST variables into SQL strings.
  • Any use of escaping functions followed by string manipulation like str_replace that touches quotes or backslashes.
  • Direct use of low-level database APIs instead of parameterized abstraction layers.
  • Code review: During manual reviews, look for:
  • SQL queries built via string concatenation or interpolation rather than prepared statements.
  • Input validation that focuses solely on escaping rather than strict whitelisting or type enforcement.
  • Functions that modify already-escaped values, especially around quotes or special SQL characters.
  • Dynamic testing: Use application-level security testing (DAST) or specialized scanners to:
  • Probe date and filter parameters with time-based payloads to detect delayed responses and conditional behaviors.
  • Correlate anomalous response times or error patterns with injected parameter values.
  • Operational monitoring: Implement database query logging and anomaly detection to highlight unusual, long-running, or structurally suspicious queries originating from the web application context.

Sources

SourceLink
github.comgithub.com/chamilo/chamilo-lms/releases/tag/v1.11.36
github.comgithub.com/chamilo/chamilo-lms/security/advisories/GHSA-5ggx-x2cv-4h44

Frequently asked

questions

Yes, if the Chamilo LMS instance is exposed over the internet and the statistics AJAX endpoint is accessible to authenticated users, an attacker who can obtain valid credentials can exploit the flaw remotely via crafted HTTP requests.

Not necessarily. The vulnerability is tied to authenticated access to the statistics functionality. Any role that can trigger the statistics AJAX endpoint and supply date_start and date_end may be able to exploit the issue, even if it does not have full administrative rights.

The safest fix is to replace all string-concatenated SQL with parameterized queries or prepared statements, enforce strict input validation (e.g., accept only valid date formats), and remove any custom escaping or quote-mangling logic that attempts to sanitize SQL manually.

Adopt a development policy that mandates parameterized queries for all database operations, implement centralized input validation utilities for common parameter types, and integrate static analysis and security-focused code reviews into the CI/CD pipeline to catch unsafe query patterns early in the development lifecycle.

Find out what's already
exploitable in your codebase.