Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.
Sources: National Vulnerability Database, CISA KEV, Exploit-DB
CVE-2024-47772 Overview
Discourse is an open source platform for community discussion. CVE-2024-47772 is a stored cross-site scripting (XSS) vulnerability [CWE-79] in the Discourse chat feature. An attacker can execute arbitrary JavaScript in a victim's browser by sending a maliciously crafted chat message and replying to it. The flaw only affects Discourse sites that have Content Security Policy (CSP) disabled. The vulnerability is patched in the latest versions of Discourse stable and beta branches. Administrators who cannot upgrade immediately should ensure that CSP is enabled on their forum as a mitigation.
Critical Impact
Attackers can execute arbitrary JavaScript in victim browsers on Discourse instances with CSP disabled, enabling session theft, account takeover, and client-side data exfiltration.
Affected Products
- Discourse stable branch versions prior to the patched release
- Discourse beta branch versions prior to the patched release
- Discourse 3.4.0 beta1
Discovery Timeline
- 2024-10-07 - CVE-2024-47772 published to the National Vulnerability Database (NVD)
- 2026-06-17 - Last updated in NVD database
Technical Details for CVE-2024-47772
Vulnerability Analysis
The vulnerability is a stored cross-site scripting flaw in the Discourse chat subsystem. An attacker crafts a chat message containing malicious markup or script content. When another user replies to that message, Discourse renders the attacker-controlled content in a context where it executes as JavaScript in the victim's browser. User interaction is required because the payload only triggers through the reply rendering flow. The attack takes place entirely over the network and does not require authentication beyond standard chat access.
Root Cause
The root cause is improper neutralization of user-supplied input during web page generation in the chat reply rendering path [CWE-79]. Content submitted through chat messages is not fully sanitized before being embedded in the Document Object Model (DOM) of the reply view. Because browsers treat embedded scripts as executable, the untrusted markup runs with the privileges of the viewing user's Discourse session. Content Security Policy, when enabled, blocks inline script execution and prevents the payload from running. Discourse ships with CSP enabled by default, so only operators who have explicitly disabled CSP are exposed.
Attack Vector
Exploitation requires an attacker to post a crafted chat message and a victim user to reply to that message within a Discourse instance where CSP is disabled. The injected JavaScript runs under the victim's origin, which allows theft of session cookies, forgery of authenticated requests, and manipulation of chat and forum content. Because the scope changes to the victim's browser context, the impact extends to any resource the victim can access from the same origin. The vulnerability does not directly affect confidentiality or integrity of the Discourse server itself, but it can be used as a pivot for account takeover.
Detection Methods for CVE-2024-47772
Indicators of Compromise
- Chat messages containing HTML tags, event handler attributes, or JavaScript URI schemes that bypass normal formatting
- Unexpected outbound requests from user browsers to attacker-controlled domains originating from a Discourse origin
- Anomalous session activity, including API calls or administrative actions initiated from unusual sources shortly after users viewed a chat reply
- Discourse response headers lacking a Content-Security-Policy directive
Detection Strategies
- Review the Discourse admin dashboard to confirm whether content_security_policy is enabled under site settings
- Audit chat message content for suspicious payloads such as <script>, <img onerror=...>, or javascript: references
- Compare the running Discourse version against the fixed releases listed in GitHub Security Advisory GHSA-67mh-xhmf-c56h
Monitoring Recommendations
- Enable and monitor CSP violation reports using the report-uri or report-to directive to surface injection attempts
- Log and alert on outbound HTTP requests from user browsers that reference unknown third-party domains after chat interactions
- Monitor Discourse application logs for abnormal patterns of chat replies tied to specific message IDs
How to Mitigate CVE-2024-47772
Immediate Actions Required
- Upgrade Discourse to the latest patched stable or beta release as published in the vendor security advisory
- Enable Content Security Policy in Discourse site settings if it has been disabled
- Audit existing chat messages for malicious payloads and remove any suspicious content
- Rotate session tokens and review administrator accounts for signs of unauthorized activity
Patch Information
Discourse has released patched versions on both the stable and beta branches. Operators should apply the latest release referenced in the GitHub Security Advisory GHSA-67mh-xhmf-c56h. After upgrading, administrators are advised to leave Content Security Policy enabled as a defense-in-depth measure against future injection flaws.
Workarounds
- Enable Content Security Policy in Discourse by setting content_security_policy to true in site settings, which blocks the inline script execution required by this attack
- Restrict chat permissions to trusted user groups until the upgrade can be applied
- Review and document any custom themes or plugins that may have required disabling CSP, and refactor them to be CSP-compatible as described in the Mozilla Developer Network CSP Documentation
# Enable Content Security Policy in Discourse
# Admin > Settings > Security > content_security_policy = true
# Verify via HTTP response headers:
curl -I https://your-discourse-site.example.com/ | grep -i content-security-policy
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.
Sources: National Vulnerability Database, CISA KEV, Exploit-DB

