MongoDB Unauthenticated Access
Unauthenticated MongoDB access occurs when the instance is started without the --auth flag or with security.authorization: disabled in the config file. Any connecting client has full access to all databases and collections without credentials. Detection here confirms the condition and scopes the exposure — how many databases exist, whether write access is also open, and whether sensitive collections are directly readable. Confirmed unauthenticated access moves to unauthenticated data extraction.
Confirm Unauthenticated Read Access
The fastest confirmation is a non-interactive version check. A version string returned without credentials confirms the instance is open:
6.0.5
Check connection identity explicitly to confirm no authentication was performed:
{ authenticatedUsers: [], authenticatedUserRoles: [] }
Empty arrays with no error confirm unauthenticated access. If the connection instead returns an error like command listDatabases requires authentication, authentication is enforced and this path is closed.
Scope the Database Exposure
List all databases to establish what is accessible and prioritize targets:
admin 102400 appdb 81920 users 40960 analytics 204800 local 40960
admin: system.users, system.roles, system.version appdb: users, sessions, orders, api_tokens users: accounts, profiles analytics: events, metrics, logs
Collections named users, accounts, sessions, api_tokens, and credentials are immediate extraction targets. The admin database's system.users collection contains password hashes for all MongoDB users.
Confirm Read Access on Collections
Verify that collection data is readable by pulling a sample document:
{
_id: ObjectId('507f1f77bcf86cd799439011'),
username: 'admin',
password: '$2b$12$abc123hashhere',
email: '[email protected]',
role: 'administrator'
}
Confirm Write Access
Test whether the anonymous connection can write. Insert a test document and immediately delete it:
{ acknowledged: true, insertedId: ObjectId('...') }
true
Warning
Always clean up test writes immediately. Use a dedicated collection name that makes the pentest origin obvious, and drop it immediately after confirming write access.
Confirmed write access means an attacker can modify application data, insert backdoor accounts into the application's user collection, and corrupt records. Move to unauthenticated data extraction to dump high-value collections, and check dangerous configuration checks to understand the full misconfiguration picture.
References
-
MongoDB — Enable Authenticationwww.mongodb.com/docs/manual/tutorial/enable-authentication (opens in new tab)
Official documentation for enabling authorization on MongoDB instances
Was this helpful?
Your feedback helps improve this page.