Skip to content

Commit 9f58cb6

Browse files
committed
auth: Actually check SASL identity argument before using it
Fixes GHSA-4g76-w3xw-2x6w.
1 parent ac4a75b commit 9f58cb6

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

internal/auth/sasl.go

+3
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ func (s *SASLAuth) CreateSASL(mech string, remoteAddr net.Addr, successCb func(i
8181
if identity == "" {
8282
identity = username
8383
}
84+
if identity != username {
85+
return ErrInvalidAuthCred
86+
}
8487

8588
err := s.AuthPlain(username, password)
8689
if err != nil {

internal/auth/sasl_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,13 @@ func TestCreateSASL(t *testing.T) {
7575

7676
t.Run("PLAIN with authorization identity", func(t *testing.T) {
7777
srv := a.CreateSASL("PLAIN", &net.TCPAddr{}, func(id string) error {
78-
if id != "user1a" {
78+
if id != "user1" {
7979
t.Fatal("Wrong authorization identity passed:", id)
8080
}
8181
return nil
8282
})
8383

84-
_, _, err := srv.Next([]byte("user1a\x00user1\x00aa"))
84+
_, _, err := srv.Next([]byte("user1\x00user1\x00aa"))
8585
if err != nil {
8686
t.Error("Unexpected error:", err)
8787
}

0 commit comments

Comments
 (0)