How to Configure MongoDB Atlas Drop Table Protection
You set up mongodb atlas drop table protection by building custom database roles. These custom roles grant write actions without the drop collection action. In MongoDB, collections hold your data just like tables do in SQL. Most teams start by giving developers the standard read and write role. That default role includes the power to drop any collection in the database. One bad script or wrong click can wipe out production data in seconds. How to set up mongodb atlas drop table protection Mon
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 drop table protection by building custom database roles. These custom roles grant write actions without the drop collection action. In MongoDB, collections hold your data just like tables do in SQL. Most teams start by giving developers the standard read and write role. That default role includes the power to drop any collection in the database. One bad script or wrong click can wipe out production data in seconds.
How to set up mongodb atlas drop table protection
MongoDB controls database access through role-based rules. A role gives a user permission to run specific actions on set resources. You can scope a role to a whole database or one specific collection. MongoDB Atlas has its own built-in roles for cloud users. These cloud roles use the same core privilege actions as self-hosted MongoDB.
The built-in read role lets users view non-system collections. It allows actions like find, list collections, list indexes, and view stats. It does not let users insert, update, remove, or drop a collection. When engineers need to fix data, teams often switch them to the readWrite role. The readWrite role grants all read actions plus data change permissions. Still, it bundles insert, update, and remove with dropCollection and dropIndex.
To prevent drops, you must avoid the standard readWrite role for human users. Instead, you create a custom role inside your cloud control panel. You add only the read, insert, update, and remove actions to this role. You leave the dropCollection and dropDatabase actions out of the custom role. Then you assign this restricted role to your engineers and service accounts. When a user tries to drop a collection, the database rejects the command.
What native roles solve and what they leave open
Custom roles stop accidental collection drops at the database engine level. They work well when a user only needs to add or edit documents. They also let you lock down specific collections while leaving temporary ones open. This setup stops a single drop command from deleting a whole collection.
Still, static roles only check who logs in and which action they call. They do not inspect the actual contents or scope of a command in flight. An engineer with the remove action cannot drop a collection. Yet that same engineer can run a remove command with an empty filter. That command deletes every single document inside the collection without dropping it. The table stays in place, but all your production records are gone.
MongoDB Authentication & Authorization + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Static roles also create day-to-day friction for database maintenance. Sometimes an engineer must drop a staging collection or remove a broken index. If you strip those actions from their role, they get stuck. Admins then grant broad roles again during urgent fixes and forget to revoke them. Also, role permissions do not hide sensitive data in query results. Anyone who can run find on a user collection sees raw emails, phone numbers, and card numbers.
Why teams pair role limits with command checks
Relying only on database roles forces a hard choice between safety and speed. Give too little access, and your team cannot fix production bugs fast. Give the standard readWrite role, and a typo can ruin a collection. You also have to manage custom roles across dozens of clusters by hand.
To close this gap, teams add checks at the command level. Instead of permanent write access, engineers request approval for a single risky task. A reviewer checks the exact command before it runs on the database. At the same time, data masking rewrites emails and card numbers in query results. This approach keeps collections safe from both drop commands and bulk deletes.
Inspect MongoDB wire traffic in flight
Built-in MongoDB roles govern collection access at setup time. They cannot score command risk per call or mask sensitive document values on the fly. By design, hoop.dev sits inline in the MongoDB protocol next to your server as a sidecar for your MongoDB. On every production command from mongosh, drivers, or AI agents, hoop.dev decides whether to pass, mask, block, or hold it for human review.
First, hoop.dev guardrails block bad deletes, drops, and write pipelines or hold them for approval. Next, hoop.dev data masking rewrites sensitive values in returned documents in memory and logs each decision. Explore the repo on GitHub.
Frequently asked questions
Does the MongoDB readWrite role allow users to drop collections?
Yes, the built-in readWrite role includes the dropCollection action by default. Any user with this role can delete entire collections in that database. You must use a custom role to allow writes while blocking drops.
Can you block collection drops for just one specific collection?
Yes, MongoDB roles can target resources down to the collection level. You can grant full permissions on temporary collections and restrict critical ones. This requires building custom roles that list each collection name and its allowed actions.
Does blocking dropCollection stop users from deleting all data?
No, removing the dropCollection action only stops the collection structure from being deleted. If a user still has the remove action, they can delete every document inside it. You need command-level review or approval rules to stop bulk document deletes.
Related guides
In this post