MongoDB Atlas Firewall Rules

Published
Length
3 min read

Luis Felipe Dias

All posts

You use mongodb atlas firewall rules to control which network addresses reach your database clusters. These network rules block unknown traffic before any user tries to log in. Network lists are the first barrier for cloud databases. They stop outsiders from reaching your data ports. Still, network checks alone cannot control what happens inside an active database session. How mongodb atlas firewall rules work in practice Every cloud cluster sits behind a network filter. By default, the plat

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 use mongodb atlas firewall rules to control which network addresses reach your database clusters. These network rules block unknown traffic before any user tries to log in.

Network lists are the first barrier for cloud databases. They stop outsiders from reaching your data ports. Still, network checks alone cannot control what happens inside an active database session.

How mongodb atlas firewall rules work in practice

Every cloud cluster sits behind a network filter. By default, the platform blocks all incoming traffic from the public internet. An admin must add trusted IP addresses or network ranges to an allowlist.

When an engineer or an AI agent connects, the network layer checks the source IP. If the IP matches a rule, the connection reaches the database login prompt. If the IP does not match, the firewall drops the packet right away.

Teams also use private network links between their cloud apps and the database. These private links keep traffic off the public internet. Even with private links, admins still manage network rules to separate staging from production.

Once a connection passes the network check, MongoDB uses role-based rules to control actions. A role grants rights to run specific actions on a database. Roles can grant access down to a single collection.

MongoDB Atlas database users have different built-in roles than self-hosted users. Still, both types of roles use the same core privilege actions. Network rules and database roles work together to protect your data.

Security tradeoffs of network rules and static roles

Relying only on network rules creates operational headaches for remote teams. Home IP addresses change often, and AI agents may run from shared cloud runners. Admins end up adding broad IP ranges just to keep work moving.

Broad network rules mean anyone on that network can reach the login prompt. Once inside, static credentials and database roles decide what the user can do. If an engineer shares a database key, the firewall cannot tell who is typing.

MongoDB Authentication & Authorization + AWS Config Rules: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

The built-in read role lets a user read all non-system collections in a database. It allows actions like find, listCollections, listIndexes, dbStats, collStats, and changeStream. It also includes the system.js collection, while blocking insert, update, remove, and dropCollection.

The readWrite role includes everything in the read role plus rights to change data. Its actions include insert, update, remove, createCollection, createIndex, dropIndex, and dropCollection. A user with this role can delete whole collections if they make a mistake.

Even a read role exposes raw data inside an active session. When a query runs, the database sends back full documents from the collection. Those documents often hold sensitive fields like emails, phone numbers, card numbers, or national IDs.

Network firewalls do not inspect the queries or the data inside an approved connection. Static roles also cannot hide specific fields inside a collection. Teams need controls that inspect commands and rewrite sensitive fields in query results.

Why teams pair network rules with query controls

Modern engineering teams keep their network allowlists small and strict. Instead of adding every laptop IP, they route database traffic through a single point. This setup keeps the cloud firewall list clean and easy to check.

At the same time, teams move away from shared static passwords. Each engineer or automated service logs in with their own identity. Admins can then check every query against the person who ran it.

Data masking adds another layer of safety during live sessions. When a query returns documents, masking rewrites matched fields like emails or card numbers. Engineers can fix app bugs without pulling raw customer records onto their laptops.

Add command guardrails and field masking beside MongoDB

Collection roles and IP rules control who connects to MongoDB. Yet an active client or agent session can still run a pipeline that writes data or reads raw personal fields. In practice, hoop.dev sits inline in the wire protocol beside your database as a sidecar for your MongoDB. For every command an agent or human sends in production, hoop.dev decides to pass, mask, block, or escalate it for review.

Using hoop.dev MongoDB controls, guardrails refuse banned commands before they run or hold risky calls for approval, and data masking rewrites matched fields in returned documents in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and generates evidence for GDPR, HIPAA, and PCI DSS programs. View the project on GitHub.

Frequently asked questions

Do mongodb atlas firewall rules block bad queries?

No, network firewall rules only check the source IP address of a connection. Once a connection passes the IP check, the firewall does not read database commands. Database roles and query controls must handle what commands a user can run.

What is the difference between read and readWrite roles in MongoDB?

The read role lets users view non-system collections using actions like find and listCollections. It blocks data changes like insert, update, remove, and dropCollection. The readWrite role adds those write actions so users can change or delete data.

Can database roles hide sensitive fields inside a collection?

MongoDB roles grant access down to the collection level, not the field level. If a user has read access to a collection, queries return the full documents. To hide fields like phone numbers or national IDs, you need data masking.

The query runs. The emails stay hidden.