MariaDB data masking: the MaxScale filter, views and a proxy

MariaDB Server has no built-in data masking functions. MariaDB's own option is the masking filter of MaxScale, its database proxy, which rewrites result sets; MaxScale is not open source (Business Source License) and 26.10 needs a license key. Inside the server you mask with views and column privileges, or with generated columns.

What data masking is, and when you need it

Data masking returns a modified value instead of the real one: a***@example.com for an email, ****4242 for a card number. The row is still there and the query still works; the sensitive part is not in the result.

You need it in MariaDB when someone or something must query a table without seeing every column:

  • PII and payment data: emails, phone numbers, card numbers, national IDs.
  • Compliance: GDPR, PCI DSS and HIPAA programmes ask you to limit who sees personal and card data, and to show that you do.
  • Analysts and support: they need the rows, not the full card number.
  • AI agents: a SELECT email, card_number FROM customers is harmless for the database, and still puts personal data into an LLM's context.

Masking at read time (dynamic masking) leaves the stored data unchanged. Rewriting the stored data (static masking) is a different job, for copies such as test databases.

MariaDB Server has no masking functions

The MySQL Enterprise masking functions do not exist in MariaDB, and the MariaDB Server docs have no masking feature: every "masking" page in them belongs to MaxScale. On MariaDB 11.4.13 there is no routine named mask% in information_schema.ROUTINES and no plugin matching %mask% in information_schema.ALL_PLUGINS. What MariaDB does have is REGEXP_REPLACE, handy for masking expressions:

SELECT mask_inner('4111111111114242', 0, 4);
SELECT REGEXP_REPLACE('ana@example.com', '^(.)[^@]*', '\\1***');
ERROR 1305 (42000) at line 35: FUNCTION shop.mask_inner does not exist
a***@example.com

Tested on MariaDB 11.4.13 (mariadb:11.4), 2026-11-14.

The MaxScale masking filter

MaxScale's masking filter sits between client and server and replaces the values of named columns in the result set. The docs are clear about its scope: "the masking filter should be viewed as a best-effort solution intended for protecting against accidental misuse rather than malicious attacks."

Configuration

[MyMasking]
type=filter
module=masking
warn_type_mismatch=always
large_payload=abort
rules=masking_rules.json

[MyService]
type=service
...
filters=MyMasking

From the docs, not tested here: MariaDB MaxScale docs: masking filter

The rules file (a relative path resolves against /etc/maxscale.modules.d) holds {"rules": [...]}. Each rule has replace (a column, optionally table and database, and an optional pcre2 match for partial replacement) and with (value and/or fill; value is used only when its length matches exactly, otherwise fill, default X). Optional applies_to and exempted list accounts. An obfuscate rule replaces a value non-reversibly; the docs warn about brute force when the range of values is small.

{ "rules": [ { "replace": { "column": "ssn" }, "with": { "value": "012345-ABCD", "fill": "X" } } ] }

From the docs, not tested here: MariaDB MaxScale docs: masking filter

MaxScale> call command masking reload MyMaskingFilter

From the docs, not tested here: MariaDB MaxScale docs: masking filter

Parameters

ParameterDefaultWhat it does
rulesmandatoryPath of the rules file
warn_type_mismatchneverWarn when a masked column has a type the filter cannot mask
large_payloadabortignore or abort on results over 16 MB
prevent_function_usagetrueRejects functions over masked columns, such as SELECT CONCAT(masked_column) FROM tbl
require_fully_parsedtrueRejects statements MaxScale cannot fully parse
treat_string_arg_as_fieldtrueCovers the ANSI_QUOTES bypass
check_user_variables, check_unions, check_subqueriestrueReject masked columns read through user variables, unions and subqueries

Documented limitations

  • It masks only string and binary types (CHAR, VARCHAR, TEXT, BLOB, BINARY, ENUM, SET and their variants); "If the type of the column is something else, then no masking will be performed."
  • It works only on packets under 16 MB.
  • A user who can write can copy the column elsewhere and read it back (CREATE TABLE cheat …; INSERT INTO cheat SELECT ssn FROM users;), so "the privileges of the users should be minimized."
  • Matching is by name: when the result set carries no table information, every column with that name is masked.

Licence and license key

  • MaxScale is distributed under the Business Source License 1.1, which, in its own words, "is not an Open Source license". MariaDB's BSL page covers MaxScale v2.0 to v24.02, with this Additional Use Grant: "You may use the Licensed Work when your application uses the Licensed Work with a total of less than three server instances in production." Each version changes to GPL v2 or later after its change date. The 24.08 licence file has the same grant (change date 2027-09-09).
  • As of 2026-11-14 we found no published licence terms for 25.01, 25.10 or 26.10.
  • MaxScale 26.10 (released 2026-11-03) "does not start without a valid license key"; the key comes from an Enterprise Platform subscription or a trial (26.10.0 release notes).

