apache / incubator-teaclave-sgx-sdk

Apache Teaclave (incubating) SGX SDK helps developers to write Intel SGX applications in the Rust programming language, and also known as Rust SGX SDK.
https://teaclave.apache.org
Apache License 2.0
1.16k stars 257 forks source link

support kvdb for enclave? #103

Open bradyjoestar opened 5 years ago

bradyjoestar commented 5 years ago

I want to support memdb for rust-sgx-sdk and at the same time writing a sample which works in the following ways:

Is this feasible in theory? If true, I'd like to be reviewed and merged. :smile:

dingelish commented 5 years ago

Really good idea!

I think it's a pretty good start of a protected db. The sample code will be a fantastic proof-of-concept.

To use it in production, one needs to consider about authentication and authorization.

bradyjoestar commented 5 years ago

yeah!it's may be more useful if we consider the persistence of protected db.:beers:

bradyjoestar commented 5 years ago

Maybe we could directly try to support kvdb in enclave? It includes kvdb-memdb and kvdb-rocksdb which from paritytech/parity-commons. At the same time we would provide two examples:

memdb

This is used to show how to save some data which we want to be reused for a long time, such as the tls keypair.

rocksdb

This is used to show how to use rocksdb as protected db, we may need to solve the following problems:

tomtau commented 5 years ago

@bradyjoestar @dingelish for the persistent (e.g. rocksdb) backend, one additional problem would be freshness -- one could overwrite the db state with an old authentic and encrypted state. As this is for "cloud" web apps (https://github.com/baidu/rust-sgx-sdk/issues/110 ) Intel ME functionality (like monotonic counters) that could help may not be available.

tomtau commented 5 years ago

I guess a more "cloud-friendly" alternative for persistent db freshness would be some fault-tolerant enclave kvdb replication?

tomtau commented 5 years ago

https://www.usenix.org/system/files/conference/usenixsecurity17/sec17-matetic.pdf

dingelish commented 5 years ago

Just noticed that parity’s kvdb-memorydb is under GPLv3. Do we really need to depend on this?

dingelish commented 5 years ago

I think I need to fork parity-common to another repo instead of place them in this repo.

dingelish commented 5 years ago

Assigned to myself.

bradyjoestar commented 5 years ago

Sure!

bradyjoestar commented 5 years ago

I guess a more "cloud-friendly" alternative for persistent db freshness would be some fault-tolerant enclave kvdb replication?

@tomtau I'm not proficient in database so give me some time to learn :smile: Thanks to your suggestion and I will read the paper carefully.