Stalwart: Reflected XSS in the Autoconfig Endpoint via the emailaddress Parameter

The autoconfig endpoint for mail clients reflects the emailaddress parameter into its XML document without escaping; a crafted link executes JavaScript in the origin of the mail server in the victim's browser.

Advisory ID: TP-2026-139
Product: Stalwart (open-source mail and collaboration server with SMTP, IMAP, JMAP, CalDAV, CardDAV and WebDAV)
Vulnerability type: Reflected cross-site scripting in the XML document of the autoconfig endpoint (CWE-79)
CVE: not requested
CVSS 3.1: 6.1 (Medium) · CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N
Affected versions: up to and including v0.16.27 (verified live: v0.16.22)
Fixed in: v1.0.0
Reported: 17 September 2026

Summary

Stalwart is an open-source mail and collaboration server and delivers server settings to mail clients as XML through an autoconfig endpoint. The endpoint copies the query parameter emailaddress and the domain derived from it into the document without escaping. The browser processes the response as XML, and an injected element in the XHTML namespace runs as script. The endpoint is reachable without authentication. An attacker who gets a victim to open a crafted link executes JavaScript in the origin of the mail server.

Root cause

Line numbers refer to v0.16.22. crates/common/src/network/autoconfig/legacy_autoconfig.rs reads emailaddress from the query (:19-22) and derives domain from the part after the last @ (:24-30).
Both values are written into the XML through writeln! without escaping, emailaddress in three places (:37, :60, :82) and domain in four (:35, :36, :40, :96), two of them inside attributes.
The project ships an XML escaper and uses it in its WebDAV responses (crates/dav-proto/src/responses/mod.rs:33-48), but does not call it in this endpoint.
The response has the type application/xml and carries neither a Content Security Policy nor X-Content-Type-Options, so Blink and Gecko execute an element in the XHTML namespace as script.
Three unauthenticated routes reach the same code: /mail/config-v1.1.xml, /.well-known/mail-v1.xml and /.well-known/autoconfig/mail/config-v1.1.xml.

Proof of Concept

Schematically:

GET /mail/config-v1.1.xml?emailaddress=x@<payload> HTTP/1.1
Host: <mailserver>

Payload (URL-encoded): markup that leaves the surrounding XML context and inserts an element
<script xmlns="http://www.w3.org/1999/xhtml">...</script>

The part after the @ is treated as the domain and lands in the document without escaping; the browser parses the response as XML and executes the script element in the XHTML namespace. Verified on v0.16.22 in the default configuration in two browser engines (Blink and Gecko), with location.origin equal to the mail server origin.

Impact

  • JavaScript execution in the origin of the mail server after one click on a crafted link, without an account and without knowledge of the target domain.
  • Requests from that origin to the web interface and the APIs of the server in the victim's context.
  • A link opened in a new tab does not read a session token because the web interface keeps it in sessionStorage; the rating therefore sets confidentiality and integrity to low.

References

Is Something Like This in Your Software?

Our team found this vulnerability during its work. Have your applications tested by the same specialists, with a penetration test from turingpoint.