Linux SGX Remote Attestation
The related code/working directory of this example resides in directory {WAMR_DIR}/samples/sgx-ra
This sample demonstrates how to execute Remote Attestation on SGX with librats and run it with iwasm. It can only build on SGX supported processors, please check it.
Preparation
SGX-RA requires to have installed:
the WASI-SDK, located in
/opt/wasi-sdk
Intel SGX dependencies
Before starting, we need to download and install SGX SDK and SGX DCAP Library referring to this guide.
The following commands are an example of the SGX environment installation on Ubuntu 20.04.
You can optionally grant users to communicate with the SDK platform using the following command. Otherwise, enclaves must be launched with root privileges.
Intel Provisioning Certification Service (Intel PCS)
Intel DCAP connects to Intel PCS to download the attestation collateral for SGX-enabled machines. Intel provides a quick install guide to set up a simplified environment. This section summarizes the commands to issue for setting up a working environment on Ubuntu 20.04.
Subscribe to Intel PCS Web services
Intel SGX DCAP requires a complimentary subscription to the Intel PCS. To subscribe to the service, browse the Intel SGX Software Services page. A the end of the subscription process, save the primary and the secondary keys.
Set up the Intel Provisioning Certification Caching Service (Intel PCCS)
Intel PCCS is a caching mechanism for attestation collateral, preventing continuously communicating with Intel PCS during attestation. Intel provides an implementation of the cache mechanism.
The following commands set up Intel PCCS.
The installation will run the PCCS setup script, asking you several questions.
Answer "Y" to this question.
Accept the default listening port of 8081.
Answer "N" to this question. We want the PCCS service to accept connections from other systems.
Enter either your primary or secondary key retrieved from the previous subsection. If you already subscribed, you can retrieve them here.
Answer "REQ" to this question. This places the caching service in the "on request" mode, which means it will fetch the attestation collateral for hosts as provisioning requests are received.
Enter two passwords for the PCCS server.
Answer "Y" to this question.
Provisioning the current system's Intel SGX collateral into the PCCS
Now that the PCCS is up and running, it's time to provision an Intel SGX-enabled platform. We use the tool PCKIDRetrievalTool
to get the attestation collateral of the current machine.
Adapt the configuration file of PCKIDRetrievalTool
located in /opt/intel/sgx-pck-id-retrieval-tool/network_setting.conf
and make the following changes:
Change the PCCS_URL to match your caching service's location.
Uncomment the user_token parameter, and set it to the user password you created when configuring the PCCS.
Set the proxy_type to fit your environment (most likely, this will be
direct
)Ensure USE_SECURE_CERT is set to
FALSE
since we're using a self-signed certificate for testing purposes.
Save your changes and run the provisioning tool.
You may get some warnings during this execution of the tool. A correct insertion into the cache server usually means the retrieval of the attestation collateral worked. Execute the following command to verify the collateral could be stored in your instance of Intel PCCS:
This should print a JSON value with the attestation collateral.
Runtime configuration
Edit the configuration file, /etc/sgx_default_qcnl.conf
, and make the following changes:
Set the PCCS_URL parameter to the location of our PCCS server.
Set USE_SECURE_CERT to
FALSE
since we're using a self-signed certificate for testing purposes.
This system is now ready to run Intel SGX workloads with generate evidence for remote attestation.
Build and executing the sample
The sample will print the evidence in JSON and the message: Evidence is trusted.
In case of validation issues expressed as a value of 0xeXXX
, the corresponding error reason is explained in this header file.
Validate quotes on non-SGX platforms
Quotes created on an Intel SGX platform can also be verified on systems that do not support SGX (e.g., a different CPU architecture). This scenario typically arises when deploying trusted applications in a cloud environment, which provides confidential computing.
For that purpose, we are required to install a subset of Intel SGX libraries to support quote validation. The steps below highlight how to set up such an environment.
Intel SGX dependencies
Set up the Intel Provisioning Certification Caching Service (Intel PCCS)
Follow the steps described in the section Set up the Intel Provisioning Certification Caching Service (Intel PCCS).
Runtime configuration
Follow the steps described in the section Runtime configuration.
Provisioning all the Intel SGX collateral into the PCCS
We must finally fetch and configure the SGX collaterals into the PCCS for all the SGX-enabled CPUs.
Validation of the quotes
The Wasm application can then be modified to validate precomputed quotes using the exposed function librats_verify
.
Alternatively, the underlying library librats
may be directly used if the non-SGX platforms do not execute WebAssembly code (without WAMR). Examples are provided in the directory non-sgx-verify/.
Claims validation
Once the runtime has validated the signature of the quote, the application must also check the other claims embedded in the quote to ensure they match their expected value.
The documentation Data Center Attestation Primitives: Library API describes in Section 3.8 Enclave Identity Checking defines the claims for the user to check. Here is a summary of them:
Enclave Identity Checking: either check the hash MRENCLAVE (the enclave identity) or MRSIGNER and the product id (the software provider identity).
Verify Attributes: production enclaves should not have the Debug flag set to 1.
Verify SSA Frame extended feature set
Verify the ISV_SVN level of the enclave: whenever there is a security update to an enclave, the ISV_SVN value should be increased to reflect the higher security level.
Verify that the ReportData contains the expected value: This can be used to provide specific data from the enclave or it can be used to hold a hash of a larger block of data which is provided with the quote. Note that the verification of the quote signature confirms the integrity of the report data (and the rest of the REPORT body).
Further readings
Last updated