mosquitto icon indicating copy to clipboard operation
mosquitto copied to clipboard

mosquitto cannot prevent brute force password attack

Open fengqiusuo opened this issue 4 years ago • 6 comments

As we know, mosquitto cannot prevent brute force password attack. So I want to know whether wo have a plan to prevent brute force password attack. Wish you all well, thank you!

fengqiusuo avatar Feb 05 '21 07:02 fengqiusuo

Firstly, a "password" in MQTT is up to 65535 bytes of data. So its up to you to set it to what you want, and then ensure you can enter the same data on the client. It is only brute forceable if you choose to use a weak password, as MQTT supports 2^524280 permutations of passwords, which is absolutely not brute forceable.

If you are using 'weak' passwords, "mosquitto_passwd" has a (undocumented?) -I option to set iteration count for password hashing. When user sends a password, it is hashed and compared to the stored hashed value. A higher iteration count means the password is stored having gone through more hash cycles, so when the comparison is done at user login attempt, the server has to do more hash cycles, and will take longer to reject or accept clients. You can set this as high as you want to make the login attempt longer and longer to prevent brute forcing in a reasonable time period.

Thirdly if you are still worried about security, you should issue each client a client certificate. Mosquitto can be set to authenticate clients via certificates.

sectokia avatar Feb 06 '21 02:02 sectokia

OK,thank you very much. I'll think about it again.

fengqiusuo avatar Feb 07 '21 02:02 fengqiusuo

This isn't on my list of priorities right now, but I agree it would be useful. If you're interested in making it happen I can offer guidance. It might actually be well suited to being a plugin.

ralight avatar Feb 09 '21 11:02 ralight

fail2ban or similar could be used but the problem is that the disconnect log entry is missing client's IP address.

jsopenrb avatar May 14 '21 12:05 jsopenrb

To use fail2ban, the mosquitto log file entry needs some kind of unique connection identificator, to reliable detect attacker.

More info at https://github.com/fail2ban/fail2ban/issues/3427

What about adding IP address to disconnect line? Something as

` Dec 06 19:49:04: New connection from 192.168.0.100:39608 on port 8883.

Dec 06 19:49:05: Client 192.168.0.100:39608 disconnected, not authorised. `

Thank you

kri164 avatar Dec 06 '22 19:12 kri164

+1

lcse66 avatar Dec 02 '23 14:12 lcse66