Practical Exploitation of CVE-2024-42009 using Docker and Swaks
Roundcube 1.6.7 contains a stored XSS flaw where a regex in the html4inline() step desanitises HTML that was already cleaned by washtml, allowing an attacker to send an email that executes JavaScript when the victim opens it. The author reproduced this in a Docker lab by sending a raw email with Swaks, bypassing Roundcube's UI which otherwise modified the payload.
medium.com
Published on medium.com
It was just another day at work, Doing a web application security assessment. Running scans, reviewing endpoints, and validating findings.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely a flawed regex in the html4inline() function that strips legacy attributes from the body tag and can break already-sanitised HTML, turning a harmless payload into an active event handler.
Impact
An attacker could execute arbitrary JavaScript in the victim's browser when the victim opens a specially crafted email, though the author notes a pre-auth constraint prevented direct demonstration on the target.
What the attacker needed
Roundcube 1.6.7 vulnerable instance; Attacker can send email to victim; Victim opens the email
How it was found
- Set up a vulnerable Roundcube 1.6.7 instance and a mail server using Docker Compose on a shared network.
- Log in as an attacker and as a victim in separate sessions.
- Send an email containing a crafted HTML body from the attacker account.
- Open the email in the victim's inbox and observe that no JavaScript executes.
- Send the same payload as a raw email directly over SMTP using Swaks to bypass client-side modifications.
- Open the email again as the victim and observe the JavaScript alert executing.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
Roundcube is webmail software that cleans incoming HTML emails to remove dangerous code. A later step that reformats the email accidentally undid part of that cleaning, so a carefully crafted email could run JavaScript when opened. This lets an attacker run code in the victim's browser session.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.