We did not run MaxScale for this guide: everything in this section is from its docs and licence files.

Inside the server: views, column privileges and generated columns

MariaDB has column privileges and SQL SECURITY DEFINER views (the default), so the MySQL pattern works as is: the user reads only harmless columns of the table, plus a view or generated columns with the masked values.

CREATE USER 'analyst'@'%' IDENTIFIED BY 'analyst-pw';
GRANT SELECT (id, name) ON shop.customers TO 'analyst'@'%';
CREATE SQL SECURITY DEFINER VIEW customers_masked AS
SELECT id, name,
       CONCAT(LEFT(email, 1), '***@', SUBSTRING_INDEX(email, '@', -1)) AS email,
       CONCAT('****', RIGHT(card_number, 4))                         AS card_number,
       CONCAT('XXX-XX-', RIGHT(ssn, 4))                               AS ssn
FROM customers;
GRANT SELECT ON shop.customers_masked TO 'analyst'@'%';

ALTER TABLE customers ADD COLUMN card_last4 VARCHAR(4)
  GENERATED ALWAYS AS (RIGHT(card_number, 4)) VIRTUAL;
ALTER TABLE customers ADD COLUMN email_masked VARCHAR(255)
  GENERATED ALWAYS AS (CONCAT(LEFT(email, 1), '***@', SUBSTRING_INDEX(email, '@', -1))) VIRTUAL;
CREATE USER 'support'@'%' IDENTIFIED BY 'support-pw';
GRANT SELECT (id, name, card_last4, email_masked) ON shop.customers TO 'support'@'%';

Tested on MariaDB 11.4.13 (mariadb:11.4), 2026-11-14.

As analyst on MariaDB 11.4.13; note that the 1142 error names the table as `shop`.`customers`, unlike MySQL:

-- The same customers table, analyst and support users, customers_masked view
-- and generated columns as in the MySQL guide. Connected as analyst:
SELECT email FROM customers;
SELECT * FROM customers;
SELECT * FROM customers_masked;
ERROR 1143 (42000) at line 3: SELECT command denied to user 'analyst'@'localhost' for column 'email' in table 'customers'
ERROR 1142 (42000) at line 4: SELECT command denied to user 'analyst'@'localhost' for table `shop`.`customers`
+----+-------+------------------+-------------+-------------+
| id | name  | email            | card_number | ssn         |
+----+-------+------------------+-------------+-------------+
|  1 | Ana   | a***@example.com | ****4242    | XXX-XX-6789 |
|  2 | Bruno | b***@example.org | ****1881    | XXX-XX-4321 |
+----+-------+------------------+-------------+-------------+

Tested on MariaDB 11.4.13 (mariadb:11.4), 2026-11-14.

As support, card_last4 and email_masked return 4242 / a***@example.com and 1881 / b***@example.org, and SELECT card_number fails with the same 1143 error as on MySQL. The trade-offs are the same: clients must use the view, and generated columns change the schema.

MaxScale, views or a proxy

OptionApp changesPer-agent policyAudit of masked readsLicence
MaxScale masking filterConnect through MaxScalePer account, with applies_to / exemptedNot part of the filterBSL 1.1 (not open source); 26.10 needs a license key
View + column privilegesClients query the viewPer user or roleNot part of the featureMariaDB Server (GPL)
Generated columnsSchema changePer user or roleNot part of the featureMariaDB Server (GPL)
Vericto TCP proxyConnection string onlyOne proxy per agent path, plus agent allowlistsEvery masked read in the audit trail, with the columnAGPL-3.0-only

The two proxies differ in where they act: the MaxScale filter replaces values in the result set; Vericto rewrites the query before it reaches the server, so the server computes the masked value and the clear one never leaves it. Both add a hop; for Vericto we publish what we measured, with the method, in the proxy latency benchmark.

Mask columns with Vericto

Vericto masks at the TCP proxy, between the client and MariaDB: no change to the database, no change to the application, and no MySQL Enterprise Edition needed. The proxy speaks the MySQL wire protocol (VERICTO_WIRE_PROTOCOL=mysql; MariaDB and Aurora MySQL go through the same protocol). You point the connection string at the proxy, with the same user and password.

How it works

  1. In the dashboard, under Databases → Sensitive columns, you tag columns: table, column, a policy (block, flag or mask) and, for mask, a style: full ([redacted]), last4, email or hash (SHA-256).
  2. For each query, the engine reads the AST and finds which tagged columns the query returns. Every decision is reported as rule VERICTO-085; when a query reads several tagged columns, the strictest policy wins (block > mask > flag).
  3. Under mask, the proxy forwards a rewritten query in the same COM_QUERY or COM_STMT_PREPARE, never the original. The ? placeholders keep their number and order, so prepared statements run unchanged. The database computes the masked values; the clear value never reaches the client.
  4. Under block, the query never reaches the database: the client gets ERROR 1142.

