Reply to calc: The Attack Chain to Compromise Mailspring
Mailspring's email renderer had a mutation XSS flaw where a crafted email could bypass HTML sanitisation and execute JavaScript when the victim replied to or forwarded it. Combined with an unsafe Electron configuration and a CSP misconfiguration, this allowed arbitrary OS command execution on the victim's machine.
Published on sonarsource.com
Mailspring, formerly known as nylas-mail, is a popular email client application that gives users a fast and efficient way to manage their email accounts. It is a free and open-source program for Windows, Mac, and Linux operating systems.
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
The sanitizer replaced disallowed tags after parsing but continued using the same DOM tree, so the output re-parsed differently (mXSS), and the Electron window had nodeIntegration enabled with contextIsolation disabled plus a permissive CSP.
Impact
An attacker could execute arbitrary OS commands on the victim's machine when the victim replies to or forwards a malicious email; version 1.11.0 added mitigations but the underlying vulnerability was not fixed.
What the attacker needed
Victim uses Mailspring before 1.11.0; victim views a malicious email; victim replies to or forwards the email; attacker controls a CSS exfiltration server
How it was found
- Attacker sets up a CSS exfiltration server.
- Attacker sends an email with the CSS exfiltration payload and an inline image that is actually a malicious HTML page.
- When the victim views the email, the payload image path is extracted.
- Attacker sends a second email with the mXSS payload pointing to the extracted path.
- When a victim tries to reply or forward the message, a calculator will show up.
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.
When you open an email, the app cleans the HTML to remove dangerous code. A bug in that cleaning step let a cleverly crafted email sneak JavaScript past the filter. Because the email app also had weak security settings, that JavaScript could run commands on your computer.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.