Skip to content

Commit c28f507

Browse files
committed
Add SMTP smuggling test
1 parent cd06f48 commit c28f507

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

server_test.go

+31
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,37 @@ func TestServer_tooLongMessage(t *testing.T) {
733733
}
734734
}
735735

736+
// See https://www.postfix.org/smtp-smuggling.html
737+
func TestServer_smtpSmuggling(t *testing.T) {
738+
be, s, c, scanner := testServerAuthenticated(t)
739+
defer s.Close()
740+
741+
io.WriteString(c, "MAIL FROM:<[email protected]>\r\n")
742+
scanner.Scan()
743+
io.WriteString(c, "RCPT TO:<[email protected]>\r\n")
744+
scanner.Scan()
745+
io.WriteString(c, "DATA\r\n")
746+
scanner.Scan()
747+
748+
io.WriteString(c, "This is a message with an SMTP smuggling dot:\r\n")
749+
io.WriteString(c, ".\n")
750+
io.WriteString(c, "Final dot comes after.\r\n")
751+
io.WriteString(c, ".\r\n")
752+
scanner.Scan()
753+
if !strings.HasPrefix(scanner.Text(), "250 ") {
754+
t.Fatal("Invalid DATA response, expected an error but got:", scanner.Text())
755+
}
756+
757+
if len(be.messages) != 1 {
758+
t.Fatal("Invalid number of sent messages:", len(be.messages))
759+
}
760+
761+
msg := be.messages[0]
762+
if string(msg.Data) != "This is a message with an SMTP smuggling dot:\r\n\nFinal dot comes after.\r\n" {
763+
t.Fatalf("Invalid mail data: %q", string(msg.Data))
764+
}
765+
}
766+
736767
func TestServer_tooLongLine(t *testing.T) {
737768
_, s, c, scanner := testServerAuthenticated(t)
738769
defer s.Close()

0 commit comments

Comments
 (0)