# S3 bucket policy: require SSE-KMS encryption on uploads

IAM policy examples · Updated 17 November 2026

**Short answer:** S3 already encrypts every new object (SSE-S3 by default), so the old "deny unencrypted uploads" policy is mostly obsolete. To require KMS, set the bucket's default encryption to SSE-KMS with your key, then add Deny statements that reject a PutObject which explicitly asks for a different encryption type or key.

## The policy

```
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "DenyNonKmsEncryptionHeader",
      "Effect": "Deny",
      "Principal": "*",
      "Action": "s3:PutObject",
      "Resource": "arn:aws:s3:::my-bucket/*",
      "Condition": {
        "StringNotEquals": {
          "s3:x-amz-server-side-encryption": "aws:kms"
        },
        "Null": {
          "s3:x-amz-server-side-encryption": "false"
        }
      }
    },
    {
      "Sid": "DenyOtherKmsKeys",
      "Effect": "Deny",
      "Principal": "*",
      "Action": "s3:PutObject",
      "Resource": "arn:aws:s3:::my-bucket/*",
      "Condition": {
        "StringNotEqualsIfExists": {
          "s3:x-amz-server-side-encryption-aws-kms-key-id": "arn:aws:kms:eu-west-2:123456789012:key/1234abcd-12ab-34cd-56ef-1234567890ab"
        }
      }
    }
  ]
}
```

Pair it with default encryption on the bucket:

```
aws s3api put-bucket-encryption --bucket my-bucket \
  --server-side-encryption-configuration '{"Rules":[{"ApplyServerSideEncryptionByDefault":{"SSEAlgorithm":"aws:kms","KMSMasterKeyID":"arn:aws:kms:eu-west-2:123456789012:key/1234abcd-12ab-34cd-56ef-1234567890ab"},"BucketKeyEnabled":true}]}'
```

## What each statement does

**DenyNonKmsEncryptionHeader** has two conditions, and both must be true for the deny to apply: the `x-amz-server-side-encryption` header is present (`Null` is `false`) and its value is not `aws:kms`. An upload asking for `AES256` is refused; an upload with no header passes and gets the bucket default, which is your KMS key.

**DenyOtherKmsKeys** refuses uploads that name a different KMS key. `IfExists` means requests that don't specify a key aren't affected, again leaving the bucket default to apply.

The classic version on many blogs uses only `StringNotEquals` without the `Null` check. That denies every upload that omits the header, which breaks clients relying on default encryption, including some AWS services that write logs to buckets.

## Before you apply it

- Uploaders now need `kms:GenerateDataKey` on the key, and readers need `kms:Decrypt`. Grant them in IAM, or in the key policy for other accounts. See [KMS decrypt policy](https://cloudconsole.dev/iam/kms-decrypt).
- Turn on **S3 Bucket Keys** (as in the command above). It sharply reduces KMS request volume and therefore KMS request charges for busy buckets.
- Existing objects keep their old encryption. Re-encrypting them needs a copy-in-place or S3 Batch Operations job.
- Services that deliver logs to buckets (for example ALB access logs) support only certain encryption types. Check the service's docs before forcing KMS on a log bucket.

## Variations

- **Require any encryption header at all** (strict mode): drop the `Null` condition. Only do this when you control every client.
- **DSSE-KMS**: the header value is `aws:kms:dsse`. Adjust the first statement if you use dual-layer encryption.
- **Deny SSE-C** (customer-provided keys): add a deny on `s3:PutObject` with `"Null": {"s3:x-amz-server-side-encryption-customer-algorithm": "false"}`.

## Common mistakes

- **Using the key alias in the key-ID condition.** Clients may send the key ARN, key ID or alias, and the comparison is a literal string match. Standardise clients on the full key ARN, or rely on default encryption and don't send the header at all.
- **Locking out readers.** A bucket full of SSE-KMS objects is unreadable to anyone without `kms:Decrypt`; check the key policy before switching defaults.
- **Forgetting multipart uploads.** The encryption headers are evaluated on the request that starts the upload; the same deny covers it because that request is authorised as `s3:PutObject`.

## Questions

### Do I still need a policy to deny unencrypted uploads to S3?

Not for encryption at rest in general: since January 2023 S3 encrypts all new objects with SSE-S3 by default. A policy is still useful to force SSE-KMS with a specific key.

### Why are uploads without an encryption header being denied?

Your deny uses StringNotEquals on s3:x-amz-server-side-encryption without a Null check, so a missing header counts as not equal. Add the Null condition shown above.

## When this happens away from your desk

If a writer starts failing after an encryption change, the error is usually a KMS AccessDenied in the application logs. Reading those logs from a phone is often enough to know whether to roll the bucket policy back.

[About the CloudConsole app](https://cloudconsole.dev/aws-console-app) · [Download on the App Store](https://apps.apple.com/app/cloudconsole-for-aws/id6835419710)

## Sources

- [Using server-side encryption with AWS KMS keys (SSE-KMS)](https://docs.aws.amazon.com/AmazonS3/latest/userguide/UsingKMSEncryption.html)
- [Setting default server-side encryption behavior for Amazon S3 buckets](https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucket-encryption.html)

## Related

- [KMS key policy: a working example explained](https://cloudconsole.dev/iam/kms-key-policy)
- [IAM policy: kms:Decrypt on one key](https://cloudconsole.dev/iam/kms-decrypt)
- [S3 bucket policy: deny requests that are not over HTTPS](https://cloudconsole.dev/iam/s3-deny-http-requests)
- [S3 bucket policy vs IAM policy](https://cloudconsole.dev/iam/s3-bucket-policy-vs-iam-policy)
- [KMS AccessDeniedException when reading an encrypted S3 object or secret](https://cloudconsole.dev/errors/kms-access-denied)
- [ABAC: tag-based access control policy example](https://cloudconsole.dev/iam/abac-tags)

---

Source: https://cloudconsole.dev/iam/s3-enforce-kms-encryption

CloudConsole is an independent iPhone and Android app for Amazon Web Services by Cloudconcur Ltd. It is not affiliated with Amazon Web Services.
