TMA-MONGODB-7.2
Ensure appropriate database file permissions are set
HighLevel 1Automatedmongodb
Description
MongoDB database files need to be protected using file permissions. The benchmark rates this recommendation Manual; the automated check covers its objective pass criterion. Checks the YAML config file /etc/mongod.conf (SKIP when it does not exist). storage.dbPath (default /var/lib/mongodb) must be 770 or stricter, with no access for other users.
How it is checked
Audit method: Shell command
shell
[ -r /etc/mongod.conf ] || exit 1; d=$(awk '/^[[:space:]]*dbPath:/ {v=$2; gsub(/["\047]/, "", v); print v}' /etc/mongod.conf); d=${d:-/var/lib/mongodb}; p=$(stat -c %a "$d" 2>/dev/null) || exit 1; if [ $((0$p & 007)) -eq 0 ]; then echo compliant; else echo "mode $p"; fi- Expected output
compliant
How it is fixed
Fix method: Guidance or infrastructure patch
chmod 770 <dbPath> and chown mongodb:mongodb <dbPath> (default /var/lib/mongodb).
Properties
- Operating systems
- Any
- Tags
- mongodbpermissions
- Reference
- CIS MongoDB 8 Benchmark v2.0.0 - 7.2 Ensure appropriate database file permissions are set
Check this host
Run this on a machine you are allowed to audit. The scan is read-only.
shell
tmaegis scan --target mongodb