You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-user@james.apache.org by Günter Paul <gp...@guenterpaul.de> on 2023/06/07 08:12:31 UTC
Attack on the James Server
I run a James mail server (james-server-spring-app-3.8.0). The log file shows that the server is constantly being attacked. This is normal, the server is on the Internet.
I was able to fend off some of the attacks via the firewall: blocking IP addresses or limiting access per minute (connect).
Now 2 attacks remain. In both cases there is a “connect”, then many actions, then the connection is closed. The IP addresses change constantly. In the "smtpserver.xml" file, I tried to reduce the number of accesses via "MaxRcptHandler", but unfortunately that doesn't work here.
Are there any out of the box options to configure something?
Here are the concrete examples from the log file (domaine.de is a dummy for my domaine)
1) Rejected message. Unknown user
INFO | jvm 1 | 2023/06/06 23:55:45 | 06-Jun-2023 23:55:45.837 INFO [smtpserver-io-3] org.apache.james.protocols.netty.BasicChannelInboundHandler.channelActive:103 - Connection established from 60.29.127.226
INFO | jvm 1 | 2023/06/06 23:55:50 | 06-Jun-2023 23:55:50.400 INFO [smtpserver-io-3] org.apache.james.protocols.smtp.core.fastfail.AbstractValidRcptHandler.reject:61 - Rejected message. Unknown user: darger@domaine.de
INFO | jvm 1 | 2023/06/06 23:55:50 | 06-Jun-2023 23:55:50.400 INFO [smtpserver-io-3] org.apache.james.protocols.smtp.core.log.HookResultLogger.onHookResult:45 - org.apache.james.smtpserver.fastfail.ValidRcptHandler: result= (DENY CONNECTED)
INFO | jvm 1 | 2023/06/06 23:55:50 | 06-Jun-2023 23:55:50.401 INFO [smtpserver-io-3] org.apache.james.protocols.smtp.core.fastfail.AbstractValidRcptHandler.reject:61 - Rejected message. Unknown user: danielle.x@domaine.de
INFO | jvm 1 | 2023/06/06 23:55:50 | 06-Jun-2023 23:55:50.401 INFO [smtpserver-io-3] org.apache.james.protocols.smtp.core.log.HookResultLogger.onHookResult:45 - org.apache.james.smtpserver.fastfail.ValidRcptHandler: result= (DENY CONNECTED)
… (202 lines in total )
INFO | jvm 1 | 2023/06/06 23:55:50 | 06-Jun-2023 23:55:50.470 INFO [smtpserver-io-3] org.apache.james.protocols.smtp.core.fastfail.AbstractValidRcptHandler.reject:61 - Rejected message. Unknown user: upoz3f3sx7nx@domaine.de
INFO | jvm 1 | 2023/06/06 23:55:50 | 06-Jun-2023 23:55:50.471 INFO [smtpserver-io-3] org.apache.james.protocols.smtp.core.log.HookResultLogger.onHookResult:45 - org.apache.james.smtpserver.fastfail.ValidRcptHandler: result= (DENY CONNECTED)
INFO | jvm 1 | 2023/06/06 23:55:51 | 06-Jun-2023 23:55:51.408 INFO [smtpserver-io-3] org.apache.james.protocols.netty.BasicChannelInboundHandler.channelInactive:143 - Connection closed for 60.29.127.226/60.29.127.226:50151
2) Password is unverified
INFO | jvm 1 | 2023/06/06 23:44:49 | 06-Jun-2023 23:44:49.108 INFO [smtpserver-io-2] org.apache.james.protocols.netty.BasicChannelInboundHandler.channelActive:103 - Connection established from 45.133.235.202
INFO | jvm 1 | 2023/06/06 23:44:49 | 06-Jun-2023 23:44:49.333 INFO [smtpserver-io-2] org.apache.james.user.lib.UsersRepositoryImpl.lambda$test$2:155 - Could not retrieve user Username{localPart=root, domainPart=Optional[Domain : domaine.de]}. Password is unverified.
INFO | jvm 1 | 2023/06/06 23:44:49 | 06-Jun-2023 23:44:49.333 INFO [smtpserver-io-2] org.apache.james.protocols.smtp.core.esmtp.AuthCmdHandler.doAuthTest:397 - AUTH method LOGIN failed from Username{localPart=root, domainPart=Optional[Domain : domaine.de]}@45.133.235.202
INFO | jvm 1 | 2023/06/06 23:44:49 | 06-Jun-2023 23:44:49.512 INFO [smtpserver-io-2] org.apache.james.user.lib.UsersRepositoryImpl.lambda$test$2:155 - Could not retrieve user Username{localPart=root, domainPart=Optional[Domain : domaine.de]}. Password is unverified.
INFO | jvm 1 | 2023/06/06 23:44:49 | 06-Jun-2023 23:44:49.512 INFO [smtpserver-io-2] org.apache.james.protocols.smtp.core.esmtp.AuthCmdHandler.doAuthTest:397 - AUTH method LOGIN failed from Username{localPart=root, domainPart=Optional[Domain : domaine.de]}@45.133.235.202
… (408 lines in total )
INFO | jvm 1 | 2023/06/06 23:45:25 | 06-Jun-2023 23:45:25.286 INFO [smtpserver-io-2] org.apache.james.user.lib.UsersRepositoryImpl.lambda$test$2:155 - Could not retrieve user Username{localPart=root, domainPart=Optional[Domain : domaine.de]}. Password is unverified.
INFO | jvm 1 | 2023/06/06 23:45:25 | 06-Jun-2023 23:45:25.286 INFO [smtpserver-io-2] org.apache.james.protocols.smtp.core.esmtp.AuthCmdHandler.doAuthTest:397 - AUTH method LOGIN failed from Username{localPart=root, domainPart=Optional[Domain : domaine.de]}@45.133.235.202
INFO | jvm 1 | 2023/06/06 23:45:25 | 06-Jun-2023 23:45:25.330 INFO [smtpserver-io-2] org.apache.james.protocols.netty.BasicChannelInboundHandler.channelInactive:143 - Connection closed for 45.133.235.202/45.133.235.202:57554
Does anyone know solutions to these problems?
Best wishes, Günter
--
Günter Paul
---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org
Re: Attack on the James Server
Posted by Günter Paul <gp...@guenterpaul.de>.
Hello Karsten,
thanks for the tip. I tried it but it doesn't work.
It seems that "verifyFailureDelay" only works for an identical user login. Here is a connection and then an attempt with different users to log in. There is no delay between registrations. It would be good if a connection was closed after three attempts.
Best wishes
Günter
> Karsten Otto <ka...@akquinet.de.invalid> hat am 07.06.2023 10:36 CEST geschrieben:
>
>
> There is a property named verifyFailureDelay that you can set in
> usersrepository.xml. The value is a time to wait between unsuccessful
> authentication attempts, e.g. 2s to wait 2 seconds.
>
> You won't get rid of the attacks this way, but slow down any brute force
> attempts to guess valid user passwords. Hopefully to a point where it
> does not make sense anymore and the attacker just gives up.
>
> On the other hand, a long delay could clog up your mail server and
> prevent legitimate users from accesssing it, so you may need to
> experiment with the settings a bit.
>
> Good luck,
> Karsten
>
> On 07.06.23 10:12 AM, Günter Paul wrote:
> > I run a James mail server (james-server-spring-app-3.8.0). The log file shows that the server is constantly being attacked. This is normal, the server is on the Internet.
> >
> > I was able to fend off some of the attacks via the firewall: blocking IP addresses or limiting access per minute (connect).
> >
> > Now 2 attacks remain. In both cases there is a “connect”, then many actions, then the connection is closed. The IP addresses change constantly. In the "smtpserver.xml" file, I tried to reduce the number of accesses via "MaxRcptHandler", but unfortunately that doesn't work here.
> >
> > Are there any out of the box options to configure something?
> >
> > Here are the concrete examples from the log file (domaine.de is a dummy for my domaine)
> >
> > 1) Rejected message. Unknown user
> >
> > INFO | jvm 1 | 2023/06/06 23:55:45 | 06-Jun-2023 23:55:45.837 INFO [smtpserver-io-3] org.apache.james.protocols.netty.BasicChannelInboundHandler.channelActive:103 - Connection established from 60.29.127.226
> > INFO | jvm 1 | 2023/06/06 23:55:50 | 06-Jun-2023 23:55:50.400 INFO [smtpserver-io-3] org.apache.james.protocols.smtp.core.fastfail.AbstractValidRcptHandler.reject:61 - Rejected message. Unknown user: darger@domaine.de
> > INFO | jvm 1 | 2023/06/06 23:55:50 | 06-Jun-2023 23:55:50.400 INFO [smtpserver-io-3] org.apache.james.protocols.smtp.core.log.HookResultLogger.onHookResult:45 - org.apache.james.smtpserver.fastfail.ValidRcptHandler: result= (DENY CONNECTED)
> > INFO | jvm 1 | 2023/06/06 23:55:50 | 06-Jun-2023 23:55:50.401 INFO [smtpserver-io-3] org.apache.james.protocols.smtp.core.fastfail.AbstractValidRcptHandler.reject:61 - Rejected message. Unknown user: danielle.x@domaine.de
> > INFO | jvm 1 | 2023/06/06 23:55:50 | 06-Jun-2023 23:55:50.401 INFO [smtpserver-io-3] org.apache.james.protocols.smtp.core.log.HookResultLogger.onHookResult:45 - org.apache.james.smtpserver.fastfail.ValidRcptHandler: result= (DENY CONNECTED)
> >
> > … (202 lines in total )
> >
> > INFO | jvm 1 | 2023/06/06 23:55:50 | 06-Jun-2023 23:55:50.470 INFO [smtpserver-io-3] org.apache.james.protocols.smtp.core.fastfail.AbstractValidRcptHandler.reject:61 - Rejected message. Unknown user: upoz3f3sx7nx@domaine.de
> > INFO | jvm 1 | 2023/06/06 23:55:50 | 06-Jun-2023 23:55:50.471 INFO [smtpserver-io-3] org.apache.james.protocols.smtp.core.log.HookResultLogger.onHookResult:45 - org.apache.james.smtpserver.fastfail.ValidRcptHandler: result= (DENY CONNECTED)
> > INFO | jvm 1 | 2023/06/06 23:55:51 | 06-Jun-2023 23:55:51.408 INFO [smtpserver-io-3] org.apache.james.protocols.netty.BasicChannelInboundHandler.channelInactive:143 - Connection closed for 60.29.127.226/60.29.127.226:50151
> >
> >
> > 2) Password is unverified
> >
> > INFO | jvm 1 | 2023/06/06 23:44:49 | 06-Jun-2023 23:44:49.108 INFO [smtpserver-io-2] org.apache.james.protocols.netty.BasicChannelInboundHandler.channelActive:103 - Connection established from 45.133.235.202
> > INFO | jvm 1 | 2023/06/06 23:44:49 | 06-Jun-2023 23:44:49.333 INFO [smtpserver-io-2] org.apache.james.user.lib.UsersRepositoryImpl.lambda$test$2:155 - Could not retrieve user Username{localPart=root, domainPart=Optional[Domain : domaine.de]}. Password is unverified.
> > INFO | jvm 1 | 2023/06/06 23:44:49 | 06-Jun-2023 23:44:49.333 INFO [smtpserver-io-2] org.apache.james.protocols.smtp.core.esmtp.AuthCmdHandler.doAuthTest:397 - AUTH method LOGIN failed from Username{localPart=root, domainPart=Optional[Domain : domaine.de]}@45.133.235.202
> > INFO | jvm 1 | 2023/06/06 23:44:49 | 06-Jun-2023 23:44:49.512 INFO [smtpserver-io-2] org.apache.james.user.lib.UsersRepositoryImpl.lambda$test$2:155 - Could not retrieve user Username{localPart=root, domainPart=Optional[Domain : domaine.de]}. Password is unverified.
> > INFO | jvm 1 | 2023/06/06 23:44:49 | 06-Jun-2023 23:44:49.512 INFO [smtpserver-io-2] org.apache.james.protocols.smtp.core.esmtp.AuthCmdHandler.doAuthTest:397 - AUTH method LOGIN failed from Username{localPart=root, domainPart=Optional[Domain : domaine.de]}@45.133.235.202
> >
> > … (408 lines in total )
> >
> > INFO | jvm 1 | 2023/06/06 23:45:25 | 06-Jun-2023 23:45:25.286 INFO [smtpserver-io-2] org.apache.james.user.lib.UsersRepositoryImpl.lambda$test$2:155 - Could not retrieve user Username{localPart=root, domainPart=Optional[Domain : domaine.de]}. Password is unverified.
> > INFO | jvm 1 | 2023/06/06 23:45:25 | 06-Jun-2023 23:45:25.286 INFO [smtpserver-io-2] org.apache.james.protocols.smtp.core.esmtp.AuthCmdHandler.doAuthTest:397 - AUTH method LOGIN failed from Username{localPart=root, domainPart=Optional[Domain : domaine.de]}@45.133.235.202
> > INFO | jvm 1 | 2023/06/06 23:45:25 | 06-Jun-2023 23:45:25.330 INFO [smtpserver-io-2] org.apache.james.protocols.netty.BasicChannelInboundHandler.channelInactive:143 - Connection closed for 45.133.235.202/45.133.235.202:57554
> >
> >
> > Does anyone know solutions to these problems?
> >
> > Best wishes, Günter
> >
> >
--
Günter Paul
Hirschbachstraße 4a
53506 Ahrbrück
Tel.: +4926436747
Mobile: +491759140889
---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org
Re: Attack on the James Server
Posted by Karsten Otto <Ka...@akquinet.de.INVALID>.
There is a property named verifyFailureDelay that you can set in
usersrepository.xml. The value is a time to wait between unsuccessful
authentication attempts, e.g. 2s to wait 2 seconds.
You won't get rid of the attacks this way, but slow down any brute force
attempts to guess valid user passwords. Hopefully to a point where it
does not make sense anymore and the attacker just gives up.
On the other hand, a long delay could clog up your mail server and
prevent legitimate users from accesssing it, so you may need to
experiment with the settings a bit.
Good luck,
Karsten
On 07.06.23 10:12 AM, Günter Paul wrote:
> I run a James mail server (james-server-spring-app-3.8.0). The log file shows that the server is constantly being attacked. This is normal, the server is on the Internet.
>
> I was able to fend off some of the attacks via the firewall: blocking IP addresses or limiting access per minute (connect).
>
> Now 2 attacks remain. In both cases there is a “connect”, then many actions, then the connection is closed. The IP addresses change constantly. In the "smtpserver.xml" file, I tried to reduce the number of accesses via "MaxRcptHandler", but unfortunately that doesn't work here.
>
> Are there any out of the box options to configure something?
>
> Here are the concrete examples from the log file (domaine.de is a dummy for my domaine)
>
> 1) Rejected message. Unknown user
>
> INFO | jvm 1 | 2023/06/06 23:55:45 | 06-Jun-2023 23:55:45.837 INFO [smtpserver-io-3] org.apache.james.protocols.netty.BasicChannelInboundHandler.channelActive:103 - Connection established from 60.29.127.226
> INFO | jvm 1 | 2023/06/06 23:55:50 | 06-Jun-2023 23:55:50.400 INFO [smtpserver-io-3] org.apache.james.protocols.smtp.core.fastfail.AbstractValidRcptHandler.reject:61 - Rejected message. Unknown user: darger@domaine.de
> INFO | jvm 1 | 2023/06/06 23:55:50 | 06-Jun-2023 23:55:50.400 INFO [smtpserver-io-3] org.apache.james.protocols.smtp.core.log.HookResultLogger.onHookResult:45 - org.apache.james.smtpserver.fastfail.ValidRcptHandler: result= (DENY CONNECTED)
> INFO | jvm 1 | 2023/06/06 23:55:50 | 06-Jun-2023 23:55:50.401 INFO [smtpserver-io-3] org.apache.james.protocols.smtp.core.fastfail.AbstractValidRcptHandler.reject:61 - Rejected message. Unknown user: danielle.x@domaine.de
> INFO | jvm 1 | 2023/06/06 23:55:50 | 06-Jun-2023 23:55:50.401 INFO [smtpserver-io-3] org.apache.james.protocols.smtp.core.log.HookResultLogger.onHookResult:45 - org.apache.james.smtpserver.fastfail.ValidRcptHandler: result= (DENY CONNECTED)
>
> … (202 lines in total )
>
> INFO | jvm 1 | 2023/06/06 23:55:50 | 06-Jun-2023 23:55:50.470 INFO [smtpserver-io-3] org.apache.james.protocols.smtp.core.fastfail.AbstractValidRcptHandler.reject:61 - Rejected message. Unknown user: upoz3f3sx7nx@domaine.de
> INFO | jvm 1 | 2023/06/06 23:55:50 | 06-Jun-2023 23:55:50.471 INFO [smtpserver-io-3] org.apache.james.protocols.smtp.core.log.HookResultLogger.onHookResult:45 - org.apache.james.smtpserver.fastfail.ValidRcptHandler: result= (DENY CONNECTED)
> INFO | jvm 1 | 2023/06/06 23:55:51 | 06-Jun-2023 23:55:51.408 INFO [smtpserver-io-3] org.apache.james.protocols.netty.BasicChannelInboundHandler.channelInactive:143 - Connection closed for 60.29.127.226/60.29.127.226:50151
>
>
> 2) Password is unverified
>
> INFO | jvm 1 | 2023/06/06 23:44:49 | 06-Jun-2023 23:44:49.108 INFO [smtpserver-io-2] org.apache.james.protocols.netty.BasicChannelInboundHandler.channelActive:103 - Connection established from 45.133.235.202
> INFO | jvm 1 | 2023/06/06 23:44:49 | 06-Jun-2023 23:44:49.333 INFO [smtpserver-io-2] org.apache.james.user.lib.UsersRepositoryImpl.lambda$test$2:155 - Could not retrieve user Username{localPart=root, domainPart=Optional[Domain : domaine.de]}. Password is unverified.
> INFO | jvm 1 | 2023/06/06 23:44:49 | 06-Jun-2023 23:44:49.333 INFO [smtpserver-io-2] org.apache.james.protocols.smtp.core.esmtp.AuthCmdHandler.doAuthTest:397 - AUTH method LOGIN failed from Username{localPart=root, domainPart=Optional[Domain : domaine.de]}@45.133.235.202
> INFO | jvm 1 | 2023/06/06 23:44:49 | 06-Jun-2023 23:44:49.512 INFO [smtpserver-io-2] org.apache.james.user.lib.UsersRepositoryImpl.lambda$test$2:155 - Could not retrieve user Username{localPart=root, domainPart=Optional[Domain : domaine.de]}. Password is unverified.
> INFO | jvm 1 | 2023/06/06 23:44:49 | 06-Jun-2023 23:44:49.512 INFO [smtpserver-io-2] org.apache.james.protocols.smtp.core.esmtp.AuthCmdHandler.doAuthTest:397 - AUTH method LOGIN failed from Username{localPart=root, domainPart=Optional[Domain : domaine.de]}@45.133.235.202
>
> … (408 lines in total )
>
> INFO | jvm 1 | 2023/06/06 23:45:25 | 06-Jun-2023 23:45:25.286 INFO [smtpserver-io-2] org.apache.james.user.lib.UsersRepositoryImpl.lambda$test$2:155 - Could not retrieve user Username{localPart=root, domainPart=Optional[Domain : domaine.de]}. Password is unverified.
> INFO | jvm 1 | 2023/06/06 23:45:25 | 06-Jun-2023 23:45:25.286 INFO [smtpserver-io-2] org.apache.james.protocols.smtp.core.esmtp.AuthCmdHandler.doAuthTest:397 - AUTH method LOGIN failed from Username{localPart=root, domainPart=Optional[Domain : domaine.de]}@45.133.235.202
> INFO | jvm 1 | 2023/06/06 23:45:25 | 06-Jun-2023 23:45:25.330 INFO [smtpserver-io-2] org.apache.james.protocols.netty.BasicChannelInboundHandler.channelInactive:143 - Connection closed for 45.133.235.202/45.133.235.202:57554
>
>
> Does anyone know solutions to these problems?
>
> Best wishes, Günter
>
>
Re: Attack on the James Server
Posted by Günter Paul <gp...@guenterpaul.de>.
Hello David,
thanks for your information. Maybe fail2ban is a solution. I would prefer to solve the problem with board funds from James.
Perhaps the solution would be to extend the handlers to stop after a certain number of failed attempts?
Best wishes
Günter
> David Matthews <ma...@dmatthews.org.invalid> hat am 07.06.2023 10:29 CEST geschrieben:
>
>
> >I run a James mail server (james-server-spring-app-3.8.0). The log file shows that the server is constantly being attacked. This is normal, the server is on the Internet.
>
> My experience is that there is a sharp increase on attacks on small mail servers since maybe April. This is not a James issue - I run exim/dovecot in production setup.
>
> I'd strongly suggest looking at fail2ban and this may give a pointer:-
>
> https://dmatthews.org/webmail.html#fail2ban
>
> Fortunately for me fail2ban's regex for exim is ok as is; writing regex is one of my least favourite tasks. Using James, you'll have some work to do there.
>
> As an aside, it seems more or less concurrent to this large increase in attacks, free email providers are all tying to get a phone number from you. Gmail, not so forcefully, but another foreign provider (I have these legacy accounts for testing purposes) told me there had been a hacked entry into my account and to do a password reset I now have to supply a phone number. For sure they are lying and there is no way they'll get a phone number from me :-) Online attack on anonymity?
>
> --
> David Matthews
> mail@dmatthews.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
> For additional commands, e-mail: server-user-help@james.apache.org
--
Günter Paul
Hirschbachstraße 4a
53506 Ahrbrück
Tel.: +4926436747
Mobile: +491759140889
---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org
Re: Attack on the James Server
Posted by Jean Helou <je...@gmail.com>.
hello Gunter,
recent james 3.x code (it may be available for older versions I haven't
checked) includes several useful pieces of information in a mapped
diagnostic context (MDC ) which is accessible by the logging system.
By default james will try to include values for all the following keys in
the MDC when the information is contextually available
public static final String HOST = "host";
public static final String IP = "ip";
public static final String PROTOCOL = "protocol";
public static final String USER = "user";
public static final String ACTION = "action";
public static final String SESSION_ID = "sessionId";
public static final String CHARSET = "charset";
you can change you logging configuration to include these fields for each
log lines. this should be done in the logback.xml file it should have an
"encoder" section under the "appender" blocks Here is what my console
appender encoder looks like
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%-5level] - %t -
[p=%X{protocol},a=%X{action},s=%X{sessionId},u=%X{user}] - %logger{15} -
%msg%n%rEx</pattern>
<immediateFlush>false</immediateFlush>
</encoder>
you can see that I include the protocol, action, sessionId and user in all
my log lines when they are available. you can make it output the ip by
adding %X{ip} to your pattern
best regards,
jean
On Thu, Jun 8, 2023 at 11:58 AM Günter Paul <gp...@guenterpaul.de> wrote:
> Hi David,
>
> I'm afraid fail2ban can't help.
>
> The tool evaluates the log file, right?
>
> The problem is as follows: First, the attacker's IP address is written in
> one line to the log file. And a second request could come almost at the
> same time, the IP address is also written to the log file. Then a
> non-existent user is written to the log file, unfortunately without
> specifying the IP address.
>
> An assignment to the attacker is no longer possible. I'm afraid the
> problem can only be solved within James himself.
>
> Example:
> INFO | jvm 1 | 2023/06/07 16:49:55 | 07-Jun-2023 16:49:55.869 INFO
> [smtpserver-io-1]
> org.apache.james.protocols.netty.BasicChannelInboundHandler.channelActive:103
> - Connection established from 59.2.248.84
> INFO | jvm 1 | 2023/06/07 16:49:55 | 07-Jun-2023 16:49:55.901 INFO
> [smtpserver-io-1]
> org.apache.james.protocols.netty.BasicChannelInboundHandler.channelActive:103
> - Connection established from 58.12.250.90
> INFO | jvm 1 | 2023/06/07 16:49:59 | 07-Jun-2023 16:49:59.761 INFO
> [smtpserver-io-1]
> org.apache.james.protocols.smtp.core.fastfail.AbstractValidRcptHandler.reject:61
> - Rejected message. Unknown user: blr@domaine.de
> INFO | jvm 1 | 2023/06/07 16:49:59 | 07-Jun-2023 16:49:59.761 INFO
> [smtpserver-io-1]
> org.apache.james.protocols.smtp.core.log.HookResultLogger.onHookResult:45 -
> org.apache.james.smtpserver.fastfail.ValidRcptHandler: result= (DENY
> CONNECTED)
>
>
> > Günter Paul <gp...@guenterpaul.de> hat am 07.06.2023 17:24 CEST
> geschrieben:
> >
> >
> > Thanks David. You're probably right, I'll check fail2ban. At the oter
> sinde: regex is not my friend though.
> >
> > BW Günter
> >
> > > David Matthews <ma...@dmatthews.org.invalid> hat am 07.06.2023 16:40
> CEST geschrieben:
> > >
> > >
> > > >Hello David,
> > > >
> > > >thanks for your information. Maybe fail2ban is a solution. I would
> prefer to solve the problem with board funds from James.
> > > >
> > > With fail2ban, once you come up with a working regex, you're solving
> the problem at a pre James level - in affect you would be operating an
> automatic and dynamic firewall block.
> > >
> > > I think that's a deal more efficient than anything James or any other
> mail exchanger can do.
> > >
> > > --
> > > David Matthews
> > > mail@dmatthews.org
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
> > > For additional commands, e-mail: server-user-help@james.apache.org
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
> > For additional commands, e-mail: server-user-help@james.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
> For additional commands, e-mail: server-user-help@james.apache.org
>
>
Re: Attack on the James Server
Posted by Günter Paul <gp...@guenterpaul.de>.
Hi David,
I'm afraid fail2ban can't help.
The tool evaluates the log file, right?
The problem is as follows: First, the attacker's IP address is written in one line to the log file. And a second request could come almost at the same time, the IP address is also written to the log file. Then a non-existent user is written to the log file, unfortunately without specifying the IP address.
An assignment to the attacker is no longer possible. I'm afraid the problem can only be solved within James himself.
Example:
INFO | jvm 1 | 2023/06/07 16:49:55 | 07-Jun-2023 16:49:55.869 INFO [smtpserver-io-1] org.apache.james.protocols.netty.BasicChannelInboundHandler.channelActive:103 - Connection established from 59.2.248.84
INFO | jvm 1 | 2023/06/07 16:49:55 | 07-Jun-2023 16:49:55.901 INFO [smtpserver-io-1] org.apache.james.protocols.netty.BasicChannelInboundHandler.channelActive:103 - Connection established from 58.12.250.90
INFO | jvm 1 | 2023/06/07 16:49:59 | 07-Jun-2023 16:49:59.761 INFO [smtpserver-io-1] org.apache.james.protocols.smtp.core.fastfail.AbstractValidRcptHandler.reject:61 - Rejected message. Unknown user: blr@domaine.de
INFO | jvm 1 | 2023/06/07 16:49:59 | 07-Jun-2023 16:49:59.761 INFO [smtpserver-io-1] org.apache.james.protocols.smtp.core.log.HookResultLogger.onHookResult:45 - org.apache.james.smtpserver.fastfail.ValidRcptHandler: result= (DENY CONNECTED)
> Günter Paul <gp...@guenterpaul.de> hat am 07.06.2023 17:24 CEST geschrieben:
>
>
> Thanks David. You're probably right, I'll check fail2ban. At the oter sinde: regex is not my friend though.
>
> BW Günter
>
> > David Matthews <ma...@dmatthews.org.invalid> hat am 07.06.2023 16:40 CEST geschrieben:
> >
> >
> > >Hello David,
> > >
> > >thanks for your information. Maybe fail2ban is a solution. I would prefer to solve the problem with board funds from James.
> > >
> > With fail2ban, once you come up with a working regex, you're solving the problem at a pre James level - in affect you would be operating an automatic and dynamic firewall block.
> >
> > I think that's a deal more efficient than anything James or any other mail exchanger can do.
> >
> > --
> > David Matthews
> > mail@dmatthews.org
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
> > For additional commands, e-mail: server-user-help@james.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
> For additional commands, e-mail: server-user-help@james.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org
Re: Attack on the James Server
Posted by Wojtek <wo...@unir.se>.
On 08/06/2023 11:30, David Matthews wrote:
>> The tool evaluates the log file, right?
>
> yes
>
> Your problem would be to write a regex that matches the lines in the log file that you don't want to see. That has to be doable, but may well be painful :-)
>
> I have fail2ban watch every service my machines offer - web, mail exchnger, name server - except ssh access, which it's usually used for. I deal with ssh by only allowing it from a small number of ipv4 addresses.
>
> I got lucky with exim4 as the supplied regex picks up all the stuff I don't want and recently that seems to have become pretty important. For apache2 (with modsecurity) and the nameserver, I had to produce a regex myself - ouch. But once you have that it's the bees knees. You can block these bad guys for as long as you like.
> David Matthews
To chip-in. It should be possible to configure logback to: output only log entries for failing
connections (e.g. for org.apache.james.protocols.smtp.core.esmtp.AuthCmdHandler.doAuthTest) and with
simplified entry (e.g. only the error message) that should make writing regexp simpler.
Wojtek
---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org
Re: Attack on the James Server
Posted by Günter Paul <gp...@guenterpaul.de>.
Hi David,
You're right of course and I get that too. My problem is that I have no way to solve the problem directly with the firewall. I have very simple rules that say no more than 4 new connections are allowed on the smpt port from one IP address (I have similar rules for other ports):
$IPTABLES -A INPUT -p tcp -d $MYHOST --dport 25 -m state --state NEW -m recent --set --name DDOS-SMTP
$IPTABLES -A INPUT -p tcp -d $MYHOST --dport 25 -m state --state NEW -m recent --update --seconds 60 --hitcount 4 --name DDOS-SMTP -j DROP
It doesn't always work for James though. I also described this in the first post on this topic. The attacker open a connection and keeps trying to log in, more than 100 attempts in a few seconds. And the connection remains open so the firewall-rule doesn't work.
My approach would be that James closes the connection after e.g. three attempts, that should be configurable. Then the standard firewall rules could take effect again.
Best wishes
Günter
> David Matthews <ma...@dmatthews.org.invalid> hat am 16.06.2023 08:47 CEST geschrieben:
>
>
> hi Gunter
>
> >The best way I think would be if James could handle this internally. Until then, fail2ban is a good alternative.
>
> I think you are misunderstanding. Neither james or any other mail exchanger or imap server can take over the work fail2ban can do. Fail2ban can provide a dynamic firewall, by blocking ip addresses that misbehave on the fly. This blocking happens at network level rather than application level so is much more efficient and safer than james/exim4/postfix alone can achieve with even the finest configuration tweaks.
>
> --
> David Matthews
> mail@dmatthews.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
> For additional commands, e-mail: server-user-help@james.apache.org
--
Günter Paul
Hirschbachstraße 4a
53506 Ahrbrück
Tel.: +4926436747
Mobile: +491759140889
---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org
Re: Attack on the James Server
Posted by Günter Paul <gp...@guenterpaul.de>.
Hi Benoit,
I wrote a documentary. You can find here:
https://www.fentool.de/daten/aYg_h2p-hpw/JamesAttacks_v0.1.pdf
Hope it's usefull. If you need a different format or if I can help in any other way, please contact me.
@All: I would appreciate if someone reviews my work and wants to give me feeddback. (A better translation would also be helpful)
Best wishes
Günter
> Benoit TELLIER <bt...@apache.org> hat am 15.06.2023 05:06 CEST geschrieben:
>
>
> Hello Paul,
>
> Fail2ban set up with Apache James seems rather generic, and might be
> worth sharing through either a blog post of through a dedicated
> documentation page.
>
> Do you think you would be able to share your experience with others?
>
> I would be happy to add a blog post entry on James website for this, if
> relevant.
>
> Regards,
>
> Benoit
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
> For additional commands, e-mail: server-user-help@james.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org
Re: Attack on the James Server
Posted by Günter Paul <gp...@guenterpaul.de>.
Hi Benoit,
Yes, I am glad to write a small documentation. But I need a few days for this.
I currently solved it by writing my own appender for log4j2. This makes the evaluation easier for me, since I can do without complicated regex expressions. But this does not work for other loggers.
The best way I think would be if James could handle this internally. Until then, fail2ban is a good alternative.
Best wishes
Günter
> Benoit TELLIER <bt...@apache.org> hat am 15.06.2023 05:06 CEST geschrieben:
>
>
> Hello Paul,
>
> Fail2ban set up with Apache James seems rather generic, and might be
> worth sharing through either a blog post of through a dedicated
> documentation page.
>
> Do you think you would be able to share your experience with others?
>
> I would be happy to add a blog post entry on James website for this, if
> relevant.
>
> Regards,
>
> Benoit
>
> On 15/06/2023 00:13, Günter Paul wrote:
> > Hi,
> >
> > at the end I'm using fail2ban. Thanks a lot for information.
> >
> > I see log4j2 works too with the parameters, so I found a solution for me.
> >
> > Best wishes
> >
> > Günter
> >
> >> Günter Paul <gp...@guenterpaul.de> hat am 08.06.2023 22:23 CEST geschrieben:
> >>
> >>
> >> Hi,
> >>
> >> Thanks, logback sounds good. I'm using the spring-version. I will try to change, hope it' possible without problems.
> >>
> >> Günter
> >>
> >>
> >> Am 8. Juni 2023 18:21:55 MESZ schrieb David Matthews <ma...@dmatthews.org.INVALID>:
> >>>> To chip-in. It should be possible to configure logback to: output only log entries for failing
> >>>> connections (e.g. for org.apache.james.protocols.smtp.core.esmtp.AuthCmdHandler.doAuthTest) and with
> >>>> simplified entry (e.g. only the error message) that should make writing regexp simpler.
> >>>>
> >>> yes, that would help
> >>>
> >>> With my exim4 setup, fail2ban is only looking at the rejectlog. You can't just ban everything though as you'd lock yourself out next time you fat fingered the password.
> >>>
> >>> --
> >>> David Matthews
> >>> mail@dmatthews.org
> >>>
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
> >>> For additional commands, e-mail: server-user-help@james.apache.org
> >>>
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
> > For additional commands, e-mail: server-user-help@james.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
> For additional commands, e-mail: server-user-help@james.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org
Re: Attack on the James Server
Posted by David Matthews <ma...@dmatthews.org.INVALID>.
hi Gunter
I'm not a James expert; I don't even use it in production, I did look at it a while back, because I'm a java programmer, but I decided that the devil you know (exim4 in my case) is better than the devil you don't. In my book, all mailexchangers being complicated beastly devils.
I still think your problem sounds like the necessity to create a regex that will match those 100 failed attempts to logon as recorded in your logs. If you can do that then fail2ban can be set to drop the connection after say 3 failed attempts.
I believe I've recently seen the same problem as you. Maybe around April this year, before which there was only the trickle of spammers trying to route spam through my mailer, suddenly a huge volume of different addresses doing strange things. They just as suddenly it stopped about a week ago and I think it was thanks to fail2ban,that there were no memory issues - even my small VM managed to shrug it off.
My suspicion is it's part of a drive to end internet anonymity. I only host my own mail, but I could easily be, as other people on this list do, running a little email business, without demanding real world ID of customers.
So little people like you and I, offering an alternative to gmail, outlook etc, become a target - that's how I see it anyway. :-)
--
David Matthews
mail@dmatthews.org
---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org
Re: Attack on the James Server
Posted by David Matthews <ma...@dmatthews.org.INVALID>.
hi Gunter
>The best way I think would be if James could handle this internally. Until then, fail2ban is a good alternative.
I think you are misunderstanding. Neither james or any other mail exchanger or imap server can take over the work fail2ban can do. Fail2ban can provide a dynamic firewall, by blocking ip addresses that misbehave on the fly. This blocking happens at network level rather than application level so is much more efficient and safer than james/exim4/postfix alone can achieve with even the finest configuration tweaks.
--
David Matthews
mail@dmatthews.org
---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org
Re: Attack on the James Server
Posted by Benoit TELLIER <bt...@apache.org>.
Hello Paul,
Fail2ban set up with Apache James seems rather generic, and might be
worth sharing through either a blog post of through a dedicated
documentation page.
Do you think you would be able to share your experience with others?
I would be happy to add a blog post entry on James website for this, if
relevant.
Regards,
Benoit
On 15/06/2023 00:13, Günter Paul wrote:
> Hi,
>
> at the end I'm using fail2ban. Thanks a lot for information.
>
> I see log4j2 works too with the parameters, so I found a solution for me.
>
> Best wishes
>
> Günter
>
>> Günter Paul <gp...@guenterpaul.de> hat am 08.06.2023 22:23 CEST geschrieben:
>>
>>
>> Hi,
>>
>> Thanks, logback sounds good. I'm using the spring-version. I will try to change, hope it' possible without problems.
>>
>> Günter
>>
>>
>> Am 8. Juni 2023 18:21:55 MESZ schrieb David Matthews <ma...@dmatthews.org.INVALID>:
>>>> To chip-in. It should be possible to configure logback to: output only log entries for failing
>>>> connections (e.g. for org.apache.james.protocols.smtp.core.esmtp.AuthCmdHandler.doAuthTest) and with
>>>> simplified entry (e.g. only the error message) that should make writing regexp simpler.
>>>>
>>> yes, that would help
>>>
>>> With my exim4 setup, fail2ban is only looking at the rejectlog. You can't just ban everything though as you'd lock yourself out next time you fat fingered the password.
>>>
>>> --
>>> David Matthews
>>> mail@dmatthews.org
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
>>> For additional commands, e-mail: server-user-help@james.apache.org
>>>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
> For additional commands, e-mail: server-user-help@james.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org
Re: Attack on the James Server
Posted by David Matthews <ma...@dmatthews.org.INVALID>.
>Hello Paul,
>Do you think you would be able to share your experience with others?
I'll chip in here as the proponent of fail2ban to watch all the services provided by your server, not just ssh as is most commonly used.
The most useful thing for james users will be a working regex, which probably should be in
/etc/fail2ban/filter.d/james.local
to make sure it doesn't get removed in an upgrade. Also details of any customization made to your logging setup.
I presume you made a
/etc/fail2ban/jail.local
file with your james config (again to prevent an upgrade removing settings). So that would also be helpful to james users.
Other james users (with logging matching yours) would just need to copy those files, make them owned root.root and restart fail2ban
--
David Matthews
mail@dmatthews.org
---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org
Re: Attack on the James Server
Posted by Günter Paul <gp...@guenterpaul.de>.
Hi,
at the end I'm using fail2ban. Thanks a lot for information.
I see log4j2 works too with the parameters, so I found a solution for me.
Best wishes
Günter
> Günter Paul <gp...@guenterpaul.de> hat am 08.06.2023 22:23 CEST geschrieben:
>
>
> Hi,
>
> Thanks, logback sounds good. I'm using the spring-version. I will try to change, hope it' possible without problems.
>
> Günter
>
>
> Am 8. Juni 2023 18:21:55 MESZ schrieb David Matthews <ma...@dmatthews.org.INVALID>:
> >>To chip-in. It should be possible to configure logback to: output only log entries for failing
> >>connections (e.g. for org.apache.james.protocols.smtp.core.esmtp.AuthCmdHandler.doAuthTest) and with
> >>simplified entry (e.g. only the error message) that should make writing regexp simpler.
> >>
> >
> >yes, that would help
> >
> >With my exim4 setup, fail2ban is only looking at the rejectlog. You can't just ban everything though as you'd lock yourself out next time you fat fingered the password.
> >
> >--
> >David Matthews
> >mail@dmatthews.org
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
> >For additional commands, e-mail: server-user-help@james.apache.org
> >
---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org
Re: Attack on the James Server
Posted by Günter Paul <gp...@guenterpaul.de>.
Hi,
Thanks, logback sounds good. I'm using the spring-version. I will try to change, hope it' possible without problems.
Günter
Am 8. Juni 2023 18:21:55 MESZ schrieb David Matthews <ma...@dmatthews.org.INVALID>:
>>To chip-in. It should be possible to configure logback to: output only log entries for failing
>>connections (e.g. for org.apache.james.protocols.smtp.core.esmtp.AuthCmdHandler.doAuthTest) and with
>>simplified entry (e.g. only the error message) that should make writing regexp simpler.
>>
>
>yes, that would help
>
>With my exim4 setup, fail2ban is only looking at the rejectlog. You can't just ban everything though as you'd lock yourself out next time you fat fingered the password.
>
>--
>David Matthews
>mail@dmatthews.org
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
>For additional commands, e-mail: server-user-help@james.apache.org
>
Re: Attack on the James Server
Posted by David Matthews <ma...@dmatthews.org.INVALID>.
>To chip-in. It should be possible to configure logback to: output only log entries for failing
>connections (e.g. for org.apache.james.protocols.smtp.core.esmtp.AuthCmdHandler.doAuthTest) and with
>simplified entry (e.g. only the error message) that should make writing regexp simpler.
>
yes, that would help
With my exim4 setup, fail2ban is only looking at the rejectlog. You can't just ban everything though as you'd lock yourself out next time you fat fingered the password.
--
David Matthews
mail@dmatthews.org
---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org
Re: Attack on the James Server
Posted by David Matthews <ma...@dmatthews.org.INVALID>.
>Hi David,
>
>I'm afraid fail2ban can't help.
it absolutely can
>The tool evaluates the log file, right?
yes
Your problem would be to write a regex that matches the lines in the log file that you don't want to see. That has to be doable, but may well be painful :-)
I have fail2ban watch every service my machines offer - web, mail exchnger, name server - except ssh access, which it's usually used for. I deal with ssh by only allowing it from a small number of ipv4 addresses.
I got lucky with exim4 as the supplied regex picks up all the stuff I don't want and recently that seems to have become pretty important. For apache2 (with modsecurity) and the nameserver, I had to produce a regex myself - ouch. But once you have that it's the bees knees. You can block these bad guys for as long as you like.
--
David Matthews
mail@dmatthews.org
---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org
Re: Attack on the James Server
Posted by Günter Paul <gp...@guenterpaul.de>.
Thanks David. You're probably right, I'll check fail2ban. At the oter sinde: regex is not my friend though.
BW Günter
> David Matthews <ma...@dmatthews.org.invalid> hat am 07.06.2023 16:40 CEST geschrieben:
>
>
> >Hello David,
> >
> >thanks for your information. Maybe fail2ban is a solution. I would prefer to solve the problem with board funds from James.
> >
> With fail2ban, once you come up with a working regex, you're solving the problem at a pre James level - in affect you would be operating an automatic and dynamic firewall block.
>
> I think that's a deal more efficient than anything James or any other mail exchanger can do.
>
> --
> David Matthews
> mail@dmatthews.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
> For additional commands, e-mail: server-user-help@james.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org
Re: Attack on the James Server
Posted by David Matthews <ma...@dmatthews.org.INVALID>.
>Hello David,
>
>thanks for your information. Maybe fail2ban is a solution. I would prefer to solve the problem with board funds from James.
>
With fail2ban, once you come up with a working regex, you're solving the problem at a pre James level - in affect you would be operating an automatic and dynamic firewall block.
I think that's a deal more efficient than anything James or any other mail exchanger can do.
--
David Matthews
mail@dmatthews.org
---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org
Re: Attack on the James Server
Posted by David Matthews <ma...@dmatthews.org.INVALID>.
>I run a James mail server (james-server-spring-app-3.8.0). The log file shows that the server is constantly being attacked. This is normal, the server is on the Internet.
My experience is that there is a sharp increase on attacks on small mail servers since maybe April. This is not a James issue - I run exim/dovecot in production setup.
I'd strongly suggest looking at fail2ban and this may give a pointer:-
https://dmatthews.org/webmail.html#fail2ban
Fortunately for me fail2ban's regex for exim is ok as is; writing regex is one of my least favourite tasks. Using James, you'll have some work to do there.
As an aside, it seems more or less concurrent to this large increase in attacks, free email providers are all tying to get a phone number from you. Gmail, not so forcefully, but another foreign provider (I have these legacy accounts for testing purposes) told me there had been a hacked entry into my account and to do a password reset I now have to supply a phone number. For sure they are lying and there is no way they'll get a phone number from me :-) Online attack on anonymity?
--
David Matthews
mail@dmatthews.org
---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org