Auditing MongoDB
MongoDB starts without access control unless someone turns it on: anyone who reaches port 27017 can read, write and delete. For years that was offset, almost by accident, by the server listening only on localhost. The problem appears when someone adds --bind_ip_all so that “it works from outside” and does not enable authorization. This card covers what is reviewed in an authorized audit of a self-managed MongoDB, with a real lab on version 9.0.8, and the equivalent settings in the managed Atlas service.
Responsibility model
Section titled “Responsibility model”On a self-managed MongoDB (Community or Enterprise), the customer decides everything. In Atlas, MongoDB runs the servers and enforces authentication and TLS, but the customer still decides:
- the IP access list or private connection used to get in;
- the database users and their roles;
- who has access to the Atlas organization and projects;
- backups and logs.
flowchart LR
A["Application"] -->|"TLS + SCRAM-SHA-256"| N{"net.bindIp<br/>which interfaces?"}
X["Internet"] -. "bindIpAll<br/>without authorization" .-> N
N --> S{"security.authorization"}
S -->|"disabled"| T[("Every database<br/>without credentials")]
S -->|"enabled"| U["User with readWrite<br/>on one database"]
U --> D[("Application database")]
L["Localhost exception"] -. "only until the<br/>first user exists" .-> S
Network: where it listens
Section titled “Network: where it listens”| Setting | Default | What to look for |
|---|---|---|
net.bindIp |
localhost only (since 3.6) |
bindIpAll: true or 0.0.0.0 without a reason |
| Port | 27017 | Reachable from the internet or from networks that do not need it |
net.tls.mode |
No TLS | requireTLS in any deployment with network traffic |
net.compression.compressors |
snappy,zstd,zlib |
After MongoBleed, drop zlib if you cannot upgrade |
The lab confirms it: started with no options, mongod refuses connections arriving on the machine’s IP address (ECONNREFUSED) and only answers on localhost.
Authorization and users
Section titled “Authorization and users”security.authorization: enabled. Without it there is no access control, even if users exist. The server itself warns in its log: “Access control is not enabled for the database”.- Localhost exception. With authorization on and no users, a connection from
localhostcan create the first user. As soon as one exists, the exception closes. A server with authorization and no users is still open to anyone on the machine itself. - Least-privilege roles.
- The application gets
readWriteon its database and nothing else. - User administration uses
userAdminAnyDatabase, separate from data access. root,dbOwner,*AnyDatabaseandrestoreare broad roles that need a justification each.
- The application gets
- Authentication mechanism. Users are created by default with both SCRAM-SHA-1 and SCRAM-SHA-256. You can restrict them to SHA-256 with
mechanisms: ["SCRAM-SHA-256"]when creating them. - Per-user IP restrictions.
authenticationRestrictionslimits where each user can connect from. - Auditing. The audit log (who did what) only exists in MongoDB Enterprise and Atlas. On Community you rely on the server log.
Lab: open, closed and audited
Section titled “Lab: open, closed and audited”MongoDB 9.0.8 and mongosh 2.14.3, from the official Ubuntu 24.04 repository, extracted without installing and with their SHA-256 checked against the repository index.
1. Open. mongod --bind_ip_all without --auth, and a connection from the machine’s IP address:
$ mongosh --quiet "mongodb://192.0.2.2:27117" --eval '…listDatabases…; …countDocuments()…; …connectionStatus…'admin, config, local, tienda2{"authenticatedUsers":[],"authenticatedUserRoles":[]}It lists the databases and counts the documents in tienda.clientes without authenticating.
2. Closed. The corrected configuration:
net: port: 27117 bindIp: 127.0.0.1,192.0.2.2 compression: compressors: snappy,zstdsecurity: authorization: enabledsetParameter: enableLocalhostAuthBypass: trueReal results (the step labels and the script’s own messages are translated; server errors and database names are as they came out):
--- from 192.0.2.2 without credentialsUnauthorized: Command listDatabases requires authentication--- localhost exception: create the first adminadmin createdUnauthorized <- second createUser from localhost: the exception is closedapp created--- app (readWrite on tienda)2 <- reads its collection[ 'tienda' ] <- listDatabases only shows the databases it can accessUnauthorized <- cannot read admin.system.users3. Audit. A mongosh script, run as a user with clusterMonitor and userAdminAnyDatabase:
const opts = db.adminCommand({ getCmdLineOpts: 1 }).parsed;print("bindIp :", opts.net?.bindIp ?? "(default: localhost)", opts.net?.bindIpAll ? "| bindIpAll" : "");print("authorization:", opts.security?.authorization ?? "DISABLED");print("TLS :", opts.net?.tls?.mode ?? "no TLS");print("compressors :", opts.net?.compression?.compressors ?? "(default: snappy,zstd,zlib)");print("version :", db.version());
const BROAD = ["root", "__system", "dbOwner", "userAdmin", "userAdminAnyDatabase", "readWriteAnyDatabase", "dbAdminAnyDatabase", "clusterAdmin", "restore"];db.adminCommand({ listDatabases: 1, nameOnly: true }).databases.forEach(d => { db.getSiblingDB(d.name).getUsers({ showCredentials: false }).users.forEach(u => { const roles = u.roles.map(r => `${r.role}@${r.db}`); const flag = u.roles.some(r => BROAD.includes(r.role)) ? " <- broad role" : ""; const mechanisms = (u.mechanisms || []).join("/"); print(`user ${u.user}@${u.db} [${mechanisms}]: ${roles.join(", ")}${flag}`); });});bindIp : 127.0.0.1,192.0.2.2authorization: enabledTLS : no TLScompressors : snappy,zstdversion : 9.0.8user admin@admin [SCRAM-SHA-1/SCRAM-SHA-256]: userAdminAnyDatabase@admin, clusterMonitor@admin <- broad roleuser app@tienda [SCRAM-SHA-1/SCRAM-SHA-256]: readWrite@tiendaTwo findings are left on purpose: TLS is missing, and the users also accept SCRAM-SHA-1.
MongoBleed and network compression
Section titled “MongoBleed and network compression”CVE-2025-14847, disclosed by MongoDB on December 19, 2025, is a server memory read without authentication:
- It is triggered by zlib-compressed messages whose headers declare inconsistent lengths.
- Decompression happens before authentication, so reaching the port is enough.
- The leaked memory can contain credentials, tokens or data from other sessions.
- CISA added it to its catalog of exploited vulnerabilities on December 29, 2025.
In the lab, a connection asking for compressors=zlib negotiates zlib without trouble on the default configuration: serverStatus().network.compression lists snappy, zstd and zlib, with byte counters for zlib. With compressors: snappy,zstd in the configuration, zlib disappears from the list. The real fix is upgrading; dropping zlib is the temporary measure the advisories recommended.
In Atlas, the review focuses on:
- Network access: each project’s IP access list without
0.0.0.0/0, or better a private connection (private endpoint or peering). - Database users: least-privilege roles, no shared users, and expiry for temporary ones.
- Organization and projects: MFA or SSO for members; Admin API keys with an IP access list and minimal permissions.
- Logs and backups: database auditing on if the plan includes it; backups with retention and a tested restore (see backups).
Real-world cases
Section titled “Real-world cases”- MongoBleed (December 2025). Described above: CVE-2025-14847, exploitable before authentication and added to CISA’s catalog on December 29. An unpatched, reachable server gave away memory even with users and passwords in place.
- 4.3 billion profiles (November 2025). On November 23, 2025, Cybernews and Bob Diachenko found a MongoDB without a password holding about 16 TB of professional profiles. The owner locked it down two days later. No vulnerability was involved: it is the same state as step 1 of the lab.
- 600 TB exposed (2015). Even then, the cause was old versions that did not limit themselves to
localhostby default. ThebindIpchange in 3.6 came later; an upgrade that keeps an inheritedbindIpAlldoes not fix it.
Checklist
Section titled “Checklist”-
bindIplimited to the interfaces needed; port not exposed to the internet; firewall in front -
security.authorization: enabledand at least one admin user created (localhost exception closed) - Application users with
readWriteon their database; broad roles justified one by one - Users with SCRAM-SHA-256 only;
authenticationRestrictionswhere it makes sense -
net.tls.mode: requireTLSwith valid certificates - A version that includes the CVE-2025-14847 fix; if you cannot upgrade,
zlibremoved from the compressors - Auditing on in Enterprise or Atlas; server log shipped to a SIEM on Community
- Atlas: IP access list without
0.0.0.0/0or a private connection; MFA or SSO in the organization; restricted API keys - Backups with a tested restore
References
Section titled “References”- MongoDB: Security Checklist for Self-Managed Deployments
- MongoDB: Localhost Exception
- MongoDB: Built-In Roles
- MongoDB Jira: SERVER-115508 (CVE-2025-14847)
- Rapid7: MongoBleed (CVE-2025-14847)
- Tenable: CVE-2025-14847 exploited in the wild
- CSA Singapore: High Severity Vulnerability in MongoDB Server
- eSecurity Planet: 4.3 Billion Records Exposed in Massive Lead-Generation Data Leak