Summary
Totara LMS v19.1.5 and earlier contains an HTML injection vulnerability in the messaging functionality, allowing attacker-controlled HTML to be stored and rendered in other users' browsers.
When a malicious message is viewed, the injected code can execute in the victim's session, potentially leading to session hijacking and arbitrary actions in the application via the victim's browser.
Affected context
The vulnerability resides in Totara LMS's in-application messaging or notification feature, where users can compose and send messages to other users.
It appears when message content is accepted from the sender and then rendered back to recipients without adequate HTML sanitization, output encoding, or strict content filtering.
The issue becomes impactful in environments where many users read messages within the web interface, particularly if administrators, trainers, or other privileged accounts regularly interact with the messaging system.
Exploit preconditions
- Attack surface: Web interface for composing and viewing messages within Totara LMS.
- Required access: Ability to authenticate or otherwise gain access to a user account that can send messages to other users (or to all users).
- Trigger point: Any page or UI component that displays the stored message content in a browser without proper output encoding.
- Why exploitation is possible: The message body is treated as trusted HTML and rendered directly in the victim's browser, allowing attacker-supplied script or event handlers to execute in the context of the Totara LMS origin.
Why this happens
This issue is an instance of CWE-79: Improper Neutralization of Input During Web Page Generation (Cross-Site Scripting).
The underlying problem is that user-supplied message content is not correctly neutralized before being embedded into the HTML response.
Instead of applying strict output encoding for the relevant HTML context (e.g., text node, attribute, URL) or sanitizing disallowed tags and attributes, the application allows raw HTML/markup to flow from input to output.
This insecure pattern effectively grants untrusted users the ability to inject active content (such as scripts) into pages viewed by other users.
Potential impact
- Attacker-controlled JavaScript executing in the victim's browser.
- Session hijacking via theft of session identifiers where not otherwise protected (e.g., via HttpOnly cookies or other controls).
- Impersonation of the victim within Totara LMS, including performing actions with the victim's privileges.
- Unauthorized access to sensitive data visible to the victim, such as course materials, grades, or user information.
- Use of the victim's browser as a pivot for further phishing or social engineering within the platform.
- Potential use of stored payloads as part of broader browser-based exploitation chains, depending on the victim's environment and other weaknesses.
General mitigation guidance
Mitigation generally focuses on strict separation between data and executable content and on treating all user input as untrusted:
- Apply context-appropriate output encoding to all user-supplied fields when rendering them into HTML pages (e.g., HTML-encoding, attribute-encoding, and URL-encoding as needed).
- Introduce a robust HTML sanitization layer for any fields that legitimately require limited markup, allowing only a minimal, well-defined whitelist of safe tags and attributes.
- Default to plain-text rendering for messages and disable or greatly restrict raw HTML where it is not essential to functionality.
- Enforce content security controls (such as a strict Content Security Policy) to reduce the impact of any remaining injection points.
- Apply least-privilege principles to user roles so that compromise of a single account yields the smallest possible access.
How teams detect issues like this
Effective detection combines automated analysis with targeted review of high-risk features:
- Use static analysis or security linters to flag server-side templates and controllers where user input is rendered without encoding or passes through unsafe rendering APIs.
- Implement automated tests that submit specially crafted message content and verify it is rendered as inert text rather than active HTML/JavaScript.
- Conduct code reviews focusing on messaging, comments, forums, and other collaborative features, looking specifically for direct insertion of user-supplied content into HTML responses.
- Apply runtime application security testing (DAST) or browser-based testing tools to systematically probe user-editable fields for XSS behavior.
- Integrate security checks into CI/CD pipelines so that new or modified rendering code is scanned for XSS patterns before deployment.

