AWS S3 Client-Side Encryption using KMS

AWS S3 client-side encryption is a very important factor to consider when saving data which contains Personal Information (PI). In this post, I will highlight why you should encrypt data on the client-side rather than relying completely on the SSE encryption. I have also kept an example how to encrypt data on the client-side using the AWS KMS (CMK) in Golang

Why encrypt on the client-side?

There are many advantages of encrypting on the client-side. 

  1. Accidentally making objects public: If the bucket or object is made public by mistake no one can decrypt it. Anyone who wants to decrypt needs to have the right permission to the AWS KMS key. You are applying defence in depth. 
  2. Stricter access policy: Even if a user or role has full access to S3 they still need the authorization of AWS KMS to decrypt the object. If they download it, the file will be of no value. 

What is the difference between client-side encryption and encryption at rest in AWS?

With client-side encryption, the data is encrypted on the client’s side before sending it to AWS. This means only the person who has access to the master key can decrypt the data. This adds another layer of encryption to the file. If the S3 object is exposed to the public, the files will be of no value since the user doesn’t have access to the key.

Encryption at rest means that the data is encrypted on the disk which is being saved at AWS Data Centre.

How to encrypt in Go?

 

How to decrypt in Go?