Enforcing WORM Retention with S3 Object Lock
This lesson explains how S3 Object Lock stores objects in write-once-read-many (WORM) form, preventing deletion or overwriting for a retention period, for regulatory compliance and ransomware protection.
Learning outcomes
After completing this lesson, you will be able to:
- Distinguish governance mode, compliance mode and legal holds.
- Identify uses of Object Lock.
- Describe a ransomware-resistant backup design.
Retention modes
S3 Object Lock stores object versions in a write-once-read-many model, so they cannot be overwritten or deleted during a retention period. In governance mode, most users cannot delete a protected version or shorten its retention, but users with the s3:BypassGovernanceRetention permission can, which protects against accidents while leaving an administrative escape.
In compliance mode, nobody, not even the root user, can delete the version or shorten its retention until the period ends, which meets regulatory record-keeping rules and protects backups from ransomware. A legal hold has no expiry date: it prevents deletion until a user with s3:PutObjectLegalHold removes it, independently of any retention period, for example while litigation is pending. The following table summarises the protections.
| Mode | Who can delete or shorten retention |
|---|---|
| Governance | Users with the special s3:BypassGovernanceRetention permission |
| Compliance | Nobody, not even the root user, until the period ends |
| Legal hold | Anyone with s3:PutObjectLegalHold can remove it; it has no expiry date |
Object Lock requires versioning and protects individual object versions. A default retention period can be set on the bucket, and governance mode is useful for testing settings before committing to compliance mode.
The following diagram compares the two retention modes.

Uses
S3 Object Lock stores objects in a write-once-read-many (WORM) model, preventing them from being deleted or overwritten for a retention period or while a legal hold is in place. Its first use is regulatory: regulations such as SEC Rule 17a-4, FINRA and CFTC require certain records to be kept in immutable form, and Object Lock in compliance mode has been assessed against those requirements.
Its second use is protection: backups and logs locked with Object Lock cannot be destroyed by ransomware or a malicious insider, even one with administrative credentials, until their retention period ends.
Object Lock modes
Ransomware-resistant design
Backups in S3 can be protected against ransomware by combining several controls, so that no single compromised credential can destroy every copy.
- Enable versioning and Object Lock on the backup bucket, so objects cannot be overwritten or deleted during their retention period.
- Replicate the data to a bucket in a separate, tightly controlled account that production administrators cannot access.
- Back up with AWS Backup into a vault protected by AWS Backup Vault Lock.
An attacker who obtains credentials for the source account can then encrypt or delete the live data, but cannot destroy the locked copies or the copies in the separate account.
Ransomware-resistant backups
Protecting data from deletion and disaster
A company's critical documents must survive accidental deletion, ransomware and the loss of a Region, and must be kept unchanged for seven years for compliance.
| Risk | Feature |
|---|---|
| Accidental deletion or overwrite | Versioning |
| Malicious deletion, even by an administrator | Object Lock in compliance mode, 7-year retention |
| Regional disaster | Cross-Region Replication to a bucket in another Region |
| Replication must finish within 15 minutes | Replication Time Control |
| Old versions piling up | Lifecycle rules expiring noncurrent versions after the retention period |
Versioning must be enabled before replication or Object Lock can be used. Replication applies only to objects written after it is configured; existing objects need S3 Batch Replication.
Which Object Lock mode prevents even the root user from deleting an object before its retention ends?
Show answer
Compliance mode. In governance mode, users with a special permission can still remove the retention.
Exam Tips
Remember for the exam
- For regulatory WORM storage that even the root user cannot bypass, use Object Lock in compliance mode.
- To allow administrators to override retention in exceptional cases, use governance mode.
- To keep an object indefinitely during litigation, apply a legal hold.
- To protect backups against ransomware, combine Object Lock with replication to a separate account.