How to Configure Cosmos DB Column Level Security
You set up cosmos db column level security with client encryption or split containers. The database engine does not block specific JSON properties with native role rules. Most teams build an app service or use the client SDK to protect fields. When a user gets a broad read role, they can read the whole document. That role exposes every plain text field inside the container at once. How cosmos db column level security works in practice This database stores records as JSON items inside containe
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 cosmos db column level security with client encryption or split containers. The database engine does not block specific JSON properties with native role rules. Most teams build an app service or use the client SDK to protect fields. When a user gets a broad read role, they can read the whole document. That role exposes every plain text field inside the container at once.
How cosmos db column level security works in practice
This database stores records as JSON items inside containers rather than flat tables. Native role access works at the account, database, or container level. A read role lets a user fetch the entire JSON document. It does not filter out single fields like emails or phone numbers.
To lock down specific fields, teams take one of two paths. The first path splits secret fields into a separate container. You keep basic profile data in one container for general readers. Then you place card numbers or national IDs in a locked container. Only specific roles get permission to read that second container. This approach forces the team to manage extra queries and data sync steps.
The second path uses client-side field encryption through the official SDK. Your app encrypts sensitive fields before it writes the document to the database. You store the encryption keys in a cloud key vault. Users with the right key permissions can decrypt those fields during a read. Users without key permissions see only cipher text in those JSON fields.
What native roles solve and what they leave open
Container roles and client encryption work well for automated apps. You can give each service its own identity and key permissions. This setup decides who can log in and which containers they can touch.
The gap appears when engineers or analysts need direct database access to fix bugs. Native roles decide who logs in, not what individual queries do in flight. If an engineer has a read role, they can run a broad query. And if they have key access for debugging, the SDK decrypts the fields.
Column-Level Encryption + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Splitting data across containers also adds work for the whole team. Every schema change requires updates to sync logic and query code. Client encryption also limits how you can query encrypted fields in the database. Teams often skip encryption on fields like emails so queries still work. That trade-off leaves sensitive fields in plain text for anyone with container read access.
Why query-time controls matter for document stores
Teams need a way to inspect live queries and rewrite sensitive fields in results. When you control data in flight, you do not need to split containers. You can keep one clean document model for your apps. At the same time, you can protect emails, phone numbers, and card numbers during ad-hoc reads.
Instead of giving engineers full keys or broad roles, you check each request. Masking rewrites matched fields in results before the payload reaches the user screen. This keeps daily debugging fast while keeping sensitive fields safe.
Check database and API queries on the wire
Identity tools, roles, and network rules decide who opens a session. Setup alone cannot check what each query does or mask sensitive values in a response once a session starts. When workflows touch Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, or internal HTTP APIs, hoop.dev sits inline in the wire protocol beside those services as an open-source proxy, a sidecar for your Postgres or API. On every query an AI agent or engineer runs against production, hoop.dev decides to pass, mask, block, or hold it for human review.
Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run, and hoop.dev data masking rewrites matched sensitive values in responses in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and writes every query and decision to an audit trail that generates evidence for HIPAA, GDPR, and PCI DSS. See the source on GitHub.
Frequently asked questions
Does Cosmos DB have native column-level access rules?
No, native roles apply to accounts, databases, or containers. They cannot hide specific JSON properties inside a single document on their own.
How does client-side encryption protect specific fields?
The client SDK encrypts chosen JSON properties before sending data to the database. Only callers with access to the cloud key can read the plain values.
When should a team split documents across two containers?
Split containers work when only one small service needs secret fields like national IDs. Most other readers can query the main container without needing extra permissions.
Related guides
In this post