I have not used mongodb in any production environment but it would be nice to know what one should do to make it secure.
I have not used mongodb in any production environment but it would be nice to know what one should do to make it secure.
- deny (all) incoming traffic by default
- permit only desired traffic (to specific ports) from specific hosts
- avoid binding (listening) to interfaces you don't need to
- set up / verify authentication is in place
In addition to the link to the security manual that cpolis posted, there's also a MongoDB Security Checklist [0].
[0]: https://docs.mongodb.com/manual/administration/security-chec...
Firewall, on the local machine ALL ports except for the ones that you expect to be accessed remotely.
This is for all hosts - even your laptop. Never mind mongo.
There is no reason at all to leave inbound ports open for requests you don't expect to service.
Further, and I know this makes peoples heads spin and they foam at the mouth, but for ports you do need open, but don't serve the public (ssh, for instance) set up a port knock. Now it's invisible and you don't care about the 0day for that service.[1]
[1] Stop. Take a deep breath. Re-read the above post and realize that I did not say to remove your login passwords and keys and rely on only the port knock for security. Take another deep breath. It's going to be OK.
https://docs.mongodb.com/manual/administration/security-chec...
So the usual rules apply: (1) have a firewall with only the bare minimum ports open, (2) make sure everything you are running is on unusual ports especially SSH, (3) VPN, jump hosts or port knocking if you need remote access, (4) use something like Fail2Ban or Sentry.
But seriously thank you for that stellar contribution.