Nilhcem/FakeSMTP

Crash in FakeSMTP server when using C# SmtpClient with Authentication

Opened this issue · 2 comments

When I try an authenticated session to FakeSMTP server using a C# SmtpClient, the server crashes:

17 Dec 2013 12:09:42 INFO org.subethamail.smtp.server.SMTPServer - SMTP server *:25 starting
17 Dec 2013 12:09:42 INFO org.subethamail.smtp.server.ServerThread - SMTP server *:25 started
17 Dec 2013 12:10:01 DEBUG org.subethamail.smtp.server.Session - SMTP connection from localhost/127.0.0.1, new connection count: 1
17 Dec 2013 12:10:01 DEBUG org.subethamail.smtp.server.Session - Server: 220 build-cct.sal-eng.nl ESMTP SubEthaSMTP null
17 Dec 2013 12:10:01 DEBUG org.subethamail.smtp.server.Session - Client: EHLO build-cct
17 Dec 2013 12:10:01 DEBUG org.subethamail.smtp.server.Session - Server: 250-build-cct.sal-eng.nl
250-8BITMIME
250-AUTH LOGIN
250 Ok
17 Dec 2013 12:10:01 DEBUG org.subethamail.smtp.server.Session - Client: AUTH login aWtrZQ==
17 Dec 2013 12:10:01 DEBUG org.subethamail.smtp.server.Session - Server: 334 VXNlcm5hbWU6
17 Dec 2013 12:10:01 DEBUG org.subethamail.smtp.server.Session - Server: 334 UGFzc3dvcmQ6
17 Dec 2013 12:10:01 ERROR org.subethamail.smtp.server.Session - Unexpected error in the SMTP handler thread
java.lang.NullPointerException: null
at org.subethamail.smtp.command.AuthCommand.execute(AuthCommand.java:88) ~[fakeSMTP-1.5.jar:na]
at org.subethamail.smtp.server.RequireTLSCommandWrapper.execute(RequireTLSCommandWrapper.java:27) ~[fakeSMTP-1.5.jar:na]
at org.subethamail.smtp.server.CommandHandler.handleCommand(CommandHandler.java:98) ~[fakeSMTP-1.5.jar:na]
at org.subethamail.smtp.server.Session.runCommandLoop(Session.java:222) ~[fakeSMTP-1.5.jar:na]
at org.subethamail.smtp.server.Session.run(Session.java:125) ~[fakeSMTP-1.5.jar:na]
17 Dec 2013 12:10:01 DEBUG org.subethamail.smtp.server.Session - Server: 421 4.3.0 Mail system failure, closing transmission channel

17 Dec 2013 12:10:01 ERROR com.nilhcem.fakesmtp.core.exception.UncaughtExceptionHandler -
java.lang.NullPointerException: null
at org.subethamail.smtp.command.AuthCommand.execute(AuthCommand.java:88) ~[fakeSMTP-1.5.jar:na]
at org.subethamail.smtp.server.RequireTLSCommandWrapper.execute(RequireTLSCommandWrapper.java:27) ~[fakeSMTP-1.5.jar:na]
at org.subethamail.smtp.server.CommandHandler.handleCommand(CommandHandler.java:98) ~[fakeSMTP-1.5.jar:na]
at org.subethamail.smtp.server.Session.runCommandLoop(Session.java:222) ~[fakeSMTP-1.5.jar:na]
at org.subethamail.smtp.server.Session.run(Session.java:125) ~[fakeSMTP-1.5.jar:na]

Maybe this is because the C# SmtpClient uses the following authentication:

However, there exists a different, RFC compliant version of this behavior, where the client initially sends the userid already with the AUTH LOGIN method:

C: AUTH LOGIN ZHVtbXk=
S: 334 UGFzc3dvcmQ6
C: Z2VoZWlt

Hi,

Good catch, the server always returns "334 VXNlcm5hbWU6" (Username:), while, in this case, it should directly return "334 UGFzc3dvcmQ6" (Password:), as user already sent his userid with the AUTH LOGIN - Issue should be located in the com.nilhcem.fakesmtp.server.SMTPAuthHandler.auth() method and it may be easy to solve.

However I have difficulties to reproduce the crash, do you have a way (binary of the C# client that makes it crash / telnet commands to input) to reproduce easily?

Thanks,