Roundcube Webmail 1.6.6 - Stored Cross Site Scripting (XSS)
# Exploit Title: Roundcube Webmail 1.6.6 - Stored Cross Site Scripting (XSS)
# Google Dork:
# Exploit Author: AmirZargham
# Vendor Homepage: Roundcube - Free and Open Source Webmail Software
# Software Link: Releases · roundcube/roundcubemail
# Version: Roundcube client version earlier than 1.5.6 or from 1.6 to 1.6.6.
# Tested on: firefox,chrome
# CVE: CVE-2024-37383
# CWE: CWE-79
# Platform: MULTIPLE
# Type: WebApps
Description:
The CVE-2024-37383 vulnerability was discovered in the Roundcube Webmail email client. This is a stored XSS vulnerability that allows an attacker to execute JavaScript code on the user's page. To exploit the vulnerability, all attackers need to do is open a malicious email using a Roundcube client version earlier than 1.5.6 or from 1.6 to 1.6.6.
Usage Info:1 - open the Roundcube_mail_server_exploit_for_CVE-2024-37383.txt and export js file.2 - Change the web address of the original email (target) and the URL of the receiving server (attacker server).3 - You can put the code in file SVG <animate> tag and send it to the server. (can use this https://github.com/bartfroklage/CVE-2024-37383-POC)4 - After the victim clicks, all emails in the mailbox will be sent to your collaborator server.
This code automates the process of retrieving all messages inbox from a Roundcube webmail server and forwarding that data to a specific collaborator server endpoint.Here’s a step-by-step breakdown:
-
Setup URLs:
- The main webmail URL (target) and the receiving server URL (attackerserver) are defined as variables at the beginning for easy configuration.
-
Get Total Page Count:
- The getPageCount function sends a GET request to the main webmail URL to fetch metadata, including the total number of pages (pagecount).
- If pagecount is found, it proceeds to loop through each page.
-
Fetch Message IDs from All Pages:
- For each page from 1 to pagecount, it constructs a paginated URL to request that page.
- Each page’s response is checked for instances of add_message_row(NUMBER) using regex, extracting message IDs from each instance and collecting all IDs in a single list.
-
Retrieve Each Message's Content:
- For each message ID, the code constructs a URL to request detailed data about that message.
- It sends a GET request for each message ID URL, receiving the full response HTML.
-
Extract and Clean Message Data:
- Within each message response, it uses regex to capture the <title> (message title) and main message content.
- Any HTML tags are stripped from the message content to keep only the plain text.
-
Send the Data to the Server:
- For each extracted message, a POST request is made to the server endpoint with the title and cleaned message content, URL-encoded for proper transmission. Roundcube Webmail 1.6.6 — Stored Cross‑Site Scripting (CVE‑2024‑37383)
This article explains the stored Cross‑Site Scripting (XSS) vulnerability identified in Roundcube Webmail (CVE‑2024‑37383), its impact, detection strategies, remediation and hardening advice. The goal is to provide clear, actionable defensive guidance for administrators, security engineers and developers while avoiding actionable exploit details.
Quick facts
| Item | Details |
|---|---|
| Vulnerability | Stored Cross‑Site Scripting (CWE‑79) |
| Affected versions | Roundcube client earlier than 1.5.6, and 1.6.0 through 1.6.6 |
| CVE | CVE‑2024‑37383 |
| Impact | Remote script execution in the context of an authenticated user when viewing a malicious message |
| Primary vector | Maliciously crafted email stored on server and viewed by victim (stored XSS) |
| Primary mitigation | Upgrade to a patched release and apply additional defenses (sanitization, CSP, secure cookies) |
Vulnerability overview
A stored XSS occurs when untrusted input is stored by the application (for example, message body metadata) and later rendered into a user's browser without sufficient context‑aware encoding or sanitization. In this case, crafted content in an email can cause the Roundcube UI to render executable script in the context of the authenticated user. An attacker could abuse this to steal session tokens, perform actions on the user's behalf, or exfiltrate data accessible in the user’s browser session.
Why this is serious
- Webmail is highly privileged: access to mailboxes, contacts and potentially account settings.
- Stored XSS triggers when a user simply views a message; social engineering can convince users to open mail.
- Automated or stealthy exfiltration is possible if the attacker can execute script in the user’s session.
Detection and indicators of compromise
Log and mailbox inspection
Inspect mail storage and application logs for suspicious message content that contains script, SVG with embedded animation, or unescaped attributes. Searching mail message bodies for common XSS vectors is a practical defensive step.
# Example defensive search (server-side): look for suspicious tags in stored mail files/maildir
grep -R --line-number -iE "<script|<svg|onload=|onerror=" /var/mail /var/vmail
Explanation: This is a defensive grep command to search server mail directories for common dangerous constructs. Adjust paths and regex to your environment and test on non-production first.
Web logs and application traces
- Look for unusual POSTs or GETs that request message viewers, or that include unexpected query parameters.
- Review access logs for unusual user agent or IP combinations that coincide with subsequent suspicious activity.
Browser artefacts
Compromised browsers may show unexpected network requests to external domains (exfiltration endpoints). Network monitoring or Content‑Security‑Policy (CSP) violation reports can highlight suspicious outbound connections originating from webmail UIs.
Remediation and mitigation
Immediate actions for administrators
- Upgrade Roundcube to a patched release immediately. For affected branches, upgrade to the vendor‑released patched versions (for example: 1.5.6 or a 1.6.x release that includes the patch) or to the latest stable release recommended by Roundcube.
- If an immediate upgrade is not possible, apply temporary mitigations: restrict access, disable HTML rendering for incoming messages or force messages to be displayed as plain text, and deploy restrictive CSP headers.
- Rotate administrative credentials and review user sessions; invalidate persistent sessions if compromise is suspected.
Server‑side hardening recommendations
- Enable or strengthen HTML sanitization on message rendering. Prefer a well‑maintained library for sanitization rather than ad‑hoc regex.
- Enable HTTP security headers: Content‑Security‑Policy, X‑Content‑Type‑Options: nosniff, Referrer‑Policy, X‑Frame‑Options and set cookies with Secure, HttpOnly and SameSite flags.
- Disable or severely limit inline scripting and execution of potentially unsafe markup (SVG animations, inline event handlers) in rendered mail content.
Content‑Security‑Policy example (recommended baseline)
Content-Security-Policy: default-src 'none'; script-src 'self'; connect-src 'self'; img-src 'self' data:; style-src 'self' 'unsafe-inline'; object-src 'none'; frame-ancestors 'none';
Explanation: This CSP restricts resources to the same origin wherever possible, disallows plugin content and prevents framing. It reduces the impact of injected scripts by blocking script execution from external sources and limiting external connections used for data exfiltration. Customize to fit legitimate assets used by your deployment (CDNs, analytics, etc.).
Sanitization example (PHP using HTMLPurifier)
// Defensive PHP example: sanitize HTML email bodies before rendering
require_once '/path/to/htmlpurifier/library/HTMLPurifier.auto.php';
$config = HTMLPurifier_Config::createDefault();
$config->set('HTML.SafeIframe', false);
$config->set('URI.SafeIframeRegexp', '%^https?://(www\.)?trusted-domain\.com/%'); // if needed
$config->set('HTML.ForbiddenElements', ['script', 'iframe', 'object']);
$purifier = new HTMLPurifier($config);
$clean_html = $purifier->purify($raw_message_html);
echo $clean_html; // safely render
Explanation: HTMLPurifier is a robust library that performs context‑aware sanitization and removes disallowed tags and attributes. The example forbids , and
Secure cookie settings (PHP example)
// Ensure session cookies are secure
session_set_cookie_params([
'lifetime' => 0,
'path' => '/',
'domain' => 'example.com',
'secure' => true,
'httponly' => true,
'samesite' => 'Lax'
]);
session_start();
Explanation: Marking cookies Secure and HttpOnly prevents easy theft via network and prevents access from JavaScript. SameSite reduces risk of CSRF and cross‑site leaking of cookies. Adjust domain and samesite mode for your environment.
Secure development practices to prevent XSS
- Escape output in the correct context: HTML element content, attribute, JavaScript, URL, CSS each require different encoding.
- Prefer whitelisting over blacklisting when validating or filtering user input and stored content.
- Use established libraries for HTML sanitization and templating engines that auto‑escape by default.
- Perform security reviews for code that handles message rendering, attachments and rich content parsing.
Incident response checklist
- Isolate affected hosts and preserve forensic evidence (application logs, mail store snapshots, webserver logs).
- Identify impacted accounts and invalidate sessions/tokens for those users.
- Rotate credentials and secrets that may have been exposed.
- Scan mail storage for similar malicious messages and quarantine or delete them.
- Notify users and, if relevant, follow legal/regulatory notification obligations.
Testing and audit recommendations
- Perform authenticated and unauthenticated scans of your Roundcube deployment using reputable scanners and manual review.
- Include XSS test cases in your application security testing, but avoid storing actual exploit payloads in production environments.
- Deploy CSP reporting (report-uri / report-to) to gather runtime violations that may indicate exploitation attempts.
Responsible disclosure, CVE handling and follow‑up
If you discover similar vulnerabilities, follow a responsible disclosure process: privately notify the vendor (Roundcube) and coordinate on a timeline for a patch and disclosure. Ensure CVE assignment and public advisory include remediation steps and detection guidance so administrators can respond quickly.
Summary
CVE‑2024‑37383 is a stored XSS in Roundcube Webmail affecting certain older releases. Administrators must prioritize upgrading to patched builds, apply hardening controls such as strict CSP and robust HTML sanitization, and follow incident response practices if compromise is suspected. Defending mail systems requires layered controls: patch management, content sanitization, secure headers and active monitoring.