BASTIONOSDocs
bastion-os.com
EN

Administer

Data masking

Card numbers, IBANs, e-mail addresses and phone numbers can be shown masked to the people who do not need them. The database is not changed: the gateway masks values before they leave it.

A masking policy#

In Console → Access control → Data masking:

Part Meaning
Columns 1 to 50 name patterns, case-insensitive: card_number, *iban*, phone*. * is any run of characters, ? one character
Method full ******; partial keeps a few characters at the start or the end, ************1111; e-mail j***@example.com; digest: a stable 16-digit digest, equal values stay equal
Protocols PostgreSQL, MySQL (MariaDB and ClickHouse too), SQL Server, Oracle, or all
Who users and groups; none means every member
What folders, assets, accounts; none means every database account
Priority 1 to 1,000; the first policy that names a column masks it

The page previews each method on a sample value.

Masking policies
Masking policies

What is masked#

  • Results in the SQL workbench, in the editor and in the graphical mode. NULL stays NULL. A masked column's header carries a mark, and the result says how many columns are masked.
  • Exports, as SQL or CSV.
  • Renamed or computed columns: card_number AS x, substr(card_number, 1, 6), a subquery or a UNION that hides the name. When the gateway cannot tell which result column carries the value, it masks every column of that result.

A column only used to filter or sort (WHERE email = …) masks nothing.

What is refused#

Whenever a policy applies to the connection, statements that could copy masked values elsewhere or hide them from the gateway are refused before they reach the server, with the policy's name: dynamic SQL (PREPARE, EXECUTE, sp_executesql, EXECUTE IMMEDIATE, DO), links to other servers (dblink, OPENQUERY), and statements that name a sensitive column and could keep its values (INSERT … SELECT, CREATE TABLE … AS, SELECT … INTO). Reads, and writes that name no sensitive column, run as usual.

An account covered by a masking policy opens from the workbench only: native clients and connection tokens are refused for it, since their results do not go through the masking.

Limits#

Masking reads the SQL text, on top of the database's own privileges. A view, a function or a trigger can return values under a name the gateway cannot tie to a sensitive column. Give masked users an account that may read but neither create objects nor run code: the guarantee then holds. Masking by content (a card number typed in a notes column) is not done.

Audit#

Each connection's audit event names the masking policies and versions it carried, and refused statements are recorded as denied by their policy.

© 2026 BastionOS · Source-available, self-hosted privileged access Contact