Log encryption

Updated at:

To encrypt log data at rest for the log analysis feature of Cloud Firewall, you can use either service-managed keys provided by Simple Log Service or the Bring Your Own Key (BYOK) feature.

Data encryption mechanisms

Simple Log Service supports the following two encryption mechanisms.

Encryption with a service key

Features:

  • Simplicity: Requires no extra configuration. Simple Log Service manages encryption and key management, which reduces your operational overhead.

  • Key isolation: A unique data encryption key is generated for each Logstore to enhance data security.

  • Durability: These data encryption keys never expire, ensuring long-term encryption stability.

  • Supported encryption algorithms: AES (default) and SM4.

Use cases:

  • You want to quickly implement data encryption without managing the keys yourself.

  • You do not have specific key management requirements and prefer the service provider to manage the keys.

  • You need to ensure the long-term validity and stability of your data encryption keys.

Target users:

Small businesses or individual users who want simple and secure log encryption without handling complex key management tasks.

Encryption with Bring Your Own Key (BYOK)

Features:

  • Full control: You manage the entire lifecycle of your keys, including creation, rotation, and deletion.

  • Flexibility: You can easily update or rotate keys as needed to enhance security and flexibility.

  • Proactive management: You must create and manage a customer master key (CMK) in the KMS console and grant the necessary permissions.

Use cases:

  • Your organization has strict security and compliance requirements that mandate self-managed encryption keys.

  • You want to proactively manage and rotate encryption keys to meet higher security standards.

  • You want the ability to quickly rotate or delete a key to protect your data if the key is compromised or other security risks arise.

Target users:

Large enterprises or financial institutions that have strict data protection and compliance requirements, need to implement their own key management policies, and have dedicated teams to manage keys.

Important

If your customer master key (CMK) is deleted or disabled, the associated BYOK key becomes invalid, and all read and write requests to the Logstore will fail.

Limitations

When you configure data encryption, you cannot modify the encryption mechanism after you select it for the first time. You also cannot modify the encryption algorithm or encryption type. You can only use the enable parameter to enable or disable the encryption feature. In addition, you must include the complete encrypt_conf parameter each time you update the Logstore.

For example, if you select the service-managed key mechanism, you cannot switch to the Bring Your Own Key (BYOK) mechanism.

Encrypt with service-managed keys

When you call the CreateLogstore API to create a Logstore or the UpdateLogstore API to modify a Logstore, add the encrypt_conf parameter to configure encryption.

The following table describes the encrypt_conf parameter. For this method, do not specify the user_cmk_info field.

Parameter

Type

Description

Example

object

The encryption configuration.

enable

boolean

Whether to enable data encryption. Valid values:

  • true

  • false

true

encrypt_type

string

The encryption algorithm. Valid values: default and sm4. Required when enable is set to true.

default

user_cmk_info EncryptUserCmkConf

Optional. If specified, the bring-your-own-key (BYOK) key is used. Otherwise, the service key of Simple Log Service is used.

{ "cmk_key_id" : "f5136b95-2420-ab31-xxxxxxxxx" "arn" : "acs:ram::13234:role/logsource" "region_id" : "cn-hangzhou" }

Encrypt with BYOK

Prerequisites

You have activated Key Management Service (KMS). For more information, see Purchase a dedicated KMS instance.

Step 1: Grant BYOK permissions

Before you use the BYOK method, you must grant the required Resource Access Management (RAM) permissions.

  1. Log on to the RAM console.

  2. Create a RAM role for a trusted Alibaba Cloud service with the following configurations:

    For Role Type, select common service role. For Role Name, enter KMS-TEST. For Select Trusted Service, select Simple Log Service.

  3. Grant the AliyunKMSReadOnlyAccess and AliyunKMSCryptoUserAccess permissions to the RAM role. For more information, see Grant permissions to a RAM role.

  4. Grant the ram:PassRole permission. You can skip this step if you use your Alibaba Cloud account to configure BYOK encryption. If you use a RAM user, you must create a custom policy and then grant permissions to the RAM user.

    The Resource value in the following policy must be replaced with the ARN of the RAM role that was created in Step 2. For more information about how to view the ARN of a RAM role, see How do I view the ARN of a RAM role?.

    {
        "Version": "1",
        "Statement": [
            {
                "Effect": "Allow",
                "Action": "ram:PassRole",
                "Resource": "acs:ram::<account-id>:role/<role-name>"  
            }
        ]
    }

Step 2: Configure data encryption

After you enable the log analysis feature in the Cloud Firewall console, Cloud Firewall automatically creates a dedicated Project and a dedicated Logstore. You must call the UpdateLogstore API to encrypt data by adding the encrypt_conf parameter to the Logstore configuration.

Before calling the UpdateLogstore API, you must first call the GetLogstore API to retrieve the current Logstore configuration. After you modify the configuration, pass the complete, updated configuration to the UpdateLogstore API.

The following table describes the encrypt_conf parameter. In this scenario, you must specify the user_cmk_info field.

Parameter

Type

Description

Example

object

The encryption configuration.

enable

boolean

Whether to enable data encryption. Valid values:

  • true

  • false

true

encrypt_type

string

The encryption algorithm. Valid values: default and sm4. Required when enable is set to true.

default

user_cmk_info EncryptUserCmkConf

Optional. If specified, the bring-your-own-key (BYOK) key is used. Otherwise, the service key of Simple Log Service is used.

{ "cmk_key_id" : "f5136b95-2420-ab31-xxxxxxxxx" "arn" : "acs:ram::13234:role/logsource" "region_id" : "cn-hangzhou" }

EncryptUserCmkConf data structure

Parameter

Type

Description

Example

object

The user-defined encryption configuration.

cmk_key_id

string

The ID of the customer master key (CMK) for Bring Your Own Key (BYOK) encryption.

f5136b95-2420-ab31-xxxxxxxxx

arn

string

The Alibaba Cloud Resource Name (ARN) of the Resource Access Management (RAM) role.

acs:ram::13234:role/logsource

region_id

string

The ID of the region where the CMK resides.

cn-hangzhou

encrypt_conf = {
    "enable" : true,                 # Specifies whether to enable encryption.
    "encrypt_type" : "default",      # The encryption algorithm. Supported values: default, m4, sm4_ecb, sm4_cbc, sm4_gcm, aes_ecb, aes_cbc, aes_cfb, aes_ofb, and aes_gcm.
    "user_cmk_info" :                # Optional. If you specify this parameter, BYOK is used. Otherwise, a service key is used.
    {
          "cmk_key_id" : "",         # The ID of the CMK for BYOK. Example: f5136b95-2420-ab31-xxxxxxxxx.
          "arn" :  "",               # The ARN of the RAM role that you created in Step 1.
          "region_id" : ""           # The region ID where the CMK is located.
    }
}

Related documents

The following API operations are related to Simple Log Service: