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

ssh-honeypot creates hundreds of forks, consuming all memory #21

Open
vegaelle opened this issue Dec 2, 2020 · 3 comments
Open

ssh-honeypot creates hundreds of forks, consuming all memory #21

vegaelle opened this issue Dec 2, 2020 · 3 comments

Comments

@vegaelle
Copy link

vegaelle commented Dec 2, 2020

Hi. I’ve been using ssh-honeypot for a few weeks now, and i noticed that the server has a very concerning ram usage. This server is a firewall, and only uses iptables (kernel-space) and ssh-honeypot. Here’s my monitoring graph for the last 7 days:

2020-12-02-110820_grim

The drops in memory consumption are when i restart the ssh-honeypot service (using openrc). Right now, there’s 425 honeypot processes running.

Why is ssh-honeypot behaving like this, and what can be done to prevent crashing my server every 2 days if i don’t stop manually the service?

@husixu1
Copy link

husixu1 commented Jul 22, 2021

I faced the same issue. After a bit of debugging and digging into the source code, I found that in the handle_ssh_auth() function, the call to ssh_handle_key_exchange() further calls ssh_handle_packets_termination() to handle packets, which is blocking and uses an infinite timeout by default. And if the authentication is interrupted midway before the polling starts, the subprocess blocks infinitely, causing a memory (and process number) leak.

So the solution is to set a valid timeout for the allocated session. In the main() function, below session = ssh_new ();, add:

long timeout = 5; // set default timeout to 5s
ssh_options_set(session, SSH_OPTIONS_TIMEOUT, (void *)(&timeout));

And that should fix this issue (at least it works for me).

jorgeverastegui added a commit to jorgeverastegui/ssh-honeypot that referenced this issue Nov 8, 2021
@vegaelle
Copy link
Author

vegaelle commented Feb 27, 2022

Hi. Would it be possible to integrate this patch? The project doesn’t seem active anymore. @jorgeverastegui is your fork intented to be a take-over?

droberson added a commit that referenced this issue Feb 27, 2022
@droberson
Copy link
Owner

added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants