Summary
DiscordChatExporter versions before 2.47.2 can generate HTML exports that render attacker-controlled Discord content without HTML entity encoding when markdown formatting is disabled. A malicious webhook or bot could place script content in messages or embed fields, which may execute when someone opens the exported HTML file.
Affected context
The issue occurs in HTML exports created with markdown formatting disabled. Affected content can originate from message bodies, forwarded or referenced messages, and embed titles, descriptions, field names, or field values. Risk depends on an attacker being able to publish content through a Discord webhook, bot, or another account with access to the exported channel, followed by a user opening the resulting HTML file in a script-capable browser.
Exploit preconditions
- Attack surface: DiscordChatExporter HTML export generation and subsequent file viewing
- Required access: Ability to store attacker-controlled text in a Discord message or embed field
- Trigger point: Rendering an HTML export with markdown formatting disabled, then opening the generated file
- Why exploitation is possible: Selected content is inserted into HTML without entity encoding, allowing markup and script-bearing content to be interpreted by the browser
Why this happens
The vulnerability results from treating untrusted Discord content as trusted HTML during export. Formatting functions such as FormatMarkdownAsync and FormatEmbedMarkdownAsync pass attacker-controlled values into an HTML template without applying context-appropriate entity encoding. This is a stored cross-site scripting issue mapped to CWE-79, because content persisted in a communication channel is later interpreted as executable browser markup.
Potential impact
- A script could execute in the context of the exported document
- Exported chat content could be read or processed by the script
- The displayed export could be altered to mislead the viewer
- Additional local browser actions could be attempted within applicable file-origin security boundaries
- Users could be exposed to phishing or deceptive content embedded in an otherwise trusted export
General mitigation guidance
Mitigation generally focuses on treating all message and embed fields as untrusted data throughout the export pipeline.
Common defensive patterns include:
- Applying context-appropriate HTML entity encoding at the final rendering boundary
- Using templating mechanisms that escape values by default
- Separating trusted formatting transformations from untrusted content
- Allowing only narrowly defined, sanitized markup when HTML is intentionally supported
- Preserving safe-by-default behavior regardless of markdown formatting settings
- Limiting the privileges and sensitive data available to applications used to open exported files
- Avoiding reliance on content origin, such as a webhook or bot, as a trust signal
How teams detect issues like this
Organizations can identify similar issues through:
- Static analysis rules for unencoded values inserted into HTML templates
- Code review checks covering every message, embed, and forwarded-content rendering path
- Tests containing harmless markup markers to verify that generated HTML encodes them
- Policy enforcement requiring auto-escaping template engines or explicit output encoding
- Review of configuration branches that disable markdown or alter rendering behavior
- Automated security review tools that flag user-controlled data reaching HTML sinks without encoding

