Skip to content
XSS Write-up Intermediate

Multiple Cross-Site Scripting (XSS) Vulnerabilities in Mailcow

Three stored cross-site scripting flaws in Mailcow let unauthenticated attackers inject HTML into admin-visible data (Autodiscover logs, quarantine attachment filenames, and login history IPs). When an administrator viewed the affected pages, attacker JavaScript ran in the Mailcow origin, allowing mailbox access and instance reconfiguration; the third flaw was escalated via login CSRF to steal a victim's emails.

aikido.dev

Published on aikido.dev

Mailcow is a widely used self-hosted and open source email server that hosts everything you'd need to manage mailboxes yourself. To assess its security, we set up a local instance and ran our AI pentesting agents against it.

The author, on aikido.dev

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 application concatenated user-controlled values into HTML strings in JavaScript without escaping them, so the browser interpreted the data as markup and script.

Impact

An attacker could run JavaScript in the Mailcow origin when an admin viewed the affected pages, potentially reading any user's mailbox and reconfiguring the instance; the third flaw could additionally let an attacker read a victim's emails after a login CSRF and two clicks, though it required the victim to open extra tabs.

What the attacker needed

No authentication for first two flaws; admin views logs or quarantine; quarantine feature enabled; victim visits malicious page

The fix

The issues were fixed by adding escapeHtml() calls around the affected values before rendering them.

How it was found

  1. Send an unauthenticated Autodiscover request with a malicious email address so it is written to the logs.
  2. Wait for an administrator to open the Autodiscover logs page, where the unescaped email address is rendered and the script runs.
  3. For the quarantine flaw, send an email with an attachment whose filename contains HTML and whose content is the EICAR test string so it is quarantined.
  4. Have an administrator open the quarantine item, where the unescaped filename is rendered and the script runs.
  5. For the login-history flaw, log in while setting a fake X-Real-IP header containing HTML so the payload is stored in the attacker's login history.
  6. Use a cross-site form to log a victim into the attacker's account, redirect to the user page to trigger the stored script, and use the opener reference to read the victim's still-open mailbox.

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.

Cross-site scripting (XSS) is when a website displays text from an untrusted source without making it safe, so the browser treats it as code and runs it. Here, an attacker could put a small script into an email address, a filename, or a fake IP address; when an admin opened the logs or quarantine page, that script ran with the admin's powers. The third bug also used a login form trick to make a victim's browser log into the attacker's account, then read the victim's still-open mailbox.

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.