AWS clean-rooms: Fix Clean Rooms KMS key policy examples: add aws:SourceArn confused-deputy guard
Summary
Corrects the example customer managed key policies for AWS Clean Rooms: replaces the invalid `ForAnyValue:ArnEquals` operator with `ArnEquals`, adds an `aws:SourceArn` condition (scoped to membership ARNs) to the service-principal statements for confused deputy protection, drops the `kms:CallerAccount` condition from the caller-validation statement, and adds a new example policy plus note for intermediate tables populated by PySpark analysis templates that uses `StringLikeIfExists` for `kms:EncryptionContext:aws:cleanrooms:intermediateTableArn` because custom encryption context is not supported for those tables.
Security assessment
The diff hardens documented KMS key policies by adding `aws:SourceArn` conditions to the `cleanrooms.amazonaws.com` service-principal statements, explicitly described as confused deputy protection, and fixes an incorrect condition operator (`ForAnyValue:ArnEquals` -> `ArnEquals`) that would have made the example policy behave differently than intended. It also documents the weaker `StringLikeIfExists` requirement for PySpark intermediate tables, which is a deliberate, explained relaxation of encryption-context scoping. These are authorization/encryption policy controls, so severity is high.
Evidence
+The second statement allows the service to describe the key for validation purposes. Like the first statement, the `aws:SourceArn` condition restricts it to the same membership ARNs, which provides confused deputy protection.
Diff
diff --git a/clean-rooms/latest/userguide/data-protection.md b/clean-rooms/latest/userguide/data-protection.md index 77af5d7..9922478 100644 --- a//clean-rooms/latest/userguide/data-protection.md +++ b//clean-rooms/latest/userguide/data-protection.md @@ -378 +378 @@ The following is an example key policy for using a customer managed key with int - "ForAnyValue:ArnEquals": { + "ArnEquals": { @@ -395 +395,9 @@ The following is an example key policy for using a customer managed key with int - "Resource": "*" + "Resource": "*", + "Condition": { + "ArnEquals": { + "aws:SourceArn": [ + "arn:aws:cleanrooms:us-east-1:666666666666:membership/member-1-membership-id", + "arn:aws:cleanrooms:us-east-1::membership/member-2-membership-id" + ] + } + } @@ -411,2 +419 @@ The following is an example key policy for using a customer managed key with int - "kms:ViaService": "cleanrooms.us-east-1.amazonaws.com", - "kms:CallerAccount": "666666666666" + "kms:ViaService": "cleanrooms.us-east-1.amazonaws.com" @@ -421 +428 @@ The first statement grants the AWS Clean Rooms service principal access for encr -The second statement allows the service to describe the key for validation purposes. +The second statement allows the service to describe the key for validation purposes. Like the first statement, the `aws:SourceArn` condition restricts it to the same membership ARNs, which provides confused deputy protection. @@ -423 +430 @@ The second statement allows the service to describe the key for validation purpo -The third statement allows a specific IAM role in the customer's account to perform key validation through AWS Clean Rooms. The permitted actions are DescribeKey, GenerateDataKey, and Decrypt. Access is scoped using `kms:ViaService` and `kms:CallerAccount` conditions. This role is typically the IAM role that you use to interact with AWS Clean Rooms. +The third statement allows a specific IAM role in the customer's account to perform key validation through AWS Clean Rooms. The permitted actions are DescribeKey, GenerateDataKey, and Decrypt. The `kms:ViaService` condition scopes access. This role is typically the IAM role that you use to interact with AWS Clean Rooms. @@ -435,0 +443,73 @@ Every AWS KMS operation is logged in CloudTrail with the intermediate table ARN, +Note + +Custom AWS KMS encryption context (`kms:EncryptionContext`) isn't supported for intermediate tables that you create from a PySpark analysis template. + +Because the encryption context isn't present for an intermediate table that you populate with a PySpark analysis template, use `StringLikeIfExists` instead of `StringLike` in the first statement. This lets the policy allow requests that don't include the encryption context, while still restricting access by the intermediate table ARN when the encryption context is present. The following is an example key policy for an intermediate table that you populate with a PySpark analysis template: + + + { + "Version": "2012-10-17", + "Statement": [ + { + "Sid": "Allow Clean Rooms to encrypt and decrypt intermediate table data", + "Effect": "Allow", + "Principal": { + "Service": "cleanrooms.amazonaws.com" + }, + "Action": [ + "kms:GenerateDataKey", + "kms:Decrypt" + ], + "Resource": "*", + "Condition": { + "StringLikeIfExists": { + "kms:EncryptionContext:aws:cleanrooms:intermediateTableArn": "arn:aws:cleanrooms:us-east-1:666666666666:membership/membership-id/intermediatetable/intermediate-table-id" + }, + "ArnEquals": { + "aws:SourceArn": [ + "arn:aws:cleanrooms:us-east-1:666666666666:membership/member-1-membership-id", + "arn:aws:cleanrooms:us-east-1::membership/member-2-membership-id" + ] + } + } + }, + { + "Sid": "Allow Clean Rooms to describe key", + "Effect": "Allow", + "Principal": { + "Service": "cleanrooms.amazonaws.com" + }, + "Action": [ + "kms:DescribeKey" + ], + "Resource": "*", + "Condition": { + "ArnEquals": { + "aws:SourceArn": [ + "arn:aws:cleanrooms:us-east-1:666666666666:membership/member-1-membership-id", + "arn:aws:cleanrooms:us-east-1::membership/member-2-membership-id" + ] + } + } + }, + { + "Sid": "Allow caller to validate key via Clean Rooms", + "Effect": "Allow", + "Principal": { + "AWS": "arn:aws:iam::666666666666:role/ExampleRole" + }, + "Action": [ + "kms:DescribeKey", + "kms:GenerateDataKey", + "kms:Decrypt" + ], + "Resource": "*", + "Condition": { + "StringEquals": { + "kms:ViaService": "cleanrooms.us-east-1.amazonaws.com" + } + } + } + ] + } +