Government Emails at Risk: Critical Cross-Site Scripting Vulnerability in Roundcube Webmail
Roundcube webmail contained cross-site scripting flaws: a desanitisation bug where post-sanitisation HTML rewriting could reintroduce event-handler attributes, and unsafe attachment Content-Types that let an attacker serve active content inline. An attacker could send a crafted email and, once the victim viewed it, run JavaScript in the webmail origin to steal emails, contacts and the password, and register a persistent service worker.
Published on sonarsource.com
Roundcube is a popular open-source webmail software that enables users to check their emails right in their browser without needing dedicated client software. It is included by default in the server hosting panel cPanel leading to millions of installations around the globe, according to Shodan.
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 the sanitised HTML was modified afterwards by a faulty regex that removed an uneven number of quotes, and attachments were served inline with attacker-controlled MIME types.
Impact
An attacker could steal emails, contacts and the victim's email password, send mail from the account, and keep a persistent service worker; the text notes no CSP or sandboxed iframe limited the exploit.
What the attacker needed
Victim views a crafted email; for CVE-2024-42008, victim clicks a link; attacker can send email to victim
The fix
It was fixed by moving the legacy-attribute conversion into the sanitiser, converting dangerous MIME types to plain text with a restrictive CSP on attachments, and tightening the CSS filter.
How it was found
- The attacker sends an email whose body contains markup crafted to survive sanitisation and break out during the later inline conversion.
- The victim opens the email in Roundcube, and the rewritten HTML executes script in the webmail origin.
- For the attachment route, the attacker uses a CSS filter bypass to leak the attachment UID from a link on the page.
- The attacker overlays a link so a click goes to their server, which redirects to the malicious attachment and triggers the payload.
- The attacker registers a service worker from an attachment URL to persist across page loads and browser restarts.
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.
Webmail shows HTML from strangers, so it cleans that HTML first to stop scripts running. Here the cleaning was undone by later code that rewrote the page, and attachments could be shown in a way the browser treats as a program. The result is that opening an email could let someone else's code act as the logged-in user.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.