MongoDB Atlas Project Data Access Read Only

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up mongodb atlas project data access read only permissions through role-based rules. These rules let users read database records while blocking all write and delete actions. Teams use read-only roles when developers, analysts, or AI agents need to inspect data. A read role stops accidental edits to live tables. Yet it still returns every field inside a matched collection. Understanding how roles work helps you close those data exposure gaps. How mongodb atlas project data access read

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 project data access read only permissions through role-based rules. These rules let users read database records while blocking all write and delete actions.

Teams use read-only roles when developers, analysts, or AI agents need to inspect data. A read role stops accidental edits to live tables. Yet it still returns every field inside a matched collection. Understanding how roles work helps you close those data exposure gaps.

How mongodb atlas project data access read only works

MongoDB controls database permissions through roles. Each role grants a set of actions on a target resource. A role applies to the database where you define it. You can scope permissions down to a single collection.

MongoDB Atlas database users have different built-in roles than self-hosted deployment users. Both types of roles use the same core privilege actions. The standard read role grants read access to all non-system collections in its database. It also covers the system JavaScript collection.

Under the hood, the read role permits specific query actions. Users can run find queries, list collections, list indexes, and check database stats. They can also check collection stats and open change streams. The read role leaves out insert, update, remove, and drop collection actions. If a user needs to change records, they need the read and write role instead.

Engineers and AI tools use these read permissions to debug issues and run reports. When a user connects with a read role, the database checks every command. If the command tries to alter data, the database blocks it right away.

Security tradeoffs of static roles and credentials

Built-in read roles stop unauthorized writes, but they do not solve every security problem. A role only checks if a user can read a collection. It does not filter what sits inside the documents of that collection.

Auditor Read-Only Access + Temporary Project-Based Access: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

When a developer runs a find query, the database returns full documents. Those documents often hold sensitive fields like emails, phone numbers, card numbers, or national IDs. A read-only role cannot hide specific fields inside a collection on its own. Every person or script with that role gets the full document payload.

Static database credentials create another risk for operations teams. Teams often share one read-only user login across many people or automated scripts. When everyone shares one login, audit logs only show the shared role name. You cannot tell which engineer ran a heavy query or exported customer records.

Long-lived passwords also stay valid until someone rotates them by hand. If a developer leaves the team, you must update keys across several apps. Adding field-level masking and per-user identity checks closes these gaps. Data masking rewrites matched fields like emails or card numbers in query results. Tying queries to individual user identities also gives you clear audit logs.

Managing read access for humans and AI agents

Modern teams grant database read access to both human engineers and AI agents. AI agents query collections to answer support questions or summarize system state. Giving an agent a raw read role exposes sensitive customer fields to the model prompt.

A safer setup combines database read roles with an external policy layer. You keep the database user restricted to read actions at the storage layer. Then you add identity checks and field masking in the path of the query. This approach keeps production data safe from writes and hides sensitive strings in results.

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

What is the lowest level of granularity for a MongoDB role?

A MongoDB role applies to the database where you define it. It can grant access down to the collection level of granularity.

Which actions are blocked by the built-in read role?

The built-in read role blocks all data modification commands. It excludes insert, update, remove, create collection, and drop collection actions.

Does a read-only role hide sensitive fields like emails or card numbers?

No, collection-level read roles return entire documents to the user. To hide emails, phone numbers, or card numbers, you need data masking that rewrites matched fields in results.

The query runs. The emails stay hidden.