Skip to main content
Menu
Advisories

go-guerrilla crashes on a bare XCLIENT command (7-byte slice off-by-one panic)

GHSA-HGHQ-53P7-C582Published Updated GitHub

Description

An off-by-one slice index (CWE-193, CWE-129) in the XCLIENT command handler gives an uncaught panic (CWE-248) and takes the whole daemon down (CWE-400). One unauthenticated packet is enough. It is gated by the non-default xclient_on config, the same gating class as CVE-2025-31135, which needed proxyon.

Confirmed at HEAD. In server.go, cmdXCLIENT = []byte("XCLIENT") is 7 bytes (line 78), so the dispatch match cmdXCLIENT.match(cmd) only guarantees len(input) >= 7. The handler then slices input[8:] at line 586:

case sc.XClientOn && cmdXCLIENT.match(cmd):
    if toks := bytes.Split(input[8:], []byte{' '}); len(toks) > 0 {   // line 586

A client sending the bare command XCLIENT, exactly 7 bytes, hits input[8:7] and panics with runtime error: slice bounds out of range [8:7]. handleClient runs in the per-connection goroutine at server.go:391, which has no recover(). The only recover() calls live in the backend mail-processing workers, a different goroutine that command parsing never reaches, so the panic goes unrecovered and the SMTP daemon dies with it.

To reproduce, connect to the SMTP port and send XCLIENT\r\n. A bare LF works too, and no HELO is needed. The precondition is xclient_on: true, which is off by default but is the documented setup for an nginx-fronted deployment, and go-guerrilla does not restrict who may send XCLIENT. So the attacker is any unauthenticated client that can reach the SMTP port.

I verified this by driving the real server.handleClient with XClientOn=true over the test suite's mock net.Conn. The bare XCLIENT panics with that exact out-of-bounds error, and the negative control, XCLIENT followed by a trailing space to make 8 bytes, returns 250 without panicking. The upstream TestXClient covers XCLIENT ADDR=... and XCLIENT c but never the bare 7-byte form, which is the missing regression case. I re-confirmed at HEAD that cmdXCLIENT is 7 bytes at server.go:78, that the handler slices input[8:] at server.go:586, and that handleClient at server.go:391 has no recover. I did not stand up a standalone daemon on a real socket to watch the OS-level process exit, so that last step rests on the mock conn plus the traced absence of a recover.

For a fix, guard the slice against the exact-verb-length case. Requiring len(input) > len(cmdXCLIENT)+1 before input[8:] would do it, or slice at the verb length and trim. A recover in the per-connection handleClient loop would also keep any remaining command-parse panic confined to the one connection.

The rest of the parsing looked sound to me. The rfc5321 recursive-descent parser for MAIL, RCPT, HELO, EHLO and addresses is bounds-safe, since next() and peek() return 0 at EOF, and the line, size and recipient caps are enforced. Every other command arm slices exactly at its verb length, so XCLIENT is the only off-by-one.

I checked the repo advisories, OSV, NVD and the global GitHub database, and found no vendor CNA. The PROXY-header IP-spoof bug (CVE-2025-31135, fixed in v1.6.7) is the only published advisory here, and I found no existing advisory, issue or pull request covering this XCLIENT panic.

I used AI assistance while investigating this.

Affected versions

References

GitHub · phires/go-guerrilla