Data masking software for databases and AI agents

Formal's Connector sits between your databases and the people, BI tools and AI agents that query them. Policies mask sensitive columns in each result based on who is asking, with no data copies, no schema changes and no masking rules to rewrite in every engine.

psql · prod-postgresexample
# same query, two identities, same policies
SELECT email, ssn FROM users LIMIT 1;
ALLOW   dana (pii_access)   jane@example.com | 123-45-6789
MASKED  maya (support)      ****@example.com | NULL

The problem

Why does data masking software belong in the access path?

Data masking software replaces sensitive values with NULLs, hashes, fake values or partial strings, so people and programs can use data without reading what it protects. Many data masking tools work on a test copy of the database or through rules inside one engine. Meanwhile engineers, dashboards and AI agents read the same production tables, sometimes through one shared login, and PII also leaves through LLM prompts, outside any database.

  1. Agents and BI tools reading production data

    A coding agent or a dashboard runs the same SELECT an engineer would, and the database returns every column it asked for.

  2. Masking rules copied into each database

    Rules typed into each engine follow that engine's roles and syntax, so every new database needs its own copy and the copies drift.

  3. One shared login for many readers

    The database sees one BI machine user for every viewer, and none of its rules knows which person sits behind that login.

today · no policy on the pathexample
01
claude-code · psqlSELECT email, ssn FROM usersALLOWED
02
maya · snowflakeSELECT card_number FROM paymentsALLOWED
03
metabase (shared login)SELECT name, email, ssn FROM customersALLOWED

# Without a policy at the proxy, all three return values in clear.

Definition

What is dynamic data masking?

dynamic data maskingnoun

Dynamic data masking (DDM) replaces sensitive values in query results at read time, based on who runs the query, and leaves the stored data unchanged.
  • Static masking writes a copy

    Static data masking writes a masked copy of a database, often a subset, for test environments. Formal does the dynamic kind only: if you need test datasets, you want static masking tools.

  • Some databases ship DDM natively

    Snowflake applies masking policies to columns at query time, an Enterprise Edition feature in its documentation as of November 2026, and our Snowflake data masking page shows how Formal’s policies sit beside them. SQL Server has its own feature.

  • Native masking works one engine at a time

    Each engine has its own policy syntax and role model, and none of them knows which person sits behind a shared BI or service account. Formal does database masking at a proxy in front of production instead, on every query, decided by who is asking.

Why the proxy

Why run data masking software at the proxy instead of in each database?

The Formal Connector, a reverse proxy in your VPC, parses each database wire protocol. Masking happens on the response: after the database returns rows, before the client sees them. Policies are written in Rego.

Masking in each databaseMasking at the Formal Connector
EnginesOne masking feature and one policy syntax per engineThe same rule masks Postgres, Redshift, MySQL, MariaDB, Snowflake, BigQuery and MongoDB results, plus CSV objects read from S3 with GetObject
IdentityDatabase roles, which have to mirror your org chartThe Formal user, their groups and, for BI tools, the end user behind the machine user
ColumnsA rule on the column as it's named in the tableLineage-aware: in SELECT email FROM users UNION SELECT email FROM customers, a mask on either source column masks the whole result column, and wildcards and joins resolve the same way
LogsSpread across each engine's audit settingsEvery masked query is logged with the policy that triggered it, so you can chart masking per resource or check which policy masked a column for a given user

How it works

How data masking works with Formal

  1. Step 1 of 4

    Put the Connector in the path

    Deploy the Connector in your VPC and point clients, BI tools and agents at its hostname instead of the database. Each connection authenticates as a Formal user or machine user.

    YOUR VPCexample
    • prod-postgres behind the Connector✓
    • snowflake behind the Connector✓
    • metabase points at the Connector hostname✓
  2. Step 2 of 4

    Label sensitive columns

    The Data Discovery Satellite catalogs databases, tables and columns and applies regex or prompt labels. You can also set labels in the Control Plane, through the API or with Terraform.

    DATA INVENTORYexample
    • app.public.customers.emailEMAIL_ADDRESS
    • app.public.customers.ssnSOCIAL_SECURITY_NUMBER
    • app.public.payments.card_numberCREDIT_CARD_NUMBER
  3. Step 3 of 4

    Write a response policy

    A Rego rule returns the mask action with a type, a subtype and the columns to mask, conditioned on labels, groups or the end user. Run it in dry-run mode first.

    DRY RUNexample
    • SELECT email FROM customers · would nullifyDRY RUN
    • SELECT ssn FROM employees · would nullifyDRY RUN
    • SELECT region FROM customersALLOWED
  4. Step 4 of 4

    Rows are masked in flight

    The Connector evaluates response policies on each returned row, masks matching values before they reach the client, and logs which policy fired.

    ACTIVEexample
    • SELECT email FROM customersMASKED
    • SELECT ssn FROM employeesMASKED
    • SELECT region FROM customersALLOWED

