Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misbehaving clients are never disconnected #145

Closed
edeca opened this issue Jun 13, 2018 · 4 comments · Fixed by #222
Closed

Misbehaving clients are never disconnected #145

edeca opened this issue Jun 13, 2018 · 4 comments · Fixed by #222
Milestone

Comments

@edeca
Copy link

edeca commented Jun 13, 2018

It's possible to exhaust resources on the server in a number of ways:

  • Connect and never send a valid command
  • Connect and repeatedly send NOOP
  • Connect and waste time in the SMTP transaction, e.g. send multiple HELO, reset,

Eventually Python will run out of file handles and exceptions will occur in code that tries to open any file, socket, etc.

@edeca
Copy link
Author

edeca commented Aug 30, 2018

Merge #146 fixes the case when clients do not send data.

Other cases need further consideration. One blunt method would be a time limit on the overall transaction. Slightly more clever mechanisms could time progress through each part of the SMTP transaction, count commands like NOOP etc.

@waynew
Copy link
Collaborator

waynew commented Aug 30, 2018

It seems to me that the blunt approach would be a great first step.

If we tracked a misbehavior score on the clients somehow, and just start with a (configurable) time limit, then we could start adding other behaviors (e.g. repeated NOOPS, number of NOOPS per email/successful email, etc.)

Then I think there may be a convenient choke point where we can just check the client score, and if they've exceeded the limit then we can disconnect them.

There might be alternate approaches that also work! That's just the first thing that popped into my head 🙂

@cnicodeme
Copy link
Contributor

I agree on these. I have a server that accepts a lot of connections per day, and too many stay open because of DOS like servers connecting to mine.

A combination of the following might help:

  • Setting up a timeout for each command (independant for each/globally for the whole connection - which would solve the NOOP loop too)
  • Counting and limiting the number of requests, allowing a certain amount (as a variable) for each command. (defaults to 3? - might be good to limit each commands separately, like VRFY could be used more)

This would greatly help!

@pepoluan
Copy link
Collaborator

pepoluan commented Dec 23, 2020

-- this comment should've gone into the PR 😅 --

@pepoluan pepoluan added this to the 1.3 milestone Dec 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants