Persistence in Conclave 1.2

Conclave Dec 07 2021 By: Divya Taori
Comments

0 Comments

Views

779 Views

Persistence in Conclave 1.2
Divya Taori
Divya Taori Blockchain Development (Corda Open Source)
Share this post:
Copied

Persistence in Conclave 1.2

Conclave 1.2 is here. It brings with it a load of important features, an important one being the Enclave Persistent Filesystem and the Persistent Map.

Conclave is a confidential computing platform used to develop solutions that pool and process confidential data from multiple parties. This computation can be used to provide a high level of insight and analysis.  Conclave builds on a trusted execution environment called an Enclave. An Enclave is a  trusted region in memory to which the CPU blocks access to. No other entity – such as the operating system or the computer provider – has access to the data within this trusted region. The Enclave process runs separately within the host but access is restricted to the host or the client. 

Enclaves have limited access to the outside world in order to keep them isolated from the rest of the server hardware.  Inside an Enclave, you don’t get access to components like filesystems, networks, and others normally found within an operating system. However, there could be cases where your application will require some way to retain state data – to allow storing of important data that is not lost during Enclave restarts. In other words, you need a way to persist information from your Enclave. A simple way to achieve this is to provide persistence using a filesystem.  

Conclave 1.1 implemented an in-memory Java file system. So, developers could download Java libraries and these libraries would work inside the Enclave. Version 1.1 of Conclave stored the entire filesystem within the Enclave memory, i.e. it provides an in-memory filesystem. Such a filesystem provides a good assurance of data privacy as all files are stored in encrypted enclave memory. Developers can use standard Java file input/output to work with these files. However, as it is an in-memory filesystem, the contents will be lost if the Enclave is restarted or stopped.

Conclave 1.2 combats this limitation with the support of a persistent filesystem. This filesystem is encrypted by the Enclave and is stored by the host in non-volatile storage, such as the disk of the host. From a developer standpoint, this is no different from using in-memory file storage, with the only difference being that the data gets persisted through the encrypted storage on the host. You can use the persisted filesystem to read and write files that need to be available after a restart of your Enclaves. This is represented as a single encrypted file on the host; your Enclave will load/save/read/write all files and directories into that file. The encryption is done using a key only known to the Enclave thus ensuring strong data confidentiality. When the Enclave restarts and if the filesystem file is present, Conclave will try to load and prepare the filesystem file so that it can be used by the Enclave.

To enable a persistent filesystem in your conclave application: 

  • Enable the persistentFileSystemSize in the Enclave runtime environment in build.gradle. This is the setting to specify the maximum size of the persisted filesystem. The default size for it is 0m – indicating that  the persisted filesystem is disabled. The size can be specified in bytes, but can also be specified in kilobytes, megabytes, or gigabytes, by inputting k, m, or g respectively after the value. It is important to note that this value cannot change once the Enclave has started for the first time. So it is important to  choose an appropriate value that is big enough for your long term needs.

conclave {
    ...
    ...
    inMemoryFileSystemSize = "0"
    persistentFileSystemSize = "64m"
    ...
    ...
    
}

If required, you can also specify the max size of the in-memory filesystem as well. You have the option to enable both types of filesystems or just one of them. In case you choose to have both the filesystems available, the persisted filesystem will be mapped to the / directory and the directory /tmp will be reserved for the in-memory filesystem. All files and directories that you write into /tmp directory will be considered temporary. All the other locations will be used to persist your files. In the case where either the in-memory or the persisted filesystem is chosen, the filesystem of your choice will be mounted to the / directory and you can write your files and directory wherever you want.

  • Specify the path to the encrypted filesystem file in your EnclaveHost.start.

enclaveHost.start(AttestationParameters.DCAP(), null, Paths.get("/home/USER/conclave.disk");

If you are using the host web server, add your file to the arguments under “filesystem.file”

  • Your Enclave code could now use the persisted filesystem inside  to perform Java file input/output operations within the Enclave.

--filesystem.file=./conclave.disk

Note that the Enclaves cannot access the disc directly, so it must rely on the host to provide the persistence. However, the host is untrusted and is considered to be a part of the attack surface for the Enclave. Any requests made by the Enclave to the host can give out information about access patterns of data which could potentially be used by the host to gain unwarranted information and insights. In response to this potential vulnerability, Conclave takes measures to ensure the data is not only encrypted but access patterns of data are also hidden from the host. Thus, Conclave does not only just encrypt the data but also hides any patterns within it that might give some clues as to what the Enclave is doing. Each block of data is encrypted using AES GCM encryption. This ensures that the blocks are tamper-resistant and each block is unique. The order of these blocks is randomized inside the Enclave before calling out the host to persist this data.

The Enclave may still be susceptible to replay and side-channel attacks occurring when the host observes the frequency of read/write actions to/from the file. Note that while the persisted filesystem is encrypted and unreadable by the host, this is not a transactional system when used alone and there would be no protection if the host performed a rollback attack. As mentioned in the last paragraph – the enclave relies on the host to store the encrypted filesystem file. So, here the host has complete control over which filesystem file version it provides to the enclave. A malicious host may give back an older block of the file to the enclave. As for the enclave, it cannot detect an older version as it doesn’t have access to a trusted time source or a secure monotonic counter. Thus, the enclave cannot check if it has been given an older copy of the filesystem.

 An alternate way to persist information in Conclave is the persistent map. The persistent map is a persistent, encrypted key-value store that is hardened against rollback attacks. The enclave can use this key-value store to persist information as required.

Enabling the persistent map has potential performance implications – as the enclave must encrypt the map every time it processes a new mail from the client. In addition, it adds an extra burden on the client (The  Enclave Client in v1.2 could help with it). Therefore, one must evaluate the tradeoffs before making a design decision. One may also use the persistent map along with the persistent filesystem to provide better security. 

  • To enable the persistent map, enable the same in the Enclave’s build.gradle. Set the enablePersistentMap to true (the default is false) and specify the maxPersistentMapSize (the default is 16m).

conclave {
    ...
    ...
    enablePersistentMap = true
    maxPersistentMapSize = "16m"
    ... 
    ...
    
}

You could now use the persistent map within your Enclave. A sample showing the use of persistent map and persistent filesystem can be found here.

To learn more, make sure to visit conclave.net or join the conclave-discuss mailing list, where you’ll have a direct line to the Conclave development team. Special thanks to Shams Asari, Marco Bonifazi, and Roy Hopkins for their help with this blog.

Divya Taori
Divya Taori Divya Taori is a Developer Evangelist at R3, an enterprise blockchain software firm working with a global ecosystem of more than 350 participants across multiple industries from both the private and public sectors to develop on Corda, its open-source blockchain platform, and Corda Enterprise, a commercial version of Corda for enterprise usage.

Leave a Reply

Subscribe to our newsletter to stay up to date on the latest developer news, tools, and articles.