Summary
Chamilo's course learning path Settings field is vulnerable to stored cross-site scripting (XSS), allowing untrusted JavaScript to be persisted and later executed in other users' browsers.
An attacker with a low-privileged account can inject malicious script that runs whenever other users, including administrators, view the affected course information page, potentially leading to session theft and account takeover.
Affected context
The vulnerability occurs within Chamilo's course management functionality, specifically when handling the "learning path" Settings field.
It manifests in deployments where user-supplied content in this field is stored and later rendered into web pages without robust output encoding or sanitization.
Any environment where trainers or similarly low-privileged roles can configure course learning paths and where other users regularly view the corresponding course information pages is potentially affected.
Exploit preconditions
- Attack surface: Web application interface for managing course learning paths.
- Required access: Authenticated low-privileged user account (e.g., trainer) with permission to edit the Settings field for a course learning path.
- Trigger point: Another user, such as a student or administrator, must visit the course information page that displays the maliciously crafted content.
- Why exploitation is possible: The application stores and later renders the Settings field without consistently applying contextual output encoding or filtering, allowing injected JavaScript to execute in the victim's browser.
Why this happens
This issue stems from improper neutralization of user-controlled content before it is included in HTML output, aligning with CWE-79 (Improper Neutralization of Input During Web Page Generation).
The learning path Settings field accepts text from a low-privileged user, stores it, and then renders it back into a page viewed by others without applying strict, context-aware HTML/JavaScript escaping or sanitization.
Because the rendered content can contain HTML tags and script-related constructs, the browser interprets parts of the stored input as executable JavaScript, enabling persistent cross-site scripting.
Potential impact
- Theft of session cookies or authentication tokens belonging to higher-privileged users.
- Account takeover (ATO) of administrators, trainers, or students who view the compromised course page.
- Execution of arbitrary actions on behalf of victims (e.g., changing settings, creating or deleting courses, or modifying user accounts).
- Injection of malicious content into course pages, potentially distributing phishing or malware links to students.
- Lateral movement within the application through chained account compromises.
General mitigation guidance
Effective mitigation focuses on enforcing strict output encoding and content handling rules for all user-controlled fields rendered in web pages.
Common defensive patterns include:
- Applying context-aware output encoding (HTML, attribute, JavaScript, or URL encoding) whenever user input is included in server-side templates or client-side rendering.
- Restricting allowed markup in rich-text fields using a well-maintained allowlist-based HTML sanitizer that strips scriptable constructs, event handlers, and dangerous attributes.
- Designing templates so that untrusted data is never embedded directly into executable JavaScript or HTML attributes without robust encoding.
- Adopting a content security policy (CSP) that disallows inline JavaScript and restricts script sources to trusted origins, reducing impact if encoding failures occur.
- Minimizing privileges for low-level roles and separating permissions for content creation and administrative control to limit the blast radius of compromised accounts.
How teams detect issues like this
Detection typically combines code-centric and behavior-centric approaches:
- Static analysis or secure code review looking for template rendering paths where data from the learning path Settings field (and similar inputs) is output without explicit encoding functions.
- Automated scanning with web vulnerability scanners configured to test stored XSS in form fields and parameters associated with course configuration and content management.
- Security unit and integration tests that assert all user-supplied fields are passed through encoding/sanitization layers before rendering.
- Application security policies or linters that flag unsafe patterns, such as direct insertion of raw user input into HTML templates or usage of dangerouslySetInnerHTML/innerHTML-style sinks.
- Monitoring of logs and application telemetry for anomalous script-like payloads being stored in database fields associated with course settings.