Per reader

PII masking per user, per BI viewer and per agent

PII masking follows the identity on the connection. People connect with their own Formal identity, so a rule can key on input.user.groups. BI tools connect as a machine user and pass the viewer’s identity, so the rule keys on input.end_user instead.

BI tools

Mask by who reads the dashboard, not by the BI tool's login

BI tools connect with one shared machine user. Formal resolves the person behind each query from Metabase, Looker, Omni, Sigma, Hex or your own app (through formal-sqlcommenter) and evaluates masking policies against that end user. Our post on the Metabase zero day makes the case: masking PII before it reaches the BI tool limits what a compromised dashboard server can expose.

  • input.end_user carries the viewer’s groups, not the machine user’s
  • A viewer outside pii_access gets NULL where a privileged viewer gets the value
  • Logs and sessions show the end user next to the BI tool’s machine user
BI integration docs ›
metabase · prod-postgresexample
katie@example.com · groups: analyst> SELECT name, email, ssn FROM customers LIMIT 2
nameemailssn
Jane DoeNULLNULL
Tom BergNULLNULL
2 rows · policy nullify unless pii_accessMASKED
AI agents

Masked for Claude Code, in clear in the engineer's own psql

An agent that runs as a machine user has its own identity and its own policies. When a coding agent connects through the Formal Endpoint, response policies also see input.agent, including the agent type, so a column can come back masked to Claude Code and in clear to the engineer’s own psql session.

  • Agents get their own machine user instead of an engineer’s database password
  • input.agent tells the agent’s query from the engineer’s on the same laptop
psql · prod-postgresexample
10:02:11claude-code for mayaSELECT email FROM customersMASKED
10:04:37maya · psqlSELECT email FROM customersALLOWED
AI assistants

Hiding sensitive columns from an AI assistant without blocking analysis

Blocking the customers table means the assistant can’t answer anything about customers. Data masking for AI keeps the rows and columns and changes only the values, so the assistant can still count accounts per region, join orders to customers and spot a trend, while names and emails come back masked.

  • Hash join keys with hash.no_salt: the same input always gives the same hash, so joins and GROUP BY still line up
  • Nullify free text the assistant has no reason to read
  • Set typesafe_fallback so a masked date doesn’t break the next query the agent writes, and use reduce_decimal_precision where rounded amounts are enough
  • For a chatbot that queries a database for whoever is chatting, have the app pass that person as the end user through formal-sqlcommenter, and the masking follows their groups instead of the bot’s machine user
assistant · prod-postgresexample
support-assistant for maya> SELECT region, customer_id, email FROM customers LIMIT 3
regioncustomer_idemail
EU9f2c41e0NULL
EU4a7b0c13NULL
USd81e5f72NULL
3 rows · policy hash.no_salt + nullifyMASKED
Rows

Remove whole rows with the filter action

Masking hides values; the filter action removes whole rows. With the Policy Data Loader, a support engineer can see a customer’s row only while a Zendesk ticket for that customer is open, as in the filter example.

psql · prod-postgresexample
14:20:05sam (support)SELECT * FROM customers WHERE plan = 'pro'FILTERED
14:20:05policyrows kept: customers with an open Zendesk ticket for samFILTERED

Masking types

Data masking techniques a policy can apply

A mask decision has a type, which sets the privacy level, and a sub_type, which picks the transformation. When two policies mask the same column, the higher privacy level wins, and a block beats an allow.

  • nullify

    The reader gets NULL.

    Privacy level 4
  • hash.with_salt

    A salted hash that changes on every read.

    Privacy level 4
  • fake

    A realistic fake value: name, email, SSN, phone, address or card.

    Privacy level 3
  • redact.constant_characters

    A constant string such as [REDACTED].

    Privacy level 3
  • hash.no_salt

    A deterministic hash: the same value hashes the same way on every read, so joins still work.

    Privacy level 2
  • redact.partial

    A partial mask, such as ****@example.com. Subtypes cover emails, names, SSNs, phone numbers, cards and addresses.

    Privacy level 1

Set typesafe_fallback to keep typed columns valid: a masked number, date or UUID comes back as NULL or a typed default instead of breaking the client (masking types).

Policy

Mask PII unless the end user has access

