AWS kms: Add KMS guidance on session-specific context and cached data keys
Summary
Adds a new section explaining that AWS services integrated with KMS (SQS, DynamoDB, S3 Bucket Keys) cache data keys and may omit session-specific context from their cache lookup key, so session-scoped conditions in a KMS key policy may not be enforced per session. Includes example Allow/Deny key policy statements and advises restricting access via the integrated service's own policies.
Security assessment
The added text documents a concrete authorization weakness: a DeniedUser session of a role can reuse a data key cached for an AllowedUser session because the cache lookup key omits session context, potentially allowing unauthorized read/write of S3 objects. It is documentation of the weakness plus mitigation guidance (enforce session conditions in the integrated service's policies), not a code fix, so severity is medium.
Evidence
+Because S3 Bucket Key doesn't include the session name in its cache lookup key, the `DeniedUser` session might be able to read and write objects in the bucket.
Diff
diff --git a/kms/latest/developerguide/conditions-aws.md b/kms/latest/developerguide/conditions-aws.md index 36e2b24..b5f0279 100644 --- a//kms/latest/developerguide/conditions-aws.md +++ b//kms/latest/developerguide/conditions-aws.md @@ -7 +7 @@ -Using the IP address conditionUsing VPC and VPC endpoint conditionsUsing IPv6 addresses in IAM and KMS key policies +Using the IP address conditionUsing VPC and VPC endpoint conditionsUsing IPv6 addresses in IAM and KMS key policiesUsing session-specific context @@ -19 +19 @@ For information about AWS global condition keys, including the types of requests -The following topics provide special guidance for using condition keys based on IP addresses and VPC endpoints. +The following topics provide special guidance for using condition keys based on IP addresses, VPC endpoints, and session-specific context. @@ -28,0 +29,2 @@ The following topics provide special guidance for using condition keys based on + * Using session-specific context with AWS services that cache data keys + @@ -110,0 +113,40 @@ You can modify the `Condition` element to deny both IPv4 (`192.0.2.0/24`) and IP +## Using session-specific context with AWS services that cache data keys + +[AWS services integrated with AWS KMS](./service-integration.html) can use [forward access sessions](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_forward_access_sessions.html) (FAS) to call AWS KMS on your behalf. Some of these services temporarily cache [data keys](./data-keys.html) to limit their volume of FAS requests, which helps you avoid throttling and high API charges. Services derive a cache lookup key from request context to determine which requests can reuse a cached data key without calling AWS KMS. To keep their caches efficient, services might not include all session context in their cache lookup key. The cache lookup key usually includes the IAM role or user that makes a request, but not session-specific context. As a result, different sessions of the same role, user, or root user might reuse the same cached data key without authorizing every session to a KMS key. + +Important + +To control access with session-specific conditions, add those conditions to the policies of the integrated service, such as an Amazon S3 bucket policy. The integrated service evaluates its own policies on every request. AWS KMS evaluates conditions in your key policy only when the service calls AWS KMS. + +The cache lookup key implementation varies by service. Amazon SQS, DynamoDB, and Amazon S3 with [S3 Bucket Keys](https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucket-key.html) enabled are examples of services that cache data keys to limit FAS requests. + +Consider the following example key policy statements for a KMS key that encrypts an Amazon S3 bucket with S3 Bucket Key enabled. In this policy example, the `AllowedUser` session of the `ExampleRole` role can use the KMS key, but the `DeniedUser` session of the same role cannot. + + + { + "Sid": "AllowSession", + "Effect": "Allow", + "Principal": { + "AWS": "arn:aws:sts::111122223333:assumed-role/ExampleRole/AllowedUser" + }, + "Action": [ + "kms:Decrypt", + "kms:GenerateDataKey" + ], + "Resource": "*" + }, + { + "Sid": "DenySession", + "Effect": "Deny", + "Principal": { + "AWS": "arn:aws:sts::111122223333:assumed-role/ExampleRole/DeniedUser" + }, + "Action": [ + "kms:Decrypt", + "kms:GenerateDataKey" + ], + "Resource": "*" + } + +Because S3 Bucket Key doesn't include the session name in its cache lookup key, the `DeniedUser` session might be able to read and write objects in the bucket. When the `AllowedUser` session makes a request, Amazon S3 caches the bucket key for `ExampleRole`. Until that cache entry expires, Amazon S3 can serve requests from the `DeniedUser` session without calling AWS KMS. To reliably deny the `DeniedUser` session, restrict its access to Amazon S3 API operations through other relevant policy types. +