Updated on 2025-11-05 GMT+08:00

Dynamic Data Masking

Introduction

Dynamic data masking is a security feature where sensitive data in a database is masked before being returned when an application queries the database. TaurusDB allows you to add masking rules to mask data in specified databases, tables, and columns.

Principles

After you configure data masking rules as user root, the database will persistently store these rules. When an application executes a query, the database will first check whether the query meets the rules. If it does, the database will mask sensitive data before sending the results to the client.

The data masking rules configured in the following figure are:

  • The rules apply only when user1 logs in to a database for query.
  • Only the name and age columns in the t1 table of the db1 database are masked.

The raw data is returned except for the columns configured in the data masking rules.

Figure 1 Diagram

As shown in the figure, the name of the string type is displayed as ******, and the age of the INT type is displayed as a random positive integer. The masking method varies depending on the data type. For details, see Table 1.

Table 1 Data masking

Data Type

After Masking

Integer (TINYINT, SMALLINT, MEDIUMINT, INT, BIGINT, and BOOLEAN)

A positive integer

Decimal (DECIMAL, FLOAT, and DOUBLE)

Time (YEAR)

Time (DATE, TIME, DATETIME, and TIMESTAMP)

DATE: [1000:01:01,9999:12:31.499999]

TIME: [00:00:00,838:59:59.499999]

DATETIME and TIMESTAMP: [1971:01:01 00:00:00, 2037:12:31 23:59:59.49999]

Other

******

Impact on Performance

After dynamic data masking was enabled and a full-field masking rule (add_mask_rule('', '', '', '')) was configured, configuring 128 data masking rules caused a roughly 10% decrease in database performance in the read-only performance test outlined in the Performance White Paper.

Supported Versions

To use this function, the kernel version of your instance must be 2.0.69.250900 or later.

For details about how to check the kernel version, see How Can I Check the Version of a TaurusDB Instance?

Constraints on Masking Rules

  • This function can take effect only for SELECT statements.
  • The masking rules are not applied to system databases. System databases include mysql, information_schema, performance_schema, and sys.
  • Spaces and special null characters (such as '\t', '\r', and '\n') at the beginning and end of a database name, table name, column name, or username will be ignored after masking.
  • A database name, table name, or column name should be no longer than 64 bytes. A username should be no longer than 32 bytes. Or, a masking rule will fail to be added.
  • The administrator list (the value of rds_dynamic_masking_super_users) in a masking rule should be no longer than 4,000 bytes.
  • Only the root user can add, delete, enable, disable, and update masking rules.
  • All users can query masking rules.

Parameters for Dynamic Data Masking

On the Parameters page of the management console, you can set the parameters listed in Table 2 to enable dynamic data masking and manage masking rules.

Table 2 Parameter description

Parameter

Level

Description

rds_dynamic_masking_enabled

Global

Whether to enable dynamic data masking.

The default value is OFF.

rds_dynamic_masking_super_users

Global

You can configure multiple administrators separated by commas (,). The masking rules do not take effect for administrators.

The default value is an empty string.

Example: 'user1,user2'

rds_masking_paramter_max_count

Global

The maximum number of database names, table names, column names, or usernames that can be configured.

The default value is 100. It means that a maximum of 100 database names, 100 table names, 100 column names, and 100 usernames can be configured in a rule.

Value range: [1, 1000]

rds_masking_map_size

Global

The maximum memory that can be used by masking rules, in MB.

The default value is 8.

Setting it too high may cause an OOM error. Exercise caution when adjusting it.

Usage

FAQs