AWS Builder Center
What If Hackers Delete Your Backups Too? Building Ransomware-Resistant Storage with AWS

What If Hackers Delete Your Backups Too? Building Ransomware-Resistant Storage with AWS

A backup is useful only if you can still access it when something goes wrong. Explore how Amazon S3 Object Lock, versioning, retention modes, and legal holds can help protect important data against accidental deletion and ransomware-related threats.

Computer Engineering Student | AWS | AI Agents | Cloud Computing | Cybersecurity
Imagine you're managing a college application that stores thousands of student assignment files.
One day, a security incident occurs. An attacker gains access to the storage system and attempts to delete or modify important files.
You have backups. But what if those backups are deleted too?
This is an important question in cloud security.
Creating backups is not always enough. We also need to think about protecting those backups from unwanted changes and deletion.
AWS provides a useful feature for this: Amazon S3 Object Lock.
Let's understand how it works and build a small example.

🔐 What Is Amazon S3 Object Lock?

Amazon S3 Object Lock helps protect objects from being deleted or overwritten for a specified period.
It uses a storage model called WORM (Write Once, Read Many).
In simple words, once an object version is protected, it cannot be deleted or overwritten during its retention period, subject to the selected retention mode.
This is especially useful for:
  • Important application backups.
  • Financial records.
  • Student documents.
  • Audit logs.
  • Sensitive business information.
Object Lock works with S3 Versioning, which allows Amazon S3 to maintain multiple versions of an object.

🏗️ What Are We Going to Build?

Let's imagine a college assignment submission system.
Students upload their assignments, and the application stores them in an S3 bucket.
We want to protect these uploaded files so that they cannot be easily deleted during a defined retention period.
Our basic architecture:
User → Application → Amazon S3 Bucket → S3 Versioning + Object Lock → Protected Object Versions
We'll explore:
  1. Creating an S3 bucket.
  1. Enabling Object Lock.
  1. Understanding retention modes.
  1. Uploading a test file.
  1. Inspecting the object's protection settings.

📦 Step 1: Create an S3 Bucket

Open the AWS Management Console.
  1. Search for Amazon S3.
  1. Select Create bucket.
  1. Enter a globally unique bucket name.
  1. Choose your preferred AWS Region.
  1. Keep Block Public Access enabled.
  1. In the advanced settings, enable Object Lock if creating a new bucket.
  1. Acknowledge the Object Lock configuration.
  1. Create the bucket.
Important: Object Lock works only with versioned buckets. Enabling Object Lock automatically enables versioning.
You can also enable Object Lock on an existing general-purpose S3 bucket.

🔒 Step 2: Configure Object Lock Retention

After creating the bucket:
  1. Open your S3 bucket.
  1. Select the Properties tab.
  1. Find the Object Lock section.
  1. Open the retention settings.
  1. Enable default retention.
  1. Select Governance mode.
  1. Choose a short test retention period, such as 7 days.
  1. Save the changes.
Now, newly uploaded objects without their own retention settings will receive the configured default retention.
Why choose Governance mode for this beginner experiment?
It provides protection while allowing specifically authorized users with the required permissions to bypass governance retention when necessary.
Important: Enabling Object Lock is a significant configuration decision. You cannot disable Object Lock or suspend versioning after enabling it on a bucket. Choose your test bucket carefully.

⚖️ Step 3: Understand the Two Retention Modes

S3 Object Lock provides two main retention modes.

1. Governance Mode

In Governance mode, protected object versions cannot normally be deleted or overwritten.
However, users with the required special permissions can bypass the protection.
This makes Governance mode useful when an organization wants strong protection while retaining controlled administrative flexibility.

2. Compliance Mode

Compliance mode provides stronger protection.
During the retention period, a protected object version cannot be overwritten or deleted by any user, including the AWS account root user.
Its retention period cannot be shortened or its mode changed during that period.
This is useful when strict data retention requirements apply.
Here's a simple comparison:
Feature
Governance
Compliance
Protects object versions
Yes
Yes
Authorized bypass possible
Yes
No
Retention can be shortened
With special permissions
No
Protection level
Flexible
Strict
For a beginner experiment, Governance mode is a sensible starting point. Compliance mode should only be used after carefully understanding the retention requirements.

