Confidential computing with Alibaba Cloud Enclave

更新时间:
复制 MD 格式

This topic describes how to use Alibaba Cloud Enclave to create a trusted and isolated environment to protect your applications and data.

Background information

Data exists in three states: data at rest, data in transit, and data in use.

  • Data at rest and data in transit can be protected by encryption.

  • Protecting data in use is challenging. Confidential computing is commonly used to protect data in use.

Alibaba Cloud Enclave provides a trusted and isolated environment within an ECS instance. It encapsulates secure operations of authorized software in an Enclave to ensure the confidentiality and integrity of your code and data against malware attacks. Alibaba Cloud Enclave is ideal for services that require strong protection for sensitive and confidential data, such as financial services, internet technology, and healthcare.

How Enclaves work

Alibaba Cloud Enclave works by partitioning compute resources, including vCPUs and memory, from an ECS instance (the primary VM) to create an Enclave VM (EVM) that serves as a trusted execution environment. The security of the EVM is ensured as follows:

  • The underlying virtualization technology provides security isolation. The EVM is isolated from the primary VM and other ECS instances.

  • The EVM runs a separate, customized, and trusted operating system. It has no persistent storage, interactive connections, or external network access. It communicates with the primary VM only through a local secure channel that is based on Virtual Socket (vsock). This design minimizes the attack surface. You can run applications that process confidential data in the EVM and allow them to interact with applications on the primary VM through secure calls.

The following figure shows how Alibaba Cloud Enclave works.

image

Alibaba Cloud Enclave provides security through multiple layers. At the underlying layer, the third-generation SHENLONG architecture, which includes Trusted Platform Module (TPM)/Trusted Cryptography Module (TCM) chips, provides the EVM with vTPM/vTCM devices to enhance its security and trustworthiness. At the upper layer, highly compatible SDKs are provided to help you quickly set up and use the Enclave environment. For remote attestation, you can verify code that runs in the trusted execution environment. For example, by using the SDKs, confidential applications can generate attestation reports at runtime that include platform data, application information, and signatures. You can then use a remote attestation server, which can be integrated with Key Management Service (KMS), to verify the reports. When the primary VM allocates resources to the EVM and the EVM starts, the underlying layer enforces resource access isolation. This ensures that the primary VM cannot access the allocated vCPUs or memory, which protects the operations and privacy of the EVM.

The following figure shows the architecture of Alibaba Cloud Enclave.

image

Limits

  • Only instance types with four or more vCPUs in the hfg9i, hfc9i, hfr9i, g8i, c8i, and r8i instance families support Alibaba Cloud Enclave.

  • You can create only one Enclave on each ECS instance.

  • Before you use an Enclave, you must reserve at least one physical processor core and some memory for the primary VM. The remaining processor and memory resources can be flexibly allocated to the Enclave. If Hyper-Threading is enabled, two vCPUs from the same physical core are reserved. Therefore, an Enclave-enabled ECS instance must have at least 4 vCPUs.

For more information about other general limits, see Limits and quotas.

Create an Enclave-enabled instance

Creating an instance with Enclave features in the console is similar to creating a regular instance, but you must configure some specific options. This procedure describes only the configurations that are specific to Enclave instances. For information about other general configurations, see Create a custom instance.

  1. Go to the Instances page of the ECS console.

  2. In the top navigation bar, select the region and resource group of the resource that you want to manage. Region

  3. Click Create Instance and configure the following parameters.

    Parameter

    Description

    Instance type

    Select an instance type with four or more vCPUs from the hfg9i, hfc9i, hfr9i, g8i, c8i, or r8i instance family.

    Image

    Select the Enclave checkbox, and then select the Alibaba Cloud Linux 2.1903 LTS 64-bit (UEFI) image.

    Note

    When you select Enclave, a trusted operating system is installed by default.

    image

    Instance RAM Role

    Select the AliyunECSInstanceForYundunSysTrustRole service-linked role.

Install the Enclave CLI

  1. Install Docker on the Enclave-enabled instance.

  2. Connect to the Enclave-enabled instance over SSH by using Workbench.

  3. Install the RPM package for the Enclave CLI.

    1. Run the following command to download the RPM package for the Enclave CLI:

      wget https://enclave-cn-beijing.oss-cn-beijing.aliyuncs.com/download/linux/enclave-cli/x86_64/2.1903/enclave-cli-1.0.8-1.x86_64.rpm
    2. Run the following command to install the Enclave CLI:

      sudo rpm -ivh enclave-cli-1.0.8-1.x86_64.rpm
    3. Run the following command to check the version of the Enclave CLI:

      enclave-cli --version

      If the command returns version information, the Enclave CLI is installed.

      image.png

  4. Add the current user to the de and docker user groups.

    1. Run the following command to add the current user to the de user group:

      sudo usermod -aG de <username>
      Note

      Replace <username> with your actual username, for example, test.

    2. Run the following command to add the current user to the docker user group:

      sudo usermod -aG docker <username>
      Note

      Replace <username> with your actual username, for example, test.

    3. Log out and log back in to the instance to apply the new group membership.

  5. Pre-allocate vCPUs and memory for the Enclave.

    1. Run the following command to open the allocator.yaml configuration file:

      sudo vim /etc/ali-enclaves/allocator.yaml
    2. Press the i key to enter Insert mode.

    3. Modify the following parameters:

      • memory_mib: the amount of memory to allocate, in MiB.

      • cpu_count: the number of vCPUs to allocate.

      The following sample configuration allocates 1,024 MiB of memory and 2 vCPUs to the Enclave.

      # Enclave configuration file.
      #
      # How much memory to allocate for enclaves (in MiB).
      memory_mib: 1024
      #
      # How many CPUs to reserve for enclaves.
      cpu_count: 2
    4. Press the Esc key, enter :wq, and then press the Enter key to save the file and exit.

  6. Run the following command to start the Enclave resource allocation service and enable it to start on boot:

    sudo systemctl start ali-enclaves-allocator.service && \
    sudo systemctl enable ali-enclaves-allocator.service

    After the configuration is complete, the Enclave resource allocation service creates a pool of available vCPUs for the Enclave based on your settings. The ECS instance can no longer use the vCPUs in this pool. When an Enclave starts, it can select vCPUs only from this pool.

    Note

    To change the resources allocated to the Enclave, modify the allocator.yaml file again and run the following command to restart the Enclave resource allocation service:

    sudo systemctl restart ali-enclaves-allocator.service
  7. Run the following command to check the status of the Enclave resource allocation service:

    systemctl status ali-enclaves-allocator.service

    The following command output indicates that the service is running.

    image.png

  8. Run the following command to start the Docker service and enable it to start on boot:

    sudo systemctl start docker && sudo systemctl enable docker
    Note

    If you no longer need Alibaba Cloud Enclave, you can run the sudo yum remove enclave-cli command to uninstall the Enclave CLI.

  9. Restart the instance for the changes to take effect.

Related topics

For more information about how to use the Enclave CLI, see Quickly use the Enclave CLI.