Dangling Route 53 Record to a Deleted S3 Website Bucket: Contain the Subdomain Takeover
Overview
A Route 53 record that still points at a deleted S3 website bucket lets another AWS account claim the bucket name and serve your hostname. Save the record, check the name with head-bucket and list-buckets, delete the record first, then hold a free name with an empty bucket; a claimed name is a security incident.
Diagnose
Symptom
What responders observe.
It usually starts with a clean-up.
A static site is retired, its bucket is emptied and deleted, and nobody removes the CNAME or alias record that sent visitors to it.
The record keeps resolving long after the bucket has gone.
You are likely to meet it in one of these ways: Browsing http://shop.example.com returns an S3 website 404 Not Found page.
The hostname serves pages your team never published, which means someone has already claimed the name.
An attack surface scan flags a record whose value is an s3-website endpoint with no matching bucket in your accounts.
A 404 on its own proves little.
S3 returns the same code for a missing object, a missing index document, a bucket without website hosting and a bucket that does not exist.
The checks further down settle which one you have.
Detection
Metrics, logs and confirmation commands.
Root cause
Why the incident occurred.
Contain and prevent
Blast radius
What else this can affect.
Prevention
Controls and guardrails that stop it recurring.
-
The lasting fix is the order of retirement.
-
Remove or repoint DNS first, confirm it with get-change, and only then retire the bucket.
-
Better still, empty the bucket and keep it, blocking requests as needed, because a deleted name can be recreated by another account.
-
Audit every hosted zone for records whose values contain s3-website, and run head-bucket with your expected owner against each name.
-
Create buckets that do not need to match a hostname in your account regional namespace, where only your account can ever create the name.
-
Review the zone's other records in the same pass.
-
A CAA record missing the renewal CA is another fault that only an audit tends to catch.
-
File the CloudTrail timeline and the saved record set with the incident report.
Fix
Pre-flight checks
Check these before you change anything.
AWS CLI v2 with read access to the hosted zone and permission to change its records.
An identity with s3:ListBucket and s3:ListAllMyBuckets in the account that owned the site.
CloudTrail read access in the bucket's former Region.
An incident lead who approves changes to the hosted zone.
Commands
aws route53 list-resource-record-sets --hosted-zone-id <zone-id> --query "ResourceRecordSets[?Name == '<hostname>.']" > record-before.json
aws route53 test-dns-answer --hosted-zone-id <zone-id> --record-name <hostname> --record-type CNAME
aws s3api head-bucket --bucket <hostname> --expected-bucket-owner <account-id>
aws s3api list-buckets --query "Buckets[?Name == '<hostname>']"
aws cloudtrail lookup-events --lookup-attributes AttributeKey=EventName,AttributeValue=DeleteBucket --region <bucket-region>
aws route53 change-resource-record-sets --hosted-zone-id <zone-id> --change-batch file://delete-record.json
aws route53 get-change --id <change-id>
aws s3api create-bucket --bucket <hostname> --region <bucket-region> --create-bucket-configuration LocationConstraint=<bucket-region>
Verify and recover
Verification
Evidence required before you close the incident.
Run aws route53 get-change --id <change-id>. — Status INSYNC. — The deletion has reached every Route 53 name server for the zone.
Run aws route53 test-dns-answer for the hostname. — RecordData without the s3-website endpoint, or with the replacement target. — Route 53 no longer answers with the S3 website endpoint.
Run aws s3api head-bucket --bucket <hostname> --expected-bucket-owner <account-id> if a holding bucket was created. — BucketRegion in the output. — The bucket name is held by your account.
Rollback
The safe way back.
Recreate the record by submitting the saved change batch with Action CREATE, only once head-bucket with your account as expected owner returns 200.
Restore the website by rebuilding website hosting in the holding bucket, or serve it through CloudFront for HTTPS.
Keep the holding bucket
delete it only after the record is gone and the owner accepts that the name becomes claimable.
Escalate when
Conditions that need another owner.
-
Most cases end with the record removed and the name held.
-
Escalate to the security team at once when any of these apply: head-bucket returns 403 and the bucket is in none of your accounts, so another account holds the name.
-
Treat anything it served as hostile and keep the record out of the zone.
-
CloudTrail shows a DeleteBucket call from a principal nobody recognises.
-
The hostname appears in sign-in redirect lists, email links or partner allow-lists, which all trust the name.
-
Escalate to the zone owner when a record protection blocks the change, rather than removing the protection yourself.
-
Zone owner Security team.
Fixed? Get the next one before it hits you: The KBY Brief
Practical fixes for the systems you run, by email about twice a week. Unsubscribe at any time.
About this page
Credited to
Dates
Published
Corrections
No corrections are listed for this page. Some review sweeps corrected pages without naming each one; those are in the corrections log.
Was this useful?
Reports go to the site owner and are used to correct pages. Corrections are listed at /corrections.
Found this useful? Follow KBY for more like it.
Sources
Based on the vendor sources listed below. Check each step against your environment before acting.
First published 28 November 2026
General purpose bucket naming rules
Cited for: Supports the documented platform behaviour, diagnosis or recovery controls used by this Runbook.
Deleting a general purpose bucket
Cited for: Supports the documented platform behaviour, diagnosis or recovery controls used by this Runbook.
Routing traffic to a website that is hosted in an Amazon S3 bucket
Cited for: Supports the documented platform behaviour, diagnosis or recovery controls used by this Runbook.
Website endpoints
Cited for: Supports the documented platform behaviour, diagnosis or recovery controls used by this Runbook.
Configuring a custom error document
Cited for: Supports the documented platform behaviour, diagnosis or recovery controls used by this Runbook.
aws s3api head-bucket
Cited for: Supports the documented platform behaviour, diagnosis or recovery controls used by this Runbook.
aws s3api list-buckets
Cited for: Supports the documented platform behaviour, diagnosis or recovery controls used by this Runbook.
aws s3api create-bucket
Cited for: Supports the documented platform behaviour, diagnosis or recovery controls used by this Runbook.
aws route53 list-resource-record-sets
Cited for: Supports the documented platform behaviour, diagnosis or recovery controls used by this Runbook.
aws route53 change-resource-record-sets
Cited for: Supports the documented platform behaviour, diagnosis or recovery controls used by this Runbook.
aws route53 get-change
Cited for: Supports the documented platform behaviour, diagnosis or recovery controls used by this Runbook.
aws route53 test-dns-answer
Cited for: Supports the documented platform behaviour, diagnosis or recovery controls used by this Runbook.
aws cloudtrail lookup-events
Cited for: Supports the documented platform behaviour, diagnosis or recovery controls used by this Runbook.
Amazon S3 CloudTrail events
Cited for: Supports the documented platform behaviour, diagnosis or recovery controls used by this Runbook.
Tutorial: Configuring a static website using a custom domain registered with Route 53
Cited for: Supports the documented platform behaviour, diagnosis or recovery controls used by this Runbook.
RFC 1035: Domain Names - Implementation and Specification
Cited for: Supports the documented platform behaviour, diagnosis or recovery controls used by this Runbook.
Recommended reading
More from KBY that goes with this runbook.
Small business ITPhishing in a small team: what to teach staff, and what to do when someone clicks
7 min read