📤 Step 4: Upload a Test File

Now let's test our configuration.
  1. Open your S3 bucket.
  1. Select Upload.
  1. Choose a small sample file.
  1. Upload it.
  1. Open the uploaded object's details.
  1. Find the Object Lock retention information.
You should be able to inspect the retention mode and the date until which the object version is protected.
This helps you understand how S3 applies retention settings to uploaded objects.

🧠 Step 5: What Happens If Someone Tries to Delete the File?

Let's return to our original problem.
Suppose an attacker gains access to an application that stores important documents.
Without additional protection, compromised permissions could potentially allow unwanted deletion or modification of stored data.
With Object Lock enabled:
  • Protected object versions remain locked during their retention period.
  • Governance mode requires special permissions to bypass protection.
  • Compliance mode prevents deletion or overwriting of protected versions during retention.
  • Legal holds can provide protection without a predefined expiration date.
One important detail: Object Lock protects specific object versions. It does not prevent someone from creating a new version or adding a delete marker that can make an object appear deleted in normal bucket listings.
That's why Object Lock should be combined with appropriate access controls and backup security practices.

📚 Step 6: What Is an S3 Legal Hold?

Besides retention periods, S3 Object Lock also supports legal holds.
A legal hold protects an individual object version without requiring a fixed expiration date.
For example, imagine a company is investigating a security incident and must preserve certain records until the investigation is complete.
A legal hold can keep those object versions protected until an authorized user explicitly removes the hold.
Unlike a retention period, a legal hold does not automatically expire after a specified number of days.

🛡️ A Few Important Security Best Practices

Object Lock is useful, but it should not be your only security measure.
Here are some additional practices:
  1. Use least privilege: Give users and applications only the S3 permissions they actually need.
  1. Separate backup access: Keep backup administration separate from everyday application access.
  1. Enable versioning: Maintain multiple object versions to help recover from unwanted changes.
  1. Monitor access: Review relevant activity and security logs.
  1. Choose retention carefully: Avoid unnecessarily long retention periods that increase storage costs.
  1. Test recovery: Regularly verify that protected data can actually be recovered.
Remember, Object Lock is one layer of a broader backup and recovery strategy, not a complete solution to every ransomware attack.

🎓 A Real Student Project Scenario

Imagine you're developing a college assignment submission portal.
Your application uses:
  • Amazon S3 to store uploaded assignments.
  • AWS Lambda to process uploaded files.
  • DynamoDB to store submission details.
  • Amazon S3 Object Lock to protect selected document versions.
  • Amazon CloudWatch to monitor application activity.
If someone accidentally deletes an important assignment or attempts to remove a protected backup, Object Lock can help preserve the protected object version.
This is a simple example of how cloud storage and cybersecurity work together.

💡 Your Mini Challenge

Try this small experiment in a separate test bucket:
  1. Enable S3 Versioning and Object Lock.
  1. Configure a short Governance retention period.
  1. Upload a sample text file.
  1. Open the object's properties.
  1. Inspect its retention settings.
  1. Upload another version using the same object key.
  1. Compare the object versions and their retention information.
Observe how S3 protects individual versions rather than treating the file as just one permanent object.
Remember to review AWS pricing before experimenting and clean up any resources that are no longer needed. Object Lock settings cannot simply be disabled afterward.

🌱 Final Thoughts

Backups are important, but protecting backups is equally important.
Amazon S3 Object Lock introduces an additional layer of security by helping prevent important object versions from being deleted or overwritten during a defined retention period.
As developers, we should think beyond simply storing data.
We should also think about what happens when something goes wrong.
Build securely. Protect your data. Plan for recovery. ☁️🔐
Let's discuss!
If you were building a cloud-based application, which would you prioritize first: backup protection, access control, or recovery testing?
I'd love to hear your thoughts!
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article