Skip to content

Spec: Add key-id and deprecate key-metadata in table and partition statistics - #17533

Open
gaborkaszab wants to merge 1 commit into
apache:mainfrom
gaborkaszab:main_spec_key_id_in_stats
Open

Spec: Add key-id and deprecate key-metadata in table and partition statistics#17533
gaborkaszab wants to merge 1 commit into
apache:mainfrom
gaborkaszab:main_spec_key_id_in_stats

Conversation

@gaborkaszab

Copy link
Copy Markdown
Contributor

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.

@singhpk234

Copy link
Copy Markdown
Contributor

key-metadata in TableStatistics and PartitionStatistics is unsecured, because that is persisted into table metadata

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

@gaborkaszab

Copy link
Copy Markdown
Contributor Author

Hey @singhpk234 ,

The problem with key-metadata is that it is the raw, unencrypted information on how to decrypt stuff. While it's safe to keep key-metadata on e.g. the data file / manifest entry level, because those files are encrypted themselves in turn encrypting key-metadata together with the file it contains this field, it's not safe to keep it on the table metadata level because that is not encrypted. It would expose the raw key-metadata. The same goes for manifest list encryption, and I believe we should follow the same approach for statistics file linked from table metadata.

See @ggershinsky 's and @RussellSpitzer 's comments here.

@singhpk234

Copy link
Copy Markdown
Contributor

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 ?

@gaborkaszab

Copy link
Copy Markdown
Contributor Author

@singhpk234 yes, this would work exactly the same way as manifest list encryption keys.

Comment thread format/spec.md
| _required_ | _required_ | _required_ | **`file-size-in-bytes`** | `long` | Size of the statistics file. |
| _required_ | _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. (**Deprecated**: use `key-id` instead) |
| _optional_ | _optional_ | _optional_ | **`key-id`** | `string` | ID of the encryption key that encrypts the statistics file key metadata |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it be the current KEK or the KEK of the snapshot MLK was encrypted with ? there is possibility that a new KEK is created before we ran an offline process to collect stats ? in that case we use KEK of the MLK for snapshot != KEK of the partition file.
I think it should be fine i think but i want to bring this up for discussion

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not the MLK's encryption key.
In my understanding TableMetadata.encryptionKeys contains the following types of encrypted keys:

  1. The table's encryption key that is used to encrypt all the other keys in the list (KEK)
  2. The encryption keys used for encrypting manifest lists
  3. The encryption keys used for encrypting snapshot files (this is newly introduced in API, Core, Spark 4.1: Add key_metadata and encrypted write support for StatisticsFile #17417)

In this case this key-id refers to a particular encrypted key for type 3)

If my understanding is incorrect, please let me know.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, a typo "snapshot" -> "statistics".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Specification Issues that may introduce spec changes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants