-
Notifications
You must be signed in to change notification settings - Fork 39
Add proposal for crypto building block #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
mukundansundar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should subtle crypto ops be available via dapr CLI?
I don't see why not. But keep in mind the high-level ops are probably going to be gRPC-only. |
This might conflict with our criteria to make APIs stable, in guaranteeing they have both gRPC and HTTP implementations. @mukundansundar do we have that listed in API maturity criteria right now? |
Currently in the API guidelines the requirements for a new API are for proposals
further below for Alpha APIs
Both of these are recommendations that they should be consistent and supported. Not a strong requirement. |
Note that subtle operations are supported for both HTTP and gRPC and what I am writing below ONLY applies to the high-level encryption/decryption APIs The rationale for only supporting gRPC is in the proposal:
Imagine the situation where you're encrypting (or decrypting) a very large file (multiple MBs or GBs). If you were to do that via HTTP, you'd have to send your entire blob to the runtime, then wait for the runtime to process it, and then read the response back. Even in the best-case scenario, where the runtime flushes the data as soon as it's processed, you still have an amount of data equal to the length of the message in memory at some point. Using gRPC we are able to use 2-way streaming. The Dapr SDK would chunk the data and send each chunk to the runtime. The runtime processes the chunk and sends it back (encrypted or decrypted). The runtime will never need to keep in memory more data than the size of a chunk (64KB in the proposal for the high-level encryption scheme). That's MUCH better than possibly holding GBs in memory. The Dapr Encryption Scheme proposed verifies the data chunk-by-chunk, so even during decryption, we are never flushing un-verified data to the caller and this is considered safe. So my point on not supporting HTTP is essentially to protect users from themselves, as there will be the temptation of sending large files over HTTP and that will cause memory issues.
PS: The guidelines use should to indicate that both HTTP and gRPC should be supported, but it's not a strict requirement. During discussion, we highlighted a bunch of scenarios where it would be not advisable to support both protocols, and I believe this is one of them (most scenarios involved the need for streaming) |
|
I support this. |
|
I support the introduction of this building block |
|
@johnewart and I had a review with the "crypto board" at Microsoft to advise on the design of the high-level encryption scheme. Overall we got approval from them, albeit with some small tweaks. I have applied a few of them already, and will complete the work by EOW. The crypto board did not comment on the APIs being exposed, as that's purely a Dapr decision, just the design of the encryption scheme, the keys and algorithms used, etc. |
|
Completed updating the document with feedback from the crypto board. The change was in the headers of the Dapr encryption scheme, which is now a JSON object that covers both the "plain-text" header and the "binary" header. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM overall. Just some feedback:
- Give an example of a
cryptocomponent's YAML. - Add HTTP High-Level API too - even with the perf penalty. It can be handy for local development and debugging.
- The high level API should be done first:
- It will "wow" most users and our target audience does not really want to deal with low level APIs. I would even argue that people using low level crypto APIs might not consider Dapr at all.
- It is a smaller exposed surface for us to quickly add to the SDKs.
|
One more point, we need a reference to the encryption key in the high-level API's payload, so old data can be decrypted after key rotation. Asking users to manage key rotation would make the high-level API not as useful. |
|
I added the HTTP APIs for high-level crypto, although their use is strongly discouraged (and limited by Dapr's max-http-request-size). As for this:
I have thought about that, but I am not sure how I feel about this. It's pretty common for users to have to provide the key (or at least its name) when performing decryption operations. None of the schemes that the Dapr Encryption Scheme v1 is based on reference the key name in the message. In the current API design, users are required to pass the name of the key used to decrypt the data in the request, and that seems to be the usual pattern. If users think that they will need to rotate keys, they should keep a reference to the key used stored alongside the data Additionally, the name of the key is dependent on where it's stored. The same key could have different names when stored locally and when in Azure I don't see how knowing the key in the message would help with key rotation. In all cases, users are required to keep around the old key if they want to continue decrypting the messages encrypted with that key (and this is a usual pattern). Also worth pointing out that key rotation should be less of a concern with the Dapr encryption scheme, which can be used to safely encrypt as many messages as one wants (unlike the current Dapr state store encryption which is limited to 2^33 messages ever).
|
Why the reference to Azure Storage specifically? |
Sorry, that was a lapse. I meant Azure Key Vault, and fixed my message now |
Implements the Subtle Crypto APIs (low-level) as defined in dapr/proposals#3 These APIs are implemented as universal APIs. They include support for resiliency and metrics. Signed-off-by: ItalyPaleAle <[email protected]>
Implements the Subtle Crypto APIs (low-level) as defined in dapr/proposals#3 These APIs are implemented as universal APIs. They include support for resiliency and metrics. Signed-off-by: ItalyPaleAle <[email protected]>
|
@artursouza I thought more about your ask to include the key ID into the manifest, and how I could make that work, and I am still not convinced. I could find 3 problems:
Thoughts? If not, are we ok to get this proposal officially approved? |
Ported from dapr/dapr#4508 Signed-off-by: ItalyPaleAle <[email protected]>
28e3dc3 to
f7711c3
Compare
We might need additional metadata in the crypto components to handle key references, maybe create aliases that are portable. My point being that having a high level building block without metadata to enable key rotation dramatically reduces the value add for this API. If there is significant work for users to implement key rotation on top of this API, they might decide not to use it at all. |
Signed-off-by: ItalyPaleAle <[email protected]>
|
@artursouza and I synced offline on the issue with "key binding" and we believe we have a solution that addresses the concerns each of us had.
I've updated the proposal for the high-level design: b713672 |
Signed-off-by: ItalyPaleAle <[email protected]>
Implements the Subtle Crypto APIs (low-level) as defined in dapr/proposals#3 These APIs are implemented as universal APIs. They include support for resiliency and metrics. Signed-off-by: ItalyPaleAle <[email protected]>
|
The only thing is to use the new names instead from the thread we had. excludeDecryptionKey bool |
|
The change is in place:
|
|
+1 binding |
Signed-off-by: ItalyPaleAle <[email protected]>
|
FYI I have made a small change to the proposal to clarify the algorithms support for key wrapping in the high-level scheme.
|
|
+1 binding |
Implements the Subtle Crypto APIs (low-level) as defined in dapr/proposals#3 These APIs are implemented as universal APIs. They include support for resiliency and metrics. Signed-off-by: ItalyPaleAle <[email protected]>
Signed-off-by: ItalyPaleAle <[email protected]>
8a66f66 to
91b9d86
Compare
Implements the Subtle Crypto APIs (low-level) as defined in dapr/proposals#3 These APIs are implemented as universal APIs. They include support for resiliency and metrics. Signed-off-by: ItalyPaleAle <[email protected]>
* Add SubtleCrypto APIs for HTTP and gRPC Implements the Subtle Crypto APIs (low-level) as defined in dapr/proposals#3 These APIs are implemented as universal APIs. They include support for resiliency and metrics. Signed-off-by: ItalyPaleAle <[email protected]> * Gate APIs behind a build-time flag Signed-off-by: ItalyPaleAle <[email protected]> * Changed per review feedback Signed-off-by: ItalyPaleAle <[email protected]> * Make CryptoValidateRequest available also in the included module (needed by high-level API) Signed-off-by: ItalyPaleAle <[email protected]> * 💄 Signed-off-by: ItalyPaleAle <[email protected]> * 💄 Signed-off-by: ItalyPaleAle <[email protected]> --------- Signed-off-by: ItalyPaleAle <[email protected]> Co-authored-by: Mukundan Sundararajan <[email protected]>
Ported from dapr/dapr#4508