Advisory

GHSA-r553-m4fv-5v97

Details, part 2 of 2. The advisory

Details

Impact

An unauthenticated client that can reach the SMTP listener can force Mailpit to allocate memory above the configured MaxMessageSize before rejection. Repeating the input across concurrent connections can create substantial memory pressure and degrade service availability. The issue is bounded by attacker bandwidth and host memory rather than by the configured message-size cap until a newline arrives and the delayed check runs.

Exploitability requires the SMTP listener to be reachable by an untrusted client. Typical Mailpit deployments confined to trusted internal networks, CI environments without untrusted SMTP access, or loopback-only access therefore have substantially lower practical risk. AV:N describes the network attack path in a reachable deployment; it does not imply that most Mailpit instances are exposed to the public Internet.

The PoV demonstrates substantial memory pressure but does not establish complete service loss. The advisory therefore uses Low availability impact (A:L), producing a CVSS 3.1 score of 5.3 (Medium).

Suggested Fix

Bound SMTP DATA line reads before buffering the full line. Replace unbounded ReadBytes('\n') with a reader that stops once len(data)+currentLineBytes would exceed srv.MaxSize, returns the existing 552 5.3.4 error, and drains or closes the connection without retaining the over-limit line. The check should account for dot-stuffing and the CRLF terminator, and should reject before allocating attacker-controlled bytes beyond the configured cap.

Regression tests should cover a normal small DATA message, a multi-line message exactly at the cap, and a single line over the cap. The over-cap single-line test should assert that Mailpit returns 552 5.3.4 without reading the whole line into a returned buffer or causing material RSS growth.

Affected Package/Versions

Confirmed affected:

  • v1.30.0, commit af8756a32cf7ecf06bef109c1348b783f1a239ee, source has the post-fix srv.MaxSize wiring and the same ReadBytes('\n') before size enforcement.
  • v1.30.3, commit 6acf5b8f942ab0e007b1227d31dfb3c3303e8d13, reproduces with the official Darwin ARM64 binary shown above.
  • Latest release v1.30.4, commit 3b41030dbef4574ec92b815cb464fec7b4cfdc15, published 2026-07-09, is source-confirmed with the same vulnerable ordering.
  • Current develop, commit 6a09f28d5489a85245cc8ddbf512047495627147, checked 2026-07-09, is source-confirmed with the same vulnerable ordering.

No fixed version was identified during this review.

A focused source sweep on 2026-07-09 returned the same ordering for the lower post-fix release, latest release, and current develop: internal/smtpd/main.go wires MaxMessageSize into srv.MaxSize, while internal/smtpd/smtpd.go still reads a full DATA line before enforcing that cap.

develop_head=6a09f28d5489a85245cc8ddbf512047495627147
v1.30.4_commit=3b41030dbef4574ec92b815cb464fec7b4cfdc15
v1.30.0_commit=af8756a32cf7ecf06bef109c1348b783f1a239ee

v1.30.0:internal/smtpd/main.go:250:	if config.MaxMessageSize > 0 {
v1.30.0:internal/smtpd/main.go:251:		srv.MaxSize = config.MaxMessageSize * 1024 * 1024
v1.30.0:internal/smtpd/smtpd.go:855:		line, err := s.br.ReadBytes('\n')
v1.30.0:internal/smtpd/smtpd.go:869:		if s.srv.MaxSize > 0 {
v1.30.0:internal/smtpd/smtpd.go:870:			if len(data)+len(line) > s.srv.MaxSize {
v1.30.0:internal/smtpd/smtpd.go:872:				return nil, maxSizeExceeded(s.srv.MaxSize)

v1.30.4:internal/smtpd/main.go:250:	if config.MaxMessageSize > 0 {
v1.30.4:internal/smtpd/main.go:251:		srv.MaxSize = config.MaxMessageSize * 1024 * 1024
v1.30.4:internal/smtpd/smtpd.go:878:		line, err := s.br.ReadBytes('\n')
v1.30.4:internal/smtpd/smtpd.go:892:		if s.srv.MaxSize > 0 {
v1.30.4:internal/smtpd/smtpd.go:893:			if len(data)+len(line) > s.srv.MaxSize {
v1.30.4:internal/smtpd/smtpd.go:895:				return nil, maxSizeExceeded(s.srv.MaxSize)

develop:internal/smtpd/main.go:250:	if config.MaxMessageSize > 0 {
develop:internal/smtpd/main.go:251:		srv.MaxSize = config.MaxMessageSize * 1024 * 1024
develop:internal/smtpd/smtpd.go:878:		line, err := s.br.ReadBytes('\n')
develop:internal/smtpd/smtpd.go:892:		if s.srv.MaxSize > 0 {
develop:internal/smtpd/smtpd.go:893:			if len(data)+len(line) > s.srv.MaxSize {
develop:internal/smtpd/smtpd.go:895:				return nil, maxSizeExceeded(s.srv.MaxSize)

Advisory History

The closest public advisory is GHSA-fpxj-m5q8-fphw, "Unauthenticated remote memory-exhaustion DoS via unlimited SMTP DATA and /api/v1/send body sizes." That advisory covered older versions where Server.MaxSize was not assigned, leaving SMTP DATA bodies unlimited. This report is the post-fix single-line gap: MaxSize is assigned and the message is eventually rejected, but one over-limit DATA line is still buffered before the cap runs.

Other published Mailpit advisories checked include GHSA-28pq-6qxg-wg5r for sibling HTTP JSON body limits, GHSA-54wq-72mp-cq7c for SMTP header injection, GHSA-w4vj-r5pg-3722 for proxy CSS map concurrency, GHSA-qx5x-85p8-vg4j for dump path traversal, the SSRF/link-check/proxy/html-check family, and GHSA-524m-q5m7-79mm for CSWSH. None describe this post-fix SMTP DATA line-buffering behavior.

GHSA-w878-pj84-3j5v and GHSA-75mr-qw9x-3r39 were published on 2026-07-09 and included in the v1.30.4 security release. GHSA-w878-pj84-3j5v caps SMTP command lines before DATA and POP3 command lines before message retrieval. It remains distinct from this post-DATA path: v1.30.4 still calls ReadBytes('\n') in readData() before comparing the complete line against MaxSize. GHSA-75mr-qw9x-3r39 bounds decoded thumbnail dimensions in the HTTP attachment handler, with a different boundary, sink, precondition, and fix surface.

The separate POP3 command-line draft was rejected and removed after GHSA-w878-pj84-3j5v and the v1.30.4 release established that the shared command-line fix covers both SMTP and POP3. That disposition does not cover this report: the affected path is SMTP readData() after DATA, remains present in v1.30.4, and requires a remaining-message or DATA-line bound rather than a command-reader cap.

Public issue searches for SMTP DATA line size and ReadBytes DATA MaxSize returned no matching issues. Public commit search for MaxSize ReadBytes returned no matching fix.

Sources & licences