7.2 Ensure that database file permissions are set correctly

Information

MongoDB database files need to be protected using file permissions.

Rationale:

This will restrict unauthorized users from accessing the database.

Solution

Set ownership of the database file to mongodb user and remove other permissions using the following commands:

chmod 770 /var/lib/mongodb
sudo chown mongodb:mongodb /var/lib/mongodb

Default Value:

Not configured

References:

https://docs.mongodb.com/v3.6/reference/configuration-options/#storage.dbPath

See Also

https://workbench.cisecurity.org/files/2605