Skip to content
XSS Write-up Intermediate

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.

Zaid Arif, on medium.com

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

  1. Set up a vulnerable Roundcube 1.6.7 instance and a mail server using Docker Compose on a shared network.
  2. Log in as an attacker and as a victim in separate sessions.
  3. Send an email containing a crafted HTML body from the attacker account.
  4. Open the email in the victim's inbox and observe that no JavaScript executes.
  5. Send the same payload as a raw email directly over SMTP using Swaks to bypass client-side modifications.
  6. 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.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.