Here is the per-user masking policy from the BI integration docs. It nullifies emails, SSNs and phone numbers unless the end user is in the pii_access group.

  • The rule never names a table: it matches on data_label
  • A new email column picks up the mask as soon as a scan labels it
  • Run it in dry-run and check the masked values in the logs before you set it to Active
Per-user data masking docs ›
mask_pii_unless_access.regorego
package formal.v2

import future.keywords.if
import future.keywords.in

# Mask PII unless end-user has special access
response := {
  "action": "mask",
  "type": "nullify",
  "columns": pii_columns
} if {
  # Identify PII columns
  pii_columns := [col |
    col := input.row[_]
    col["data_label"] in ["email_address", "social_security_number", "phone_number"]
  ]

  count(pii_columns) > 0

  # End-user doesn't have PII access
  not "pii_access" in input.end_user.groups
}

LLM traffic

Can you redact PII before it reaches an LLM?

Yes, for LLM traffic that goes through the Connector. LLM resources are HTTP-based, so a request-stage rewrite can replace the request body and the session continues.

LLM traffic

Redact PII before a prompt reaches the model provider

Send LLM traffic to the Connector instead of the provider’s hostname. A rewrite policy inspects each message and swaps matching values in the body, for example with regex.replace on SSN patterns, before anything leaves. Redaction in prompts, tool calls and prompt logs is covered on AI DLP; for the wider view of prompts, responses and tool calls per user, see AI gateway. For data that reaches a model through retrieval, RAG vs MCP covers where masking applies in each pipeline.

  • input.llm.messages exposes the text and tool results of each message
  • rewrite with a new body, for example regex.replace on SSN patterns
  • Log schemas can encrypt or drop LLM content before Formal stores it
llm · anthropic.<connector-hostname>example
rewritesupport-botPOST /v1/messages · 123-45-6789 → [REDACTED-SSN]MASKED
forwardconnectorrequest forwarded to api.anthropic.comALLOWED

Buyer's checklist

What to look for in data masking tools

Shortlists of data masking solutions usually mix two products. Static masking and test data tools copy a database and transform the copy; dynamic masking tools change live results for each reader. Decide which job you have first. For dynamic masking in production, these are the questions we’d ask any vendor, Formal included.

  1. Placement

    It decides coverage. Masking inside a database covers that engine, masking in a BI tool covers its dashboards, and a proxy covers every client that connects through it, so check what can still reach the database around it.

  2. The real reader

    A database role sees one machine user for every Metabase viewer and one service account for every agent. Ask whether a policy can key on the person behind the BI login and the agent behind the service account, and whether the same query can return different values to each.

  3. Masked data that still works

    Joins, typed columns and aggregates have to keep working in the client, which the AI assistant example above walks through.

  4. Labels, not column lists

    Column lists maintained by hand go stale with every migration. Tools that mask by label, with labels kept current by a discovery scan, keep covering new columns, which is why discovery and dynamic data masking tools tend to be bought together. The scanning side is on our data classification tools page.

  5. What a wrong rule does

    In Formal, a mistyped mask type or sub_type leaves the value unmasked and logs no error (masking types). We’d rather tell you than have you find it in an audit: run every new masking policy in dry-run and check the masked values in the logs before you activate it.

  6. Logs and AI traffic

    Each masked query should be logged with the reader and the policy that fired, and an SSN pasted into a prompt to a model provider needs a rule as much as an SSN in a result set.

Coverage

Where does sensitive data masking apply?

Sensitive data masking applies to every session that goes through the Connector. Keep database credentials in Formal’s native users and give people and agents their own Formal identity, and every read passes your masking policies.

  • Sessions through the Connector

    Every query from a person, BI viewer or agent that connects with a Formal identity is checked against your response policies.

    Masked
  • Postgres exports

    With response policies on, COPY TO STDOUT and \copy are blocked, so exports run as SELECT and come back masked.

    COPY blocked
  • Bypass attempts

    Pair masking with a request policy that blocks constructs such as RESULT_SCAN or CLONE, as in the redact emails example.

    Block by policy
  • ClickHouse, Redis and MCP tool responses

    ClickHouse column masks aren’t supported and fail closed. MCP tool responses and Redis results aren’t masked.

    Not masked

Masking covers what an authorized session reads. Access control, encryption and query auditing cover the rest of database security.

Works with

Works with your data stores, BI tools and agents

The Connector parses each database wire protocol and masks the rows before they reach the client.

  • Postgres
  • Redshift
  • MySQL
  • MariaDB
  • Snowflake
  • BigQuery
  • MongoDB
  • Amazon S3
  • Metabase
  • Looker
  • Omni
  • Sigma
  • Hex
