MongoDB Config Security Audit Guide
Last updated:
A MongoDB config audit is a static review of a MongoDB server's configuration file — mongod.conf — checked line by line against known-good practice, without connecting to the server. The file is small, usually a few dozen settings, but it decides who can connect without a password, which network interfaces the server listens on, whether a crash loses your data, and whether anyone will ever know what happened. This guide walks through the settings that matter, the one setting that decides everything, the network exposure hiding in two lines, the durability trade-off, logging and audit, and the mistakes that show up again and again — then shows you how to run the same audit yourself with the MongoDB Config Auditor.
What a MongoDB config audit actually checks
A config audit reads the file the way the server reads it: as nested sections of settings, one key: value line at a time. MongoDB uses YAML in mongod.conf — sections like net, security and storage, with indented keys beneath them — plus # comments and quoted values. Because a setting that is simply absent leaves the compiled-in default in force, an audit checks absence as carefully as presence: the line you never wrote can be the one that matters most.
The checks fall into four families. Authentication and access: who can connect, with what credentials, and how replica-set members prove who they are. Transport security: which interfaces the server listens on, and whether connections are encrypted. Durability and recovery: what survives a crash, and whether a secondary can catch up afterwards. And observability: logging, profiling and audit — the settings whose absence is only noticed during an incident. The MongoDB Config Auditor runs these rules and scores the result from 0 to 100; the same audit family covers Redis and MySQL/Postgres configs.
Authentication is off by default — the one setting that decides everything
MongoDB ships with authentication OFF. A fresh install with no security.authorization line accepts any connection and lets it read and write everything — no password, no user, no error. That single default is behind the waves of open MongoDB instances found by scanners, emptied, and left with a ransom note. Everything else in the config is secondary: if authorization is off, the bind address and the TLS settings are the only things standing between the database and the internet, and both of them have permissive defaults of their own.
Turning it on takes one line — security: { authorization: enabled } — and then the real work starts: creating users in the admin database, because authorization enabled with no users means nobody can log in at all, including you, until the first user is created through the localhost exception. In a replica set, members also need security.keyFile, a shared secret file every member holds, or any mongod can join the set and copy the data. And the password mechanism matters: setParameter.authenticationMechanisms should include SCRAM-SHA-256, the modern mechanism — SCRAM-SHA-1 alone is weaker, and MONGODB-CR is a legacy mechanism removed in modern MongoDB, whose presence means the install is ancient.
Network exposure: bindIp, bindIpAll and TLS
Two lines decide whether the server is reachable at all. net.bindIp picks the interfaces mongod listens on: 127.0.0.1 means local clients only, 0.0.0.0 means every interface, including the public internet if the host is exposed. net.bindIpAll: true is the same exposure in a single flag. The default when bindIp is absent is localhost in MongoDB 3.6 and later — but an absent line is an implicit decision, and older installs and explicit bindIpAll differ, which is why the auditor flags the absence as well as the exposure.
Then comes encryption. net.tls.mode decides whether connections are encrypted: disabled means credentials and data travel in cleartext, allowTLS and preferTLS let a client downgrade to cleartext, and requireTLS refuses unencrypted connections. The trap is the contradictory config: requireTLS without net.tls.certificateKeyFile means mongod will fail to start at all. And net.port deserves a word of caution in the other direction: 27017 on a public interface is trivially scanned, but changing the port is obscurity only — it never substitutes for binding to localhost or a firewall.
The settings that decide durability: journal and the oplog
Durability in MongoDB rests on two settings. storage.journal.enabled controls the write-ahead journal: with journaling on, mongod replays writes after a crash instead of losing them; with it off, a crash can lose everything since the last checkpoint. It is a trade-off — journaling costs write throughput — but for most deployments the durability is worth more than the speed, and the auditor flags a disabled journal as a warning, not a note.
The second is the oplog. replication.oplogSizeMB sizes the capped collection that records every write for replication: a secondary that falls behind replays from the oplog, and if the oplog is too small to cover the gap, the secondary can no longer catch up and needs a full resync. The guideline is roughly 5% of disk, at least 1 GB for production — the demo config's 256 MB is a quarter of that floor. What the auditor deliberately does not judge is storage.wiredTiger.engineConfig.cacheSizeGB: its right value depends on total RAM, which a static audit cannot see, so the rule only notes its absence — the default is roughly 50% of RAM minus 1 GB.
Logging and audit: quiet, logRotate and the Enterprise audit trail
The last family is the one you miss during an incident. systemLog.quiet: true suppresses useful log output — the warnings and operational messages you need when something goes wrong — and the auditor flags it as a warning. systemLog.logRotate absent means logs grow unbounded unless something outside mongod rotates them, and a systemLog.destination of syslog without a syslogFacility means logs can land in an unexpected bucket. None of these is a vulnerability; all of them decide whether the next incident is diagnosable.
The audit trail itself is the sharpest limit in this family: auditLog.destination records who did what, but auditing is Enterprise-only. Community users cannot enable it, and the auditor says so explicitly in the finding rather than letting a Community user chase a setting they cannot use. What a static audit can still check here is the profiling pair: operationProfiling.mode: all profiles every operation at a real overhead cost, while a slowOpThresholdMs above 1000 ms means only operations slower than a second are ever logged — the default is 100 ms, and the slow operations you actually care about slip past unrecorded.
The five mistakes the auditor flags most
Across real-world configs, the same five findings recur. First, no security.authorization at all — the classic unauthenticated MongoDB on the public internet, the one behind the ransomware waves that empty databases and leave a ransom note. Second, net.bindIp: 0.0.0.0 — the same hole, one section earlier. Third, TLS disabled — every credential in cleartext, on a server that is often already public. Fourth, no durability: storage.journal.enabled: false with a 256 MB oplog, so a crash loses writes and a lagging secondary needs a full resync. Fifth, setParameter.enableTestCommands: 1 — test commands such as _migrateClone enabled in production, where they must never be.
The demo config below manages all five in 25 lines, plus a few extras: server-side JavaScript on, full profiling at a 5-second threshold, quiet logging to syslog with no facility, a 200,000 connection cap, and a daemonised process with no log file or pid file. The auditor scores it 31 out of 100, band Poor. Its hardened twin — same shape, every finding fixed — scores 100.
What a static audit cannot see — and auditing yours in five minutes
A static audit reads text, and its limits are the limits of text. It cannot see the values the running server actually uses — a setting in the file can be overridden at startup, so check getParameter and db.adminCommand on the server for the live truth. It cannot see the users and roles in the admin database — the people who can actually log in live in the database, not in mongod.conf. It cannot see the MongoDB version or whether it is end-of-life, the firewall in front of port 27017, the keyFile permissions on disk, or whether the TLS certificate is valid. And it cannot see total RAM, so a cacheSizeGB it calls absent is a fact, but whether the limit you pick is right depends on the box.
To audit yours in five minutes: copy the config (or the one file you care about), paste it into the MongoDB Config Auditor — it runs entirely in your browser, and the config is never uploaded, which matters because a config names hosts, key file paths and internal hostnames you do not publish. Fix the errors first (no authorization, a public bind, test commands enabled, a removed engine), then the warnings, then work through the infos as a list of defaults worth setting explicitly. Export the findings CSV if you want the checklist in a ticket. Then check the live values on the server — db.adminCommand({ getParameter: 1, authenticationMechanisms: 1 }) and friends — and create the users the config alone cannot give you, because a config that enables authentication without users locks everyone out, including you.
The broken demo config
# Demo mongod.conf — deliberately broken. Do not deploy.
net:
port: 27017
bindIp: 0.0.0.0
maxIncomingConnections: 200000
tls:
mode: disabled
storage:
journal:
enabled: false
engine: mmapv1
security:
javascriptEnabled: true
setParameter:
enableTestCommands: 1
operationProfiling:
mode: all
slowOpThresholdMs: 5000
systemLog:
quiet: true
destination: syslog
replication:
oplogSizeMB: 256
processManagement:
fork: true