Reputation: 35
Is there a way to load an existing application into an Intel SGX
enclave directly?
Upvotes: 2
Views: 1842
Reputation: 36
As pointed out by previous answers, the Intel SGX default design does not permit to run ummodified programs in general, because they contain (most likely) routines which are unsupported (all syscalls) by the trusted libc provided by the Intel SGX SDK. Tools such as Scone, Graphene SGX, Haven, or SGX-LKL allow to run unmodified applications in Intel SGX enclaves.
Most of the above mentioned tools run mini-OSes inside the enclave to handle (via emulation) the unsupported syscalls or libc routines. This leads to a large enclave size or a large TCB, which is not good for security, and performance (as the enclave memory is limited to 128MB or 256MB in more recent SGX versions.
The solution you choose to use will depend largely on the program you are trying to run. If the program is not that large, you could try porting it to Intel SGX. Porting involves separating your application into trusted and untrusted parts. Only the trusted part will run in the enclave, and may communicate with the untrusted part (a helper) out of the enclave runtime. During porting you may still have trusted code which depends on unsupported routines like syscalls. You could solve this problem by reimplementing unsupported calls (e.g., syscalls) as ocalls which then invoke the real routines out of the enclave; good example here. This way you will maximize enclave memory and prevent bloating it will a full-blown library OS.
On the other hand, if you are dealing with a very complex application where porting is not feasible, then I will advice you to go for a solution such as Graphene-SGX which runs the full unmodified program inside the enclave. Graphene-SGX is opensource and well documented.
Upvotes: 0
Reputation: 1902
Intel SGX
is designed for securing data and not loading the entire application. You can perform secure computations inside the SGX
enclaves on your data by sending temporary buffers from the user space program (app.cpp
) to your SGX
enclave (Enclave.cpp
). But why?
open
for opening a file.Thus, if your application is large or contains some syscalls or even some forbidden standard C library functions by SGX
implementation, it is impossible to import it entirely inside an enclave. But, if your application is doing some primitive operations without the need for any special syscall or function call, you can freely port it inside an enclave. Still, you can't directly load it inside an enclave you have to change your implementation to make it as a trusted enclave call inside the Enclave.cpp
.
As an example, I've implemented a set of cryptographic operations e.g. SHA-2, HMAC SHA-2, AES, and etc. inside an enclave. I send/receive temporary buffers of pliantext/ciphertext data to/from enclave performing the encryption/decryption operations inside the enclave and storing the results of computation like a hash digest, or ciphertexts in userspace. In this way, I ensure that no one can tamper the results of operations because they're running inside the enclave which is secured by CPU instructions.
You can read more about this example here and check the implementation here.
Upvotes: 1
Reputation: 402
While hmofrad is right with the statement that SGX is not designed to run an entire existing application, there are approaches to achieve exactly this: There is SCONE (closed source) and Graphene (open source). So you could read up on Graphene with SGX and check if this fits your need.
Upvotes: 3