Introduction to column encryption
Database Autonomy Service (DAS) supports column encryption for ApsaraDB RDS for MySQL, ApsaraDB RDS for PostgreSQL, PolarDB for MySQL, PolarDB for PostgreSQL, and PolarDB-X 2.0 databases. Column encryption protects sensitive column data and allows authorized users to decrypt and access the plaintext of encrypted columns by using the column encryption client. Column encryption ensures both the confidentiality and integrity of sensitive data. For more information, see Security capabilities.
Security capabilities
Security goal | How column encryption achieves it | What it means for you |
Confidentiality | Sensitive columns are encrypted by using AES_128_GCM, AES_256_GCM, or the Chinese cryptographic algorithm SM4_128_GCM. |
|
Integrity | GCM is an authenticated encryption algorithm. The ciphertext is verified before decryption. | If ciphertext is tampered with, truncated, or forged during transmission or on the application side, the verification fails and the ciphertext is not decrypted into incorrect plaintext. |
Key control | You can generate the master key (MEK) yourself or host it in KMS. | Only applications that hold the correct key can decrypt the data. |
The integrity protection of column encryption applies to the ciphertext data itself. It ensures that tampered ciphertext is not decrypted into incorrect plaintext. It cannot replace database account permission control or operation auditing. Manage insert, delete, and update operations on data by using database account permissions and DAS security audit.
Column encryption encrypts the query results of the target columns that are returned to accounts with ciphertext permission. You can combine column encryption with TDE or disk encryption to further protect data at rest. Clients that have the required permissions and keys can decrypt the data to obtain the plaintext. For more information, see Comparison of different database encryption technologies.
Supported databases and regions
Database | Region |
| Public cloud: China (Hangzhou), China (Shanghai), China (Qingdao), China (Beijing), China (Zhangjiakou), China (Hohhot), China (Ulanqab), China (Shenzhen), China (Heyuan), China (Guangzhou), China (Chengdu), China (HK), Singapore, Malaysia (Kuala Lumpur), Indonesia (Jakarta), Philippines (Manila), and Germany (Frankfurt) Finance Cloud: China East 1 Finance, China East 2 Finance, and China South 1 Finance Gov Cloud: China North 2 Ali Gov 1 |
PolarDB-X 2.0 | Public cloud: China (Hangzhou), China (Shanghai), China (Qingdao), China (Beijing), China (Zhangjiakou), China (Hohhot), China (Ulanqab), China (Shenzhen), China (Guangzhou), China (Chengdu), China (HK), Singapore, Malaysia (Kuala Lumpur), Indonesia (Jakarta), and Germany (Frankfurt) Finance Cloud: China East 1 Finance, China East 2 Finance, and China South 1 Finance Gov Cloud: China North 2 Ali Gov 1 |
PolarDB for PostgreSQL (Compatible with Oracle) | China (Hangzhou) and Malaysia (Kuala Lumpur) |
ApsaraDB RDS for SQL Server does not support column encryption.
Prerequisites
Column encryption is authorized for the instance on the Instance list page.
On the Instance List page, click the Cloud Instances tab, find the target instance, and click Activate in the Security Center column.
You have purchased DAS Security Center and a sufficient column encryption quota. If you have not enabled the free trial for column encryption or your quota is insufficient, purchase a new quota.
Make sure that the region of your instance supports column encryption. For more information, see Product series and supported features.
You do not need to complete sensitive data detection before you configure column encryption. To select columns to encrypt based on sensitivity levels, run a sensitive data detection task first (optional). For more information, see Manage sensitive data identification.
Billing information
DAS provides a free quota to encrypt 1 column. To continue using the service, activate the Column Encryption service and purchase a sufficient Column Encryption Quota. The service is billed on a subscription (monthly or yearly) basis. For more information, see Billing details.
If Encryption Method is set to KMS Key in the column encryption configuration, KMS charges fees for the managed key. For more information, see Billing.
Account permissions
After you configure column encryption, you can set one of the following three permissions for a database account to control what the account sees when it accesses encrypted columns:
Permission | Description |
Ciphertext permission (JDBC decryption) | The account accesses encrypted column data as ciphertext by default. The account can use an SDK to decrypt the data with a local key or a KMS key through the column encryption client driver and view the plaintext. |
Ciphertext permission (no decryption permission) | The account can access only the ciphertext of encrypted column data. The account cannot decrypt the data in any way to view the plaintext. |
Plaintext permission | After column encryption is enabled for the database, accounts with plaintext permission are not affected by the column encryption settings and can directly access encrypted column data in plaintext. |
For the permissions supported by each database and the default permission, see the Supported permissions column in Encryption limits below.
Encryption limits
Supported database types | Supported versions | Supported encryption algorithms | Supported encryption methods | Supported permissions |
ApsaraDB RDS for MySQL | The major engine version is MySQL 5.7 or MySQL 8.0, and the minor engine version is 20240731 or later. |
|
|
|
ApsaraDB RDS for PostgreSQL | The major engine version is PostgreSQL 16, and the minor engine version is 20241230 or later. | AES_256_GCM. | Local key. |
|
PolarDB for MySQL | The major engine version is MySQL 5.7 or MySQL 8.0, and the database proxy version is 2.8.36 or later. Important If you configure column encryption policies for a PolarDB for MySQL cluster, you must use a read/write cluster endpoint to connect to the database. If you use a primary endpoint, the column encryption policies do not take effect. For more information, see Configure the database proxy and Manage endpoints. | AES_128_GCM. | Local key. |
|
PolarDB for PostgreSQL | The major engine version is PostgreSQL 14, and the database version is 2.0.14.15.31.0 or later. | AES_256_GCM. | Local key. |
|
PolarDB for PostgreSQL (Oracle Compatible) | Only the Oracle syntax-compatible version 2.0 is supported. The major engine version is PostgreSQL 14, and the database version is 2.0.14.15.31.0 or later. | AES_256_GCM. | Local key. |
|
PolarDB-X 2.0 | The database version is polardb-2.5.0_5.4.20-20250714 or later, and the series is Enterprise Edition. |
|
|
|
All the preceding encryption algorithms use the GCM authenticated encryption mode. They provide tamper-proof verification while encrypting data and meet both confidentiality and integrity requirements.
Enable column encryption
When you query encrypted columns by using SQL through a client, the returned data is displayed as strings regardless of the original column data types. Before you configure column encryption, carefully evaluate the impact on your business.
Log on to the DAS console.
In the navigation pane on the left, click .
In the Actions column of the destination instance, click Rapid Encryption to configure an encryption policy.
NoteFor an instance that already has an encryption policy, click Edit in the Actions column to modify the policy.
In the Encryption Configuration side panel, select the Asset Type, Instance Name, Encryption Algorithm, Encryption Method, and Plaintext Permission Accounts. Then, select the destination Database, Table, and Column to encrypt, and click OK.
Note the following parameter configurations:
Encryption Method: If the encryption method is KMS key, create a symmetric key in Key Management Service (KMS) in advance.
ImportantChanging the encryption method may restart the encryption task and affect the existing column encryption protection. Change the encryption method with caution, and verify that column encryption takes effect again after the change is complete.
Plaintext Permission Accounts: After the encryption configuration is complete, all accounts in the database are set to ciphertext permissions by default.
For PolarDB for MySQL, PolarDB for PostgreSQL, PolarDB for PostgreSQL (Oracle Compatible), ApsaraDB RDS for PostgreSQL, and PolarDB-X 2.0, database accounts default to ciphertext permission (JDBC decryption). The accounts access ciphertext data by default and can access plaintext data after decryption through the column encryption client.
For ApsaraDB RDS for MySQL, if the encryption method is KMS key, database accounts default to ciphertext permission (JDBC decryption).
For ApsaraDB RDS for MySQL, if the encryption method is local key, database accounts default to ciphertext permission (no decryption permission) and can access only ciphertext data.
Select the accounts to add to the whitelist. These accounts use plaintext permission to directly access the plaintext data of encrypted columns.
In the instance list, click the
icon to the left of the destination instance to expand the list of databases, tables, and columns.In the Actions column of the expanded list, click Enable Encryption, and then click OK in the dialog box that appears.
NoteAfter column encryption is enabled, if you want to disable column encryption for the instance, click Disable Encryption in the Actions column of the instance, and then click OK in the dialog box that appears.
Verify that column encryption takes effect
After you configure column encryption, query the encrypted columns by using database accounts with different permissions to confirm that the configuration takes effect:
Query method | Plaintext permission account | Ciphertext permission (no decryption permission) account | Ciphertext permission (JDBC decryption) account |
Standard client (such as DMS or the MySQL command line) | Returns plaintext | Returns ciphertext | Returns ciphertext |
Column encryption client (EncJDBC or Go driver) | Returns plaintext | Returns ciphertext | Returns plaintext |
If a ciphertext permission account queries the encrypted columns through a standard client and ciphertext is returned, the column encryption configuration has taken effect.
ApsaraDB RDS for PostgreSQL database accounts support only plaintext permission and ciphertext permission (JDBC decryption). The verification method is the same as that for ApsaraDB RDS for MySQL.
When you log on to PolarDB for MySQL through DMS, a primary endpoint is used and column encryption policies do not take effect. To verify column encryption for PolarDB for MySQL, connect to the cluster endpoint (database proxy endpoint) by using the MySQL command line. Example:
mysql -h<cluster endpoint> -P<port> -u<username> -p<password>.
Access plaintext of encrypted columns by using a client
To access the plaintext data of encrypted columns from a client, use an account with ciphertext permission (JDBC decryption) and decrypt the data through the column encryption client for Java or Go.
Programming language | Supported database types | References |
Java |
| Integrate EncJDBC (supports decryption with local keys and KMS keys) |
Go |
| Integrate the Go driver for column encryption (supports decryption with local keys only) |
The key methods that are actually available must meet the support requirements of the database type, database version, and client driver at the same time. For the support scope on the database side, see Encryption limits. For detailed client configurations, see the corresponding driver documentation listed in the preceding table.
References
Integrate EncJDBC: To access the plaintext of these encrypted columns from a Java application, use the EncJDBC driver to connect to the database.
Integrate the Go driver for column encryption: To access the plaintext of these encrypted columns from a Go application, use the alibabacloud-encdb-mysql-go-client driver to connect to the database.
Best practices for automated management of column encryption rules: Use Python scripts to call API operations for creating, querying, and managing column encryption rules in batches.