Summary
A stored cross-site scripting vulnerability in Discourse causes a chat-transcript username to be rendered as HTML by the Rich Text Editor. If an attacker can place crafted content in a username or transcript that is later viewed, script may execute in another user's browser.
Affected context
The issue occurs in Discourse deployments where the Rich Text Editor processes chat transcripts and renders usernames without consistently treating them as plain text. It becomes risky when attacker-controlled username data is stored, included in a transcript, and subsequently displayed to other users with browser-executable markup.
Exploit preconditions
- Attack surface: Discourse chat-transcript rendering in the Rich Text Editor
- Required access: The ability to create or control a username or other data incorporated into a stored transcript
- Trigger point: A victim views the affected transcript through the editor or rendered interface
- Why exploitation is possible: Username content is interpreted as HTML instead of being safely encoded before insertion into the document
Why this happens
The underlying bug is insufficient output encoding for attacker-controlled username data during HTML rendering. By treating stored text as markup, the application permits browser interpretation of content that should remain data. This behavior maps to CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting'), specifically a stored XSS condition.
Potential impact
- Malicious script may execute in the security context of a victim's Discourse session
- An attacker could perform unauthorized actions through the victim's browser
- Sensitive page content or user information could be exposed
- Account settings or forum content could be altered
- The vulnerability could support phishing or further compromise of users
General mitigation guidance
Mitigation generally focuses on treating usernames and transcript fields as untrusted text throughout their lifecycle.
Common defensive patterns include:
- Applying context-appropriate HTML output encoding whenever usernames are rendered
- Using a well-maintained HTML sanitization policy when markup is genuinely required
- Avoiding direct insertion of untrusted strings into HTML or browser DOM APIs
- Enforcing strict content security controls as defense in depth
- Limiting privileges available to authenticated sessions and administrative interfaces
- Preserving untrusted-data classification across storage, transformation, and rendering boundaries
How teams detect issues like this
Detection approaches commonly include:
- Static analysis for direct insertion of user-controlled values into HTML-rendering paths
- Code review checks for missing output encoding around usernames and transcript fields
- Security tests that verify special characters remain text in every supported rendering context
- Dynamic scanning of stored-content workflows with benign markup markers
- Policy enforcement requiring approved templating and sanitization APIs
- Browser security telemetry and content security policy reports for unexpected script execution
Automated code review and application security testing tools may help identify unsafe rendering patterns, but findings should be validated against the actual browser context.

