Skip to content

mosquitto cannot prevent brute force password attack #2076

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

Open
fengqiusuo opened this issue Feb 5, 2021 · 6 comments · May be fixed by #3248
Open

mosquitto cannot prevent brute force password attack #2076

fengqiusuo opened this issue Feb 5, 2021 · 6 comments · May be fixed by #3248

Comments

@fengqiusuo
Copy link

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!

@sectokia
Copy link

sectokia commented Feb 6, 2021

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.

@fengqiusuo
Copy link
Author

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

@ralight
Copy link
Contributor

ralight commented Feb 9, 2021

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.

@jsopenrb
Copy link

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

@kri164
Copy link

kri164 commented Dec 6, 2022

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

More info at fail2ban/fail2ban#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

@lcse66
Copy link

lcse66 commented Dec 2, 2023

+1

mattst88 added a commit to mattst88/mosquitto that referenced this issue Apr 2, 2025
@mattst88 mattst88 linked a pull request Apr 2, 2025 that will close this issue
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

Successfully merging a pull request may close this issue.

6 participants