Add decrypt only access for legacy AWS KMS keys - #5162
Conversation
3ddb516 to
d6d4c53
Compare
|
|
||
| /** KMS Key ARN for server-side encryption,used for writes, optional */ | ||
| /** Deprecated KMS Key ARN, retained for compatibility and treated as an allowed KMS key. */ | ||
| @Nullable |
There was a problem hiding this comment.
| @Nullable | |
| @Deprecated | |
| @Nullable |
There was a problem hiding this comment.
added, thanks you!
flyrain
left a comment
There was a problem hiding this comment.
LGTM overall. Thanks @iting0321 for the PR. I think it moves in the right direction. It's a spec change and we usually post it in dev mailing list for visibility. Can you start a discussion for this?
|
|
||
| List<String> allowedKmsKeys = getAllowedKmsKeys(); | ||
| checkArgument( | ||
| allowedKmsKeys == null || allowedKmsKeys.stream().noneMatch(legacyKmsKeys::contains), |
There was a problem hiding this comment.
The whole decrypt-only guarantee rides on this overlap check, and it compares ARN strings exactly. If the same key can show up in two forms, say an alias ARN in allowedKmsKeys and the underlying key ARN in legacyKmsKeys, those are different strings, so the check passes. Since AWS unions Allow statements, the legacy key would then still pick up encrypt from the allowed statement, defeating decrypt-only. Harmless if entries are always canonical key ARNs, but KMS keys aren't format-validated here the way roleARN is. Are canonical key ARNs guaranteed, or should this normalize/validate the ARN form before comparing?
There was a problem hiding this comment.
I agreed with this point, alias ARNs do not grant permissions to the underlying key, but wildcard resources such as key/* could bypass the exact-match overlap check and restore encryption access to a legacy key.
I’ll validate all configured values as concrete KMS key ARNs and reject aliases, wildcards, and non key ARN forms before checking overlap. Once inputs are canonical key ARNs, exact comparison is sufficient.
| type: string | ||
| description: the aws kms key arn used to encrypt s3 data | ||
| deprecated: true | ||
| description: Deprecated. Use allowedKmsKeys instead. The aws kms key arn used to encrypt and decrypt s3 data. |
There was a problem hiding this comment.
nit: arn -> ARN, aws -> AWS
| allowedKmsKeys: | ||
| type: array | ||
| description: The list of kms keys that this catalog and its clients are allowed to use for reading s3 data | ||
| description: The list of kms keys that this catalog and its clients are allowed to use for encrypting and decrypting s3 data |
There was a problem hiding this comment.
We kind of re-purpose it from "reading" to "encrypting and decrypting", but by checking the existing behavior, the allowedKmsKeys are also used for encryption, I think that repurposing is fine.
There was a problem hiding this comment.
Yes, exactly. This is only a documentation correction. allowedKmsKeys already receives encryption and data-key permissions.
| items: | ||
| type: string | ||
| example: ["arn:aws:kms::123456789001:key/01234578"] | ||
| legacyKmsKeys: |
There was a problem hiding this comment.
Maybe we could give a more descriptive name, like decryptOnlyKmsKeys
Thanks for your feedback! This is the link for dev mailing list : https://lists.apache.org/thread/fb1xjn9wmp5m0gk1yk59hjhzsj6jl8nq |
Summary
Fixes #3338 .
This change adds support for historical AWS KMS keys that can decrypt existing S3 data without being permitted to encrypt new data.
Previously, every explicitly configured KMS key received encryption permissions when Polaris vended write-capable credentials. During key rotation, this meant that retaining access to data encrypted with an older key also allowed clients to continue using that key for new writes.
Changes
legacyKmsKeysto the AWS catalog storage configuration.kms:DescribeKeykms:DecryptcurrentKmsKeyin favor ofallowedKmsKeyswhile preserving its existing behavior for compatibility.currentKmsKeyallowedKmsKeys--legacy-kms-keyCLI option.legacy_kms_keysin setup configuration import and export.Key rotation workflow
A key currently used for encryption should be configured as an allowed key:
After rotating to a new key, the previous key can be moved to the legacy list:
Credentials can then decrypt objects encrypted with the previous key, but cannot use it to encrypt new objects or generate data keys.
Validation
AWS combines permissions from applicable
Allowstatements. Therefore, emitting separate allowed-key and legacy-key statements would not enforce decrypt-only behavior if the same ARN appeared in both categories.The storage configuration now rejects overlap rather than silently choosing one category. This validation applies when catalog configuration is created and when persisted configuration is deserialized.
Overlap between
currentKmsKeyandallowedKmsKeysremains valid because both are encrypt-capable categories.Checklist
CHANGELOG.md(if needed)site/content/in-dev/unreleased(if needed)