Spec: Add key-id and deprecate key-metadata in table and partition statistics - #17533
gaborkaszab wants to merge 3 commits into
Conversation
i understand the rational of using key-id but what i don't understand is why storing key-metadata unsecure ? because we contain wrapped key as if encrypted value instead of raw ? are there more details to this .... cc @ggershinsky |
|
Hey @singhpk234 , The problem with See @ggershinsky 's and @RussellSpitzer 's comments here. |
|
Ah i see, this is unwrapped key metadata which was used to encrypt this file, and not the encrypted keymedata, then it makes sense to have have this wrapped and then have key-id from the table.metadata_keys .... we will wrap this KEK then like we do with MLK then ? |
|
@singhpk234 yes, this would work exactly the same way as manifest list encryption keys. |
RussellSpitzer
left a comment
There was a problem hiding this comment.
This looks good to me, we should bring it up on the dev list before we merge the spec change
Thanks for the reviews, @ggershinsky @singhpk234 @RussellSpitzer ! |
| | _optional_ | _optional_ | **`key-metadata`** | | Base64-encoded implementation-specific key metadata for encryption. | | ||
| | _required_ | _required_ | **`blob-metadata`** | `list<blob metadata>` (see below) | A list of the blob metadata for statistics contained in the file with structure described below. | | ||
| === "v1 - v4" | ||
| | v1 and v2 | v3 | v4 | Field name | Type | Description | |
There was a problem hiding this comment.
We changed v2 and v3 to v1 and v2. is this intentional?
There was a problem hiding this comment.
That is intentional. These columns are the same between "v1" and "v2 and v3". Initially I figured we could merge all these together, but I figured we might want to deprecate key-metadata earlier in V3 so kept that version separately. I can revert if this is distracting.
There was a problem hiding this comment.
I did revert the regrouping to remove noise. I might open a follow-up refactor to merge v1-v3 cols in the table
|
@singhpk234 @RussellSpitzer @stevenzwu @ggershinsky @rdblue
|
| | _required_ | _required_ | **`file-footer-size-in-bytes`** | `long` | Total size of the statistics file's footer (not the footer payload size). See [Puffin file format](puffin-spec.md) for footer definition. | | ||
| | _optional_ | _optional_ | **`key-metadata`** | | Base64-encoded implementation-specific key metadata for encryption. | | ||
| | _required_ | _required_ | **`blob-metadata`** | `list<blob metadata>` (see below) | A list of the blob metadata for statistics contained in the file with structure described below. | | ||
| === "v1 - v4" |
There was a problem hiding this comment.
I think this diff is much too large. We don't need to add a v4 column that is a copy of the other two existing columns and mix those changes into this diff. If I understand the diff correctly, the only thing that should change is that key-metadata should be deprecated and key-id should be added.
There was a problem hiding this comment.
That's right. key-metadata is deprecated now, and there is a new field for key-id. Note, for key-metadata there was no type, I added string.
Reverted the V4 column, should be more readable now.
| @@ -1239,13 +1238,14 @@ | |||
| Partition statistics file must be registered in the table metadata file to be considered as a valid statistics file for the reader. | |||
|
|
|||
| `partition-statistics` field of table metadata is an optional list of structs with the following fields: | |||
There was a problem hiding this comment.
Same here. Please revert the rest of the changes so this diff doesn't include the entire table.
|
@gaborkaszab, I think the changes look okay, but this isn't very reviewable because I have to manually diff the tables. Since there aren't substantive changes to the other rows, let's minimize the diff. |
|
Thanks for taking a look, @rdblue ! |
|
Hey @rdblue , |
|
@rdblue Is this something we can start a vote on? |
| | _required_ | _required_ | **`file-size-in-bytes`** | `long` | Size of the statistics file. | | ||
| | _required_ | _required_ | **`file-footer-size-in-bytes`** | `long` | Total size of the statistics file's footer (not the footer payload size). See [Puffin file format](puffin-spec.md) for footer definition. | | ||
| | _optional_ | _optional_ | **`key-metadata`** | | Base64-encoded implementation-specific key metadata for encryption. | | ||
| | _optional_ | _optional_ | **`key-metadata`** | `string` | Base64-encoded implementation-specific key metadata for encryption. (**Deprecated**: use `key-id` instead) | |
There was a problem hiding this comment.
I think there is still a problem in that we are mixing file-level keys with table-level keys. The keys table is intended to be a small set of keys that are reused and occasionally rotated, not file-specific.
@ggershinsky, how should we handle these? Do we need a way to store encrypted key metadata? What I'm thinking is that we keep key-metadata but add an optional key-id that is used to encrypt the stats file key?
There was a problem hiding this comment.
for manifest lists, we did the following: #12162 #12927
An "encrypted key metadata" is a 4-field record (key-id, encrypted-key-metadata, encrypted-by-id, properties map). All of these records are kept in the TableMetadata.encryption-keys list. Some of them are reusable (key encryption keys), but most of them are specific to manifest files. Each snapshot object keeps the key-id of the "encrypted key metadata" of its manifest list file.
The situation with stats files looks similar (if not identical) to the manifest list files. A straightforward technical approach would be to do the same: write a 4-field "encrypted key metadata" record in the TableMetadata.encryption-keys list, and add pointer to the record (key-id) to the stats file object.
There was a problem hiding this comment.
Thanks for looking into this @rdblue and @ggershinsky !
I think the main questions here are 1) reusability of keys and 2) whether reusability requires any special care in the spec.
- I did an experiment the other day and for me it seems that each manifest list file adds a new
EncryptedKeyinto theencryption-keyslist. There is (are?) additional KEK entry(ies) on top of that in the list. I'm not sure about custom implementations but for me it seems that there is no reuse ofEncryptedKeyentries across different manifest lists, apart from the KEK used to encrypt theEncryptedKeys.
Keys for stat files fit into this pattern, they could behave the same way as keys for manifest lists. Let me know if I miss something here. - I think the spec changes in this PR can express both the reused key and the non-reused key scenario.
key-idfor statistics files is just an ID to be used for finding theEncryptedKeyin theencryption-keyslist that in turn can be used to decrypt the statistics files (after decrypting the foundEncryptedFileitself using the KEK). Whether this is a reusedEncryptedFileacross files or not, I don't think matters in this context.
While I'm still learning this area of the project, let me know where my assumptions go wrong :)
|
these assumptions sgtm. one general point on re-use of file encryption keys. Due to AES GCM limits, the standard practice is to create a key per file - otherwise, it's hard to guarantee the data safety. That's why our EncryptionManager generates a random key for each output file. |
Storing key-metadata in TableStatistics and PartitionStatistics is unsecured, because that is persisted into table metadata, that itself is not encrypted. As an existing design for manifest list, we encrypt the key-metadata, and save the key-id of the encryption key that we used to encrypt key-metadata.