MongoDB Service Discovery and Access Validation
Service discovery confirms that a port running MongoDB is actually MongoDB, retrieves the version, and establishes whether authentication is enforced. A version without authentication is an immediate finding — move to unauthenticated access to confirm the scope of exposure. Default port is 27017, but 27018 and 27019 are used in replica sets and sharded clusters.
nmap Service Detection
Run nmap with version detection and the MongoDB-specific NSE scripts to get version, build info, and database list without touching the shell:
27017/tcp open mongodb MongoDB 4.4.18 | mongodb-info: | MongoDB Build info | version = 4.4.18 | javascriptEngine = mozjs | Server status | connections | current = 2 | available = 838858 | uptime = 3742 |_ ok = 1
| mongodb-databases: | databases | 0 name = admin sizeOnDisk = 102400 empty = false | 1 name = appdb sizeOnDisk = 81920 empty = false | 2 name = local sizeOnDisk = 40960 empty = false |_ totalSize = 225280
The mongodb-databases script returning database names without authentication is a confirmed unauthenticated exposure. Note the version from mongodb-info and cross-reference it against the MongoBleed affected version table immediately.
Run Both Scripts Together
Validate Access with mongosh
Connect interactively to confirm whether authentication is enforced. A successful connection without credentials confirms unauthenticated access:
Current Mongosh Log ID: abc123 Connecting to: mongodb://10.10.10.50:27017/ Using MongoDB: 4.4.18 Using Mongosh: 2.1.0 test>
A prompt without an authentication challenge confirms unauthenticated access. Run a quick check to confirm what identity the connection has:
{
authInfo: {
authenticatedUsers: [],
authenticatedUserRoles: []
},
ok: 1
}
Empty authenticatedUsers and authenticatedUserRoles confirms the connection is unauthenticated. Move to server configuration enumeration to understand why auth is absent, and to unauthenticated access testing to establish the full scope.
Non-Interactive Version Check
Quick one-liner for scripted checks across multiple hosts:
4.4.18
10.10.10.50: 4.4.18 10.10.10.51: no access 10.10.10.52: 6.0.5
References
-
nmap — mongodb-info NSEnmap.org/nsedoc/scripts/mongodb-info.html (opens in new tab)
Version and build info retrieval without authentication
-
nmap — mongodb-databases NSEnmap.org/nsedoc/scripts/mongodb-databases.html (opens in new tab)
Unauthenticated database list enumeration
-
Official MongoDB shell download
Was this helpful?
Your feedback helps improve this page.