Protecting Objects with S3 Versioning and MFA Delete
This lesson explains how S3 Versioning keeps every version of an object and how MFA Delete protects those versions from permanent deletion, guarding against accidental overwrites and deletions.
Learning outcomes
After completing this lesson, you will be able to:
- Describe how versioning and delete markers work.
- Describe how lifecycle rules manage noncurrent versions.
- Recover objects overwritten by ransomware.
How versioning works
Without versioning, an overwritten or deleted S3 object is gone, whether the change was an accident, a faulty application or ransomware. S3 Versioning keeps every version of every object, so earlier versions can be restored. MFA Delete adds a second factor to the operations that could remove that protection, making it harder for someone with stolen credentials to destroy the history. The following list describes both features.
- Every version is kept: overwrites create new versions and a simple delete adds a delete marker, so earlier versions remain recoverable.
- Versioning can be suspended but not turned off once enabled.
- MFA Delete, configured by the root user, requires MFA to delete versions permanently or to suspend versioning.
Versioning and MFA Delete
Managing versions
With versioning, every overwrite and delete keeps the previous version, so storage grows over time, and lifecycle rules manage it. Noncurrent version expiration permanently deletes old versions a set number of days after they were replaced, keeping a recovery window without keeping everything for ever. Noncurrent version transition moves old versions to cheaper storage classes, such as Glacier, while they are kept. Expired object delete marker removal cleans up delete markers that no longer have any versions behind them, which would otherwise accumulate and slow down listing. The following table summarises the actions.
| Lifecycle action | Effect |
|---|---|
| Noncurrent version expiration | Deletes old versions after a period |
| Noncurrent version transition | Moves old versions to cheaper storage classes |
| Expired delete marker removal | Cleans up delete markers with no remaining versions |
Lifecycle rules for versions
Versioning in security designs
Versioning is a prerequisite for S3 replication and Object Lock, and it lets a team recover objects overwritten by ransomware or a faulty process. It does not stop a user with s3:DeleteObjectVersion from removing versions; Object Lock or MFA Delete is needed for that.
The following diagram shows one object's versions in a versioned bucket and how it is restored after ransomware overwrites it.

What versioning does not stop
Recovering from ransomware that overwrote objects
Compromised credentials were used to overwrite thousands of objects in a versioned bucket with encrypted copies. Because versioning keeps the previous versions, each object can be restored by copying its last good version back:
aws s3api list-object-versions --bucket acme-docs --prefix contracts/ \
--query 'Versions[?LastModified<`2026-10-10T02:00:00Z`].[Key,VersionId]' --output text
# For each key and version found:
aws s3api copy-object --bucket acme-docs --key contracts/c-1001.pdf \
--copy-source "acme-docs/contracts/c-1001.pdf?versionId=VERSION_ID"At scale, S3 Batch Operations performs the copies from a manifest. Afterwards, MFA Delete is enabled by the root user so that versions cannot be permanently deleted without MFA, and Object Lock is considered for the most important prefixes.
What does a simple delete do in a versioned bucket?
Show answer
It adds a delete marker; earlier versions remain and can be restored.
Exam Tips
Remember for the exam
- To recover from an accidental overwrite or deletion, use versioning.
- A simple delete in a versioned bucket only adds a delete marker.
- MFA Delete requires the root user's MFA to delete versions permanently.
- Versioning is required for replication and Object Lock.
- Expire noncurrent versions with lifecycle rules.