Featured
How To Protect Your AWS S3 Buckets From Ransomware
A recent article highlighted how files on an S3 bucket can be taken captive by a ransomware attack.
How The Attack Happens
A malicious actor will do the following to ransom your S3 objects.
- Find an AWS IAM keys that are exposed.
- They access your AWS accounts with the IAM keys.
- The discover which S3 buckets to which the IAM key has privileges.
- They use the SSE-C encryption method to encrypt the bucket.
- They mark the buckets for deletion in one week using lifecycle rules.
Even if you pay to have the objects decrypted, they might be automatically deleted before you even get a chance to decrypt them.
How To Protect Yourself
There are various ways to protect yourself from this type of attack.
Protect Your IAM Keys
- Do not commit them to your repos.
- Do not shared them in Slack or other messaging tools.
- Rotate the keys on a schedule.
- Delete them when you no longer need them.
- Enforce MFA with the associated IAM user.
Stop Using IAM Keys
- Use AWS STS to issue you a temporary IAM access keys that expire after one hour.
- AWS IAM Identity Center that provides temporary IAM access keys from its web-based portal.
- Use a Lambda function to perform the request. Assign the function to have the permissions to perform the desired changes. Securely invoke the function.
Use Least Privilege IAM Policies
- Write your policies to only have the necessary privileges to get the job done and nothing else.
- The IAM users should not have access to more resources than needed.
Replication and Backups
- Use AWS Backup to back up your S3 objects.
- Replicate your S3 objects to a bucket in another region.
- Replicate your S3 objects to another AWS account.
S3 Features
- Turn on object lock which prevents modifying S3 objects.
- Use lifecycle management that moves old objects to cold storage which takes a long time to retrieve. This could mess up the ransomware scripts.
- Use S3 versioning. Even if the object is deleted, any old version are still retained unless explicitly deleted.
Podcast Discussion
I discussed this topic on the LogiCast podcast.
Before you go
Did you know I wrote a book that will help you build a serverless application step-by-step?
As an Amazon Associate I earn from qualifying purchases.