S3 Object Locking: Modes, Setup and Ransomware Protection

Quick answer: S3 object locking is an Amazon S3 feature that keeps object versions in a write once, read many (WORM) state, so nobody can overwrite or permanently delete them until a retention date passes or a hold is lifted. You pick governance mode, where specially authorized users can override the lock, or compliance mode, where nobody can, not even the AWS root user. Once a bucket has it, the feature cannot be switched off. That permanence is why S3 object locking is the standard way to give cloud backups a recovery window ransomware cannot erase.

Key points

  • Locks attach to object versions, so a ransomware DELETE only adds a delete marker.
  • Since 2027, AWS supports event holds, which start the retention clock at a business event instead of a fixed date.
  • Enabling the feature on an existing bucket protects new uploads only; older objects need S3 Batch Operations.
  • Object Lock guards objects, not encryption keys. Deleting the KMS key behind locked data can still make it unreadable.
  • NetApp ONTAP supports it from version 9.14.1 on new buckets only, and Garage does not support it yet.

What does S3 object lock mean?

S3 object lock means Amazon S3 stores a specific object version in a WORM state and refuses any request that would overwrite or permanently remove it while the lock is active. The lock lives in that version’s metadata, and S3 itself enforces it.

A retention period protects a version until its retain until date; a legal hold protects it until someone removes it. A bucket default retention period applies automatically to each new version.

Because locks work per version, the bucket must be versioned. Uploading the same key creates a newer version; the older one keeps its lock.

How does S3 object locking stop ransomware?

S3 object locking stops ransomware by making your recovery copy impossible to destroy with ordinary credentials. Even attackers holding a stolen key with full S3 rights cannot permanently delete or overwrite a locked version early, so you can roll back to clean data.

Trace what an attacker tries. A plain DELETE only places a delete marker on top. A DELETE naming the version ID gets a 403 Access Denied. Uploading an encrypted copy creates a new version beside the protected one, and lifecycle expiration rules cannot remove locked versions.

What most articles miss is what object lock does not cover. Delete markers themselves are not WORM protected. Governance mode can be bypassed. And AWS warns that if objects use an AWS KMS key and that key gets deleted, locked data can become unreadable, so restrict key deletion as tightly as the bucket.

Locks also do nothing about data theft. That is why immutable storage is one layer of a wider ransomware protection plan and works best as the offsite copy in the 3 2 1 backup rule.

S3 object lock governance mode vs compliance mode

Governance mode blocks deletes and overwrites for most users but lets anyone with the s3:BypassGovernanceRetention permission override the lock. Compliance mode blocks everyone, including the root user, and its retention can be extended but never shortened.

FeatureGovernance modeCompliance modeLegal hold
Who can delete earlyUsers with the bypass permission and headerNobody; only closing the AWS accountNobody while it is on
Can protection shrinkYes, with the bypass permissionNo, only extendRemovable with s3:PutObjectLegalHold
Protection endsRetain until dateRetain until dateWhen removed
Best fitTesting, internal policyRegulated records, backupsAudits, litigation

In practice, governance mode is weaker against ransomware than teams assume. Overriding it needs the permission plus a bypass header, and the S3 console adds that header automatically. An attacker controlling an administrator with the permission can wipe governance protected backups in a few clicks, so deny it to everyone except a break glass role.

What are S3 object lock event holds?

Event holds are the variable retention option AWS announced on 2027. You place an event hold plus a duration on an object; S3 protects it while the hold stays on, then for the chosen duration after you release it.

This suits records whose clock starts later, such as files kept five years after an acquisition closes. While the hold is on, the retain until date equals now plus the duration, rolling forward as time passes. Releasing the hold freezes it, and shortening the duration never pulls it earlier.

Event holds work as a bucket default, scale through S3 Batch Operations and reached AWS GovCloud (US) in October 2027. For ransomware defense, the key benefit is separation: a compromised account that releases a hold still has to wait out the full duration before anything can be deleted.

S3 object lock tutorial: turning it on in AWS

You can enable S3 object locking on a new general purpose bucket or an existing one. S3 turns on versioning, you choose a default mode and period, and every new version inherits that lock unless its upload sets its own.

  1. Create the bucket with Object Lock on. In the console, open Advanced settings and choose Enable under Object Lock. Through the API, call CreateBucket with ObjectLockEnabledForBucket set to true.
  2. Set default retention with PutObjectLockConfiguration:

json

{
  "ObjectLockEnabled": "Enabled",
  "Rule": {
    "DefaultRetention": { "Mode": "GOVERNANCE", "Days": 30 }
  }
}
  1. Override per object with PutObjectRetention or upload settings. Uploads that set retention need a Content MD5 or SDK checksum header, or S3 rejects them; custom scripts often miss this.
  2. Verify with GetObjectRetention and GetObjectLegalHold.

Can you enable S3 object lock on an existing bucket?

Yes. Edit the Object Lock section on the bucket’s Properties tab, or call PutObjectLockConfiguration. Versioning must already be on, and the console asks you to confirm the change is permanent.