This is the real rewrite of vericto-engine 5.0.0 for a query that reads two masked columns, and the rows it returned on MySQL 8.4 and MariaDB 11.4:

-- The query the agent or the app sends (MySQL or MariaDB):
SELECT id, name, email, card_number FROM customers WHERE id = 42
-- FLAGGED VERICTO-085: SensitiveColumn > customers.card_number, customers.email (mask)
-- The query the proxy forwards instead (rewritten_query):
SELECT id, name, CASE WHEN CHAR_LENGTH((CONVERT((email) USING utf8mb4) COLLATE utf8mb4_bin)) = 0 THEN (CONVERT((email) USING utf8mb4) COLLATE utf8mb4_bin) WHEN LOCATE('@', (CONVERT((email) USING utf8mb4) COLLATE utf8mb4_bin), 2) > 0 THEN CONCAT(LEFT((CONVERT((email) USING utf8mb4) COLLATE utf8mb4_bin), 1), '***', SUBSTRING((CONVERT((email) USING utf8mb4) COLLATE utf8mb4_bin), LOCATE('@', (CONVERT((email) USING utf8mb4) COLLATE utf8mb4_bin), 2))) ELSE CONCAT(LEFT((CONVERT((email) USING utf8mb4) COLLATE utf8mb4_bin), 1), '***') END AS `email`, CASE WHEN CHAR_LENGTH((CONVERT((card_number) USING utf8mb4) COLLATE utf8mb4_bin)) <= 8 THEN '[redacted]' ELSE CONCAT('****', RIGHT((CONVERT((card_number) USING utf8mb4) COLLATE utf8mb4_bin), 4)) END AS `card_number` FROM customers WHERE id = 42

Real output: vericto-engine 5.0.0, evaluate() on MySQL with customers.email (mask, email), customers.card_number (mask, last4) and customers.ssn (block), 2026-11-14.

-- The rows the masked rewrite returns:
+----+------+------------------+-------------+
| id | name | email            | card_number |
+----+------+------------------+-------------+
| 42 | Ana  | a***@example.com | ****4242    |
+----+------+------------------+-------------+

Tested on MySQL 8.4.13 Community (mysql:8.4) and MariaDB 11.4.13 (mariadb:11.4), 2026-11-16.

The masks use only functions present in MySQL 5.7, 8.0, Aurora MySQL and MariaDB (no REGEXP_REPLACE), and give the same values as on PostgreSQL. A SELECT * over a table with tagged columns is blocked, with a message asking to list the columns:

SELECT * FROM customers
-- BLOCKED VERICTO-085: SensitiveColumn > * over customers (block): list the columns explicitly
-- Fix: List the columns explicitly: `*`, `t.*`, whole-row references and `COPY table TO` read every tagged column

Real output: vericto-engine 5.0.0, evaluate() on PostgreSQL with customers.email (mask, email), customers.card_number (mask, last4) and customers.ssn (block), 2026-11-14.

What to know

  • Versions: on MySQL, mask rewrites from vericto-proxy 4.7.0 and vericto-eval 2.3.0; with older versions a mask tag blocks the query.
  • The rewrite is printed from the parsed statement, so comments and formatting are not kept. A query the engine cannot reproduce faithfully (optimizer hints /*+ … */, SQL_CALC_FOUND_ROWS and the other SELECT modifiers, bit literals) is blocked rather than rewritten. Text that MySQL and the engine would read differently is blocked by VERICTO-086.
  • A column used only in WHERE, JOIN, GROUP BY or ORDER BY is not a read, so an agent could infer a value by filtering on it. For agents, add an agent-access allowlist, where every reference counts.
  • Vericto decides by column name, not content; a renamed column loses its tag, and views or functions over a tagged table are not covered unless tagged too.
  • Only the TCP proxy enforces. The runtime API returns rewritten_query for the application to run, MCP returns it as the only approved_query, and the CLI shows it as a suggestion. vericto-proxy mcp is PostgreSQL-only in 5.0.1, so for a MySQL agent use the TCP proxy.
  • Sensitive columns need a Vericto workspace: the masking page lists where the feature is available. The proxy is open source under AGPL-3.0-only.

Keep column privileges and views as the base layer; the proxy adds per-database policies, the audit trail of every masked read and one place to manage them. Full reference: sensitive columns docs.

Frequently asked questions

Sources

The official documentation this guide cites, checked on 2026-11-14: