Stalwart: Memory Exhaustion via Empty Quoted Strings in the IMAP Parser Before Login
The IMAP parser does not charge empty quoted strings "" to the size of a request; an unauthenticated client makes a single request grow without bound and exhausts the server's memory.
Advisory ID: TP-2026-140
Product: Stalwart (open-source mail and collaboration server with SMTP, IMAP, JMAP, CalDAV, CardDAV and WebDAV)
Vulnerability type: Allocation of resources without limits in the IMAP parser (CWE-770)
CVE: not requested
CVSS 3.1: 7.5 (High) · CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
Affected versions: up to and including v1.1.0 (verified: v1.1.0; the same pattern in the source of v0.16.22, v0.16.27 and v1.0.0)
Fixed in: v1.1.1
Reported: 16 November 2026
Summary
Stalwart is an open-source mail and collaboration server. Its IMAP parser limits the size of a request, to 64 KiB before login, and counts the bytes of the arguments for that purpose. For an empty quoted string "" the parser creates a token but charges nothing to the request size. The limit therefore never triggers, and the token list of a single request grows for as long as the client sends empty quoted strings. An unauthenticated attacker exhausts the server's memory this way. The vendor confirmed the bug and found the same pattern after login while fixing it.
Root cause
Line numbers refer to v1.1.0. push_argument charges a non-empty argument to current_request_size and compares it with max_request_size (crates/imap-proto/src/receiver.rs:230-234), whereas the branch for the empty quoted string appends Token::Nil without increasing the counter (crates/imap-proto/src/receiver.rs:238-240).
The parser reaches this branch at every closing quote of an empty quoted string (crates/imap-proto/src/receiver.rs:516), and push_request_token appends the token to the token list of the request without a check of its own (crates/imap-proto/src/receiver.rs:222-227).
Before login the session works with MAX_UNAUTHENTICATED_REQUEST_SIZE of 64 KiB (crates/imap-proto/src/receiver.rs:86, crates/imap/src/core/session.rs:144), but a sequence of empty quoted strings never gets closer to that limit.
After login, ( and other one-byte tokens count as one byte only (crates/imap-proto/src/receiver.rs:275-280), although each token takes about 40 bytes in memory according to the vendor.
A single request therefore holds roughly 40 times the configured limit.
Proof of Concept
Schematically:
a1 LOGIN "" "" "" "" "" "" "" "" ... (continued for any length without a line ending)
Each empty quoted string creates a token in the token list of the request in progress, the request size counter stays unchanged, and without a line ending the request is never completed. Since v1.1.1 the parser charges every token at its in-memory size; according to the vendor such a sequence before login now ends with an error after about 1,600 tokens.
Impact
- Memory exhaustion through the IMAP port without an account and without credentials.
- IMAP runs in the same process as the other protocols; a termination due to memory shortage affects all services of the server.
- After login, a single request made of one-byte tokens holds roughly 40 times the configured request limit in memory.
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.
