MongoDB Atlas Access Control
You set up mongodb atlas access control by giving database roles to users. Each role lets a user run specific actions on a database or collection. Teams use these built-in and custom roles to limit what people and apps can do. This model stops unauthorized changes, but it cannot filter sensitive fields inside returned documents. How mongodb atlas access control works in practice MongoDB uses role-based rules to manage who can touch data. A role gives a user the right to run actions on set re
Your coding agents run with your access.
Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.
You set up mongodb atlas access control by giving database roles to users. Each role lets a user run specific actions on a database or collection.
Teams use these built-in and custom roles to limit what people and apps can do. This model stops unauthorized changes, but it cannot filter sensitive fields inside returned documents.
How mongodb atlas access control works in practice
MongoDB uses role-based rules to manage who can touch data. A role gives a user the right to run actions on set resources. Each role works on the database where you define it. It can grant rights down to a single collection.
MongoDB Atlas users have different built-in roles than self-hosted database users. Both systems build their roles from the same basic privilege actions. Engineers and AI agents get a role before they send any queries.
The basic read role lets a user read all non-system collections in a database. It also covers the system JavaScript collection. This role allows actions like find, list collections, and list indexes. It also allows database stats, collection stats, and change streams. The read role blocks insert, update, remove, and drop collection actions.
When an engineer or script needs to change data, teams assign the read and write role. This role includes every action in the read role. It also adds the right to modify data. It allows insert, update, remove, and create collection actions. Users with this role can also create or drop indexes and drop collections.
AI agents often need broad read rights to answer support or data questions. If you give an agent the read role, it cannot delete or alter records. This keeps production tables safe from bad write queries during automated runs.
MongoDB Authentication & Authorization: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Security tradeoffs of static roles and active sessions
Database roles do a good job of separating read work from write work. Still, roles stop working at the collection boundary. Once a user or agent can read a collection, they can read every field in it.
A standard read role returns the full document for every matched query. If that collection holds customer records, the query result includes raw private data. Dynamic data masking solves this by rewriting matched fields in query results. For example, masking can rewrite emails, phone numbers, card numbers, or national IDs on the fly.
Static credentials also create day-to-day operational work for platform teams. Engineers often share database passwords or keep long-lived keys on their laptops. If an attacker steals a key, they get every right tied to that role.
Also, role definitions do not approve individual commands during an active session. A user with write rights can drop a collection without a second check. Teams often need command-level reviews and field masking to close these gaps.
Check MongoDB commands and documents on the wire
MongoDB roles and SCRAM login decide who opens a session. They do not check single commands or redact sensitive fields inside returned documents. With hoop.dev, you run an open-source proxy, a sidecar for your MongoDB, inline in the MongoDB wire protocol. On every command an AI agent or engineer runs against production, hoop.dev decides to pass, mask, block, or hold it for human review.
Before a command runs, hoop.dev guardrails check its effect and refuse banned drops or writes with MongoDB error code 13, or hold risky commands for approval. On the way back, hoop.dev data masking rewrites sensitive fields in returned documents in memory, and every verdict is logged. See the open-source code on GitHub.
Frequently asked questions
What is the lowest level of resource control in MongoDB?
A role applies to the database where you define it. It can grant rights down to the collection level, not to single documents or fields.
What is the difference between read and readWrite roles?
The read role lets users find data, view stats, and list collections or indexes. The readWrite role adds actions to insert, update, remove, and drop collections or indexes.
Do MongoDB Atlas and self-hosted MongoDB use the exact same built-in roles?
No, MongoDB Atlas database users have different built-in roles than self-hosted users. Still, both sets of roles use the same underlying privilege actions.
Related guides
In this post