BI integrations and end-user identity ›

How it fits

Find the sensitive data, then decide what each reader sees

Masking is the enforcement side of data security for AI: discovery labels the sensitive columns, and the policies on this page decide what each reader gets back. The same Connector carries the prompts you redact with AI DLP and the sessions you govern with database access controls, with one Control Plane for every policy and log.

Formal Connector architecture for privileged access: engineers and AI agents connect through the Formal Connector in your infrastructure, which checks their identity, applies policies and signs in to Postgres, Snowflake, SSH hosts and Kubernetes as a native user.
The Connector holds the credentials. The Control Plane manages configuration and can't interact with your data.

Deployment

Runs in your environment, next to your databases

Formal Connector in your VPC

Linux on AMD64 or ARM64: AWS ECS Fargate behind a Network Load Balancer, or Helm on EKS, GKE, AKS or on-premises Kubernetes. In production, run 2 or more nodes behind a load balancer (deployment).

AWS PrivateLink to the Control Plane

On AWS, the Connector can reach the Formal Control Plane over AWS VPC PrivateLink.

Your identity provider

People sign in with SSO, and SCIM keeps users and groups in sync. Policies use the groups you already manage.

Logs in your SIEM

Log integrations forward Formal logs to AWS S3, Google Cloud Storage, Azure Blob Storage, Datadog, Splunk or Panther.

Policy and configuration as code

Policies are written in Rego. Manage Formal with Terraform, Pulumi or the Kubernetes Operator.

Audited controls

Formal holds SOC 2 Type II and ISO/IEC 27001. The reports are on security.formal.ai.

In production

RDS instances
100+
Deployment
<1 week
Users
100M+
“What's nice is that the developers who are using it don't even notice that they're using it. So it's working very seamlessly into our system. It's working in the background and it's not impacting developer velocity.”
Michelle Parent
Security Engineer, Notion
Read the Notion story ›

FAQ

Questions about data masking software

Buying and fit

What is data masking used for?

Teams mask data to give support, analytics and on-call engineers production access without exposing PII, to keep card numbers and health records out of BI tools and AI agents, and to build test datasets from production (that last one is static masking). Privacy programs under GDPR, HIPAA or PCI DSS use it to limit who sees personal, health or card data in clear.

What is an example of data masking?

A support agent queries a customer record and gets ****@example.com in the email column, while a payroll admin running the same query sees the full address. That’s partial redaction (redact.partial) with an email subtype, applied by a response policy at read time. Other masking types return NULL, a hash, a fake value or a constant string.

Which databases can Formal mask?

Formal masks columns in Postgres, MySQL, MariaDB, Redshift, Snowflake and BigQuery results, MongoDB fields by path, and CSV objects read from S3. MongoDB masking follows a field the command returns under another name, so a rule on ssn also masks it in find({}, {"exposed": "$ssn"}), and a request policy can block commands it can’t follow, such as $out (MongoDB policies). ClickHouse column masks aren’t supported and fail closed, MCP tool responses and Redis results aren’t masked, and SQL Server and Oracle aren’t Connector resource types.

Does PostgreSQL support dynamic data masking?

Not as a built-in feature: core PostgreSQL has column privileges and row security policies, which hide whole columns or rows but don’t transform values per reader. Our PostgreSQL data masking page shows how the Connector masks Postgres results, exports included.

Does data masking make you GDPR compliant?

Masking supports GDPR principles such as data minimization by limiting who sees personal data in clear, and query logs that monitor database activity show who read what. Compliance also depends on your processes and legal basis. Formal itself holds SOC 2 Type II and ISO/IEC 27001, listed on security.formal.ai.

Product

What are the best tools for anonymizing data?

Start with where the data goes. If a dataset leaves production for developers, a vendor or a model training job, you want static masking or anonymization tools that write a transformed copy. If people and agents read production, you want dynamic data masking tools that change results per reader, which is the category Formal is in; the criteria above apply to those. Hashed or partially redacted values can still be personal data under GDPR, so masking alone rarely makes a dataset anonymous.

What is the difference between data masking, encryption and tokenization?

Encryption is reversible with the key and protects bytes at rest or in transit. Tokenization swaps a value for a token and keeps the mapping in a vault, so an authorized system can get the original back. Data masking changes what a reader sees in a result and keeps no mapping: after nullify or salted hashing there is nothing to reverse, and the stored data is untouched. Use encryption or tokenization when a system must recover the value, and masking when a person or agent should never see it.

Mask data by who is asking

Data masking software at the proxy for people, BI viewers and agents, across your databases and LLM traffic.