Summary
A stored Cross-site Scripting (XSS) vulnerability in the AppLollmsMessage.from_dict method allows unsanitized content data from user-controlled input to be deserialized and later rendered as HTML.
When malicious content is viewed in a browser context, injected HTML or JavaScript can execute in the victim's session, potentially leading to account takeover, session hijacking, or self-propagating (wormable) behavior.
Affected context
This vulnerability affects parisneo/lollms deployments that:
- Accept or process user-supplied data into
AppLollmsMessageobjects viafrom_dict - Later render the
contentfield in a browser or web view without robust output encoding - Persist or relay messages between users or sessions (e.g., chat history, shared messages, logs shown in a UI)
The issue is especially relevant where one user's message content can be displayed to other authenticated users or administrators.
Exploit preconditions
- Attack surface: Web UI or any browser-based interface that displays
AppLollmsMessage.content - Required access: Ability to submit or influence message data serialized to a dict and passed into
AppLollmsMessage.from_dict(e.g., chat input, API call, imported conversation) - Trigger point: Deserialization via
from_dictfollowed by rendering thecontentfield into HTML without proper context-aware encoding - Why exploitation is possible: The
contentfield is treated as trusted and inserted into a browser-rendered context without sanitization or HTML/JavaScript escaping, allowing attacker-controlled script execution.
Why this happens
The root cause is the absence of validation, sanitization, or output encoding for the content field when reconstructing AppLollmsMessage instances from user-controlled dictionaries.
The from_dict method effectively rehydrates untrusted data and allows it to propagate into HTML-rendered views without applying context-aware escaping or enforcing a safe subset of markup.
This maps to CWE-79: Improper Neutralization of Input During Web Page Generation (Cross-site Scripting), where user input is included in a web page without correct encoding or filtering, enabling arbitrary script execution in the browser.
Potential impact
- Attacker-controlled JavaScript execution in victims' browsers
- Session hijacking by stealing authentication cookies or tokens (where accessible to JavaScript)
- Account takeover through scripted actions performed on behalf of the victim
- Defacement or manipulation of the web UI to mislead users
- Exfiltration of sensitive data displayed in the affected page or accessible via same-origin APIs
- Wormable propagation by automatically injecting malicious content into subsequent messages or shared artifacts
General mitigation guidance
Effective mitigation focuses on enforcing strict separation between data and executable content and minimizing trust in user-controlled fields:
- Apply context-aware output encoding (HTML, attribute, JavaScript, or URL encoding as appropriate) whenever rendering
contentinto a browser view. - Treat the
contentfield as untrusted, and prefer escaping by default; only allow deliberate, tightly controlled formatting if required. - Where rich text is needed, use a whitelisting/allow-list HTML sanitizer that strips scripts, event handlers, and dangerous attributes.
- Centralize rendering logic so that any data originating from
from_dictpasses through consistent encoding/sanitization routines. - Avoid mixing structured model deserialization with view rendering concerns; keep deserialization purely data-focused and enforce encoding in the presentation layer.
- Apply the principle of least privilege in the browser by avoiding exposure of sensitive tokens or APIs to page scripts when possible.
How teams detect issues like this
Organizations can detect and monitor for similar XSS risks through:
- Static analysis: Rules that flag direct insertion of model fields (such as
content) into templates or DOM sinks (innerHTML,v-html,dangerouslySetInnerHTML, etc.) without encoding or sanitization. - Code review: Check deserialization paths like
from_dictfor fields later used in views, verifying that all untrusted data goes through a shared encoding/sanitization layer. - Template and component policies: Enforce conventions disallowing raw HTML rendering and requiring explicit safe-render helpers for special cases.
- Security testing: Fuzz front-end inputs and message-creation APIs with XSS payloads and observe rendered output for unescaped content.
- Automated pipelines: Integrate SAST/DAST tools and linting rules into CI to surface new or changed code paths that render user-controlled content.

