What is dynamic data masking?
Dynamic data masking (DDM) hides sensitive values at the moment data is read, based on who is asking. The stored data does not change. A user with the right role sees the real value, and other users see a masked version, such as a phone number with only the last four digits showing.
For example, a bank’s customer database masks Social Security numbers for support reps, who see only the last four digits, while fraud analysts see the full number. Then the bank connects an AI assistant to the same database through one service account with broad access. The masking rules see a single identity, the service account, so the assistant receives full numbers and can repeat them to any support rep who asks.
How dynamic data masking works
- Rules are set on columns. An administrator marks columns such as SSN, email or salary as masked and defines the masked format.
- The query runs as usual. The database or a proxy in front of it applies the rule as results are returned.
- The role decides the result. Users with an unmask permission get real values. Everyone else gets the masked version.
- Storage stays the same. Nothing is rewritten on disk, so turning masking off restores full values at once.
Many databases and cloud data warehouses offer dynamic data masking as a built-in feature.
Dynamic vs static data masking
| Dynamic data masking | Static data masking | |
|---|---|---|
| When masking happens | At read time, per query | Once, when a copy is made |
| Stored data | Unchanged, real values | A new copy with masked values |
| Common use | Production systems with mixed user roles | Test, development and training data |
| Reversible | Yes, for users with permission | Usually no |
Limits of dynamic data masking in AI systems
DDM was built for people running queries against structured tables. AI systems stretch it in a few ways:
- Service accounts. AI agents and assistants often query data through one shared account, so the end user’s role never reaches the masking rule.
- Free text. DDM works on columns. Names and account numbers inside notes, emails and documents pass through unmasked.
- Copies leave the database. Once a value is in a prompt, a vector store or a log, database masking no longer applies to it.
- Inference. A user who can filter on a masked column may be able to guess values through repeated queries.
DDM is a useful control inside the database. It works best with protection that follows the data into AI workflows and checks the real user’s role at the point of use. This post on RBAC vs CBAC explains how role and context fit together.
How Protecto helps
Protecto masks sensitive values where data flows into AI, including prompts, retrieved context and tool outputs, and covers free text as well as tables. Real values are revealed by role through controlled unmasking and Context-Based Access Control (CBAC), based on the actual user or tool. Users without access see the data masked. See data access control for AI agents.
Frequently asked questions
What is the difference between static and dynamic data masking?
Static masking creates a masked copy of the data once, often for testing. Dynamic masking leaves stored data unchanged and hides values at read time based on the user’s role.
Does dynamic data masking replace encryption or access control?
No. The real values stay in storage, so DDM works alongside encryption and access controls. Users with high privileges can often still see or reach the real data.
Does dynamic data masking work on unstructured data?
Usually not. It is designed for columns in structured tables, so sensitive values inside free text such as notes or emails are not masked.
Related terms
Static data masking · Data masking · Controlled unmasking · Role-based access control (RBAC)