AWS Fundamentals Series

🔑 Understanding AWS KMS's Key Policy From a Top 1% Perspective — Even When an IAM Policy 'Allows' It, You Still Can't Decrypt if the Key Policy Sits on the Deny Side

Introduction

This article is part of the Top 1% Series Complete Article Guide, and article 14.1 in the AWS Series.

Prerequisite Knowledge

Getting the Big Picture

With most AWS services, an action gets executed as long as an IAM policy allows it. But a KMS customer managed key carries another absolute gate entirely — a “key policy” tied to that specific key itself. No matter how explicitly an IAM policy allows kms:Decrypt, decryption is completely impossible unless the key policy itself also allows that action (or declares a delegation of the decision to IAM).

graph TB
    IAMUser["IAM user"] -->|"IAM policy allowing kms:Decrypt"| Request["Decryption request"]
    Request --> KeyPolicy{"Does the key policy delegate<br/>the decision to this<br/>account's IAM?"}
    KeyPolicy -->|"Yes (default key policy)"| Allowed["The IAM policy's allow takes effect"]
    KeyPolicy -->|"No (no delegation statement)"| Denied["AccessDenied, even if<br/>the IAM policy allows it"]

Deep Dive Into the Fundamentals

The Default Key Policy Includes “Delegation to the Root Account”

When you create a new customer managed key, its default key policy automatically includes a statement granting full access to that AWS account’s root account (arn:aws:iam::<account-id>:root). It’s exactly this one statement that lets an IAM policy within that same account effectively handle the allow/deny decision for this key at all. If this delegation statement to the root account ever gets removed from the key policy, no matter how much access the IAM policy grants, it never has any effect at all.

Envelope Encryption: What KMS Directly Encrypts Is Only a Small “Data Key”

KMS never directly encrypts an entire S3 object or an RDS database itself. In reality, it only generates and protects a “data key” — a small symmetric key. The actual data body gets encrypted locally, using that data key, by each AWS service (or the client side), and the encrypted data key itself gets stored alongside the encrypted data. To decrypt the data, you need permission (kms:Decrypt) to send the encrypted data key to KMS and have it decrypted.

KMS Grants: Dynamically Delegating Permission Without Editing the JSON Key Policy

KMS Grants are a separate mechanism for dynamic, fine-grained permission delegation, without ever editing the JSON-format key policy itself. Internal AWS services like EBS use this Grants mechanism internally, to obtain the encryption/decryption permission they need, without a user ever having to edit the key policy directly.

What a Pro Sees Here (Top 1% Understanding)

The Assumption “the IAM Policy Is the Final Decision-Maker” Doesn’t Hold for KMS

Experience with most other AWS services tends to leave you with the premise “if the IAM policy allows it, the action executes” — but a KMS customer managed key has another independent layer (the key policy) where this premise simply doesn’t hold. The habit of digging one layer deeper, per service, to check “does this particular service’s permission decision really complete with the IAM policy alone” is the perspective a top-1% engineer brings to handling an unexplained AccessDenied, despite an IAM policy allowing it.

Common Misconceptions and Pitfalls

Troubleshooting Perspective

  1. An IAM policy allows kms:Decrypt, but you still get AccessDenied: Check whether that key’s key policy includes delegation to the root account, or directly allows the relevant principal.
  2. You can’t decrypt encrypted data: Check whether you have kms:Decrypt permission on the specific data key itself (access permission on the data alone is never enough).
  3. Changing the key policy frequently is making operations cumbersome: Consider switching to dynamic permission delegation via KMS Grants.

Summary

Takeaways to Apply Today

  1. When you hit a KMS-related AccessDenied, always check the key policy, not just the IAM policy.
  2. When adopting a new AWS service, dig one layer deeper and check whether its permission decision really completes with an IAM policy alone.

References

Comments

Feel free to leave thoughts, questions, or corrections below (sign in with a GitHub account to comment or react).