sec(iac): scope kms:GetKeyPolicy away from Resource=* - #525
Conversation
Move kms:GetKeyPolicy from KMSCreateAndRead (Resource="*", account-wide) to a new KMSReadTaggedOnly statement in policy_compute_b.tf gated on aws:ResourceTag/Project=CUDly. This prevents a compromised deploy token from reading key policies of unrelated KMS CMKs in the account (key-policy reconnaissance), while still allowing the deploy SA to read policies of CUDly-owned keys (which are tagged at CreateKey time by the Terraform aws_kms_key resource). Split to policy_compute_b.tf because policy_compute.tf is at the AWS 6144-char managed-policy limit. Closes #427.
|
Warning Review limit reached
More reviews will be available in 43 minutes and 48 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR refines KMS IAM permissions to enforce least-privilege by removing unrestricted ChangesKMS Permission Least-Privilege Refinement
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai review |
1 similar comment
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
|
@coderabbitai full review |
Rate Limit Exceeded
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@coderabbitai full review |
✅ Action performedFull review finished. |
Summary
kms:GetKeyPolicyfromKMSCreateAndRead(Resource="*") — this action reveals the full trust model of a CMK (all principals and conditions).KMSReadTaggedOnlystatement forkms:GetKeyPolicygated onaws:ResourceTag/Project=CUDly. A compromised deploy token can now only read key policies of CUDly-owned CMKs, not enumerate the key policies of every CMK in the account.The tag condition works correctly because
aws_kms_keysets theProject=CUDlytag atCreateKeytime (via theTagsparameter), beforeGetKeyPolicyis ever called on the new key.Split to
policy_compute_b.tfbecausepolicy_compute.tfis at the AWS 6144-char managed-policy limit.Test plan
terraform fmt -check -recursivepasses (pre-commit verified)terraform validatein ci-cd-permissions passesCloses #427.
Summary by CodeRabbit