Most people discover the catch afterward: default retention covers only versions written from then on. Existing objects stay unlocked until you lock them with S3 Batch Operations, typically using an S3 Inventory report as the manifest.

S3 object lock Terraform example

With the Terraform AWS provider, enable it on the bucket and define the rule separately:

hcl

resource "aws_s3_bucket" "backups" {
  bucket              = "examplebackupvault"
  object_lock_enabled = true
}

resource "aws_s3_bucket_object_lock_configuration" "backups" {
  bucket = aws_s3_bucket.backups.id
  rule {
    default_retention {
      mode = "COMPLIANCE"
      days = 30
    }
  }
}

Event hold support was requested in provider GitHub issue 49909 in September 2027, so check the changelog before coding event holds.

Can you disable S3 object locking?

No. After Object Lock is enabled on a bucket, you cannot disable it or suspend versioning, and existing locks stay in force until they expire. AWS states the only way to remove a compliance mode version early is deleting the entire AWS account.

You can still turn off default retention for new uploads, shorten governance locks with the bypass permission, and lift legal holds. Compliance locks must run out. Need an unrestricted bucket? Create a new one and copy data whose locks have expired.

S3 object lock pricing: what you actually pay

S3 object lock carries no separate fee on AWS, and event holds launched at no additional charge. You pay normal S3 rates for the storage every locked version occupies, plus request charges for retention API calls.

Versions drive the bill. Each is a full copy, so a job rewriting 2 TB nightly under 30 days of retention keeps about 60 TB locked at any moment. Compliance mode turns sizing mistakes into fixed bills: lock 50 TB for seven years by accident and you pay for seven years. Tie durations to your RPO and RTO targets, then add a lifecycle rule that expires noncurrent versions once their locks lapse.

Object locking beyond AWS: NetApp ONTAP, Garage and other S3 storage

Object lock is part of the S3 API, but support varies. NetApp ONTAP and Wasabi support it with conditions, while the open source Garage project does not support it yet.

PlatformSupportKey condition
Amazon S3Yes, with event holdsNew and existing general purpose buckets
NetApp ONTAP S3Yes, from 9.14.1Enable at bucket creation; SnapLock license, included in ONTAP One
WasabiYesNo additional charge
Garage (Deuxfleurs)NoNo object versioning yet; feature request still open

On ONTAP, NAS volumes shared over S3 should use SnapLock instead. Garage returns 501 Not Implemented for unsupported calls, so test your backup tool on the exact platform. For background on buckets and objects, see our guide to the benefits of object storage.

Frequently asked questions

Is S3 object lock the same as S3 Versioning?

No. Versioning keeps older copies, but anyone with delete rights can still remove them permanently. Object Lock blocks that until the lock ends.

What is WORM storage?

WORM means write once, read many. Data is written once and read freely, but cannot be changed or erased during retention.

What is the longest retention period S3 allows?

AWS documents a maximum of 100 years. You can also enforce your own minimum and maximum in a bucket policy, which stops a typo from locking data for decades.

Does object lock still work in S3 Glacier storage classes?

Yes. Protection stays in force in every storage class and through S3 Lifecycle transitions, so you can move locked backups to cheaper archive tiers without losing immutability.

Does S3 Replication copy object lock settings?

Yes. Replication copies retention metadata, including event hold settings, and both buckets need Object Lock enabled.

How can I check whether an object is locked?

HeadObject or GetObject returns a version’s retention mode, retain until date and legal hold status. S3 Inventory lists lock metadata across a bucket, though reports can take up to 48 hours.

What happens when a retention period ends?

The version becomes ordinary again, so authorized users or lifecycle rules can delete it. A legal hold on the same version keeps it protected until someone removes the hold.

Does S3 object lock meet SEC record keeping rules?

Cohasset Associates assessed S3 Object Lock for SEC Rule 17a-4(f), FINRA Rule 4511 and CFTC Regulation 1.31, with a 2027 update. Your firm still must configure compliance mode and its processes correctly.

Do backup tools support S3 object lock?

Yes. AWS lists Veeam, Commvault, Rubrik, Cohesity and Veritas among partners using it for immutable backups. Check each vendor’s documentation for supported modes and versions.

Can I use object lock on S3 directory buckets?

AWS documents Object Lock setup for general purpose buckets, and the checksum header it relies on is unsupported for directory buckets. Plan immutable backups on general purpose buckets.

How long should backup retention be for ransomware protection?

Cover how long an intrusion could go unnoticed plus restore time. An AWS Storage Blog walkthrough uses a 30 day default as a ransomware recovery window.

Does object lock protect against stolen data?

No. It prevents deletion and overwriting, not reading. Pair locks with least privilege IAM policies, encryption and monitoring through AWS CloudTrail.

Conclusion

Enable object locking on your backup bucket, prove restores in governance mode, then move new writes to compliance mode. The Amazon S3 Object Lock documentation covers every permission, the AWS event holds announcement explains the newest option, and the Cohasset Associates assessment maps S3 to SEC, FINRA and CFTC rules.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *