404 to Root : How a Forgotten Subdomain Led to Server Takeover ๐ดโโ ๏ธ
A forgotten subdomain had a dangling CNAME pointing to a deleted S3 bucket, allowing the attacker to register the bucket and take over the subdomain. The attacker then found an internal API on that subdomain that was vulnerable to SSRF, used it to read AWS instance metadata and steal temporary IAM credentials, and finally obtained a root shell on an EC2 instance.
This is the story of how a tiny 404 page turned into a full-blown server takeover. A tale of recon, forgotten subdomains, DNS negligence, and one overly caffeinated bug bounty hunter (me).
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely a dangling DNS CNAME record pointing to a deleted cloud storage bucket, combined with an internal API exposed on the same host that allowed server-side requests to arbitrary URLs.
Impact
An attacker could take over a company subdomain, reach internal services, steal cloud credentials, and gain full control of an EC2 server.
What the attacker needed
Dangling CNAME to a deleted S3 bucket; attacker can register the same bucket name; internal API reachable on the subdomain
The fix
The text does not state that the issue was fixed; it should be fixed by removing stale DNS records, deleting unused subdomains, not exposing internal APIs publicly, and applying least privilege to IAM roles.
How it was found
- Enumerate subdomains and filter for live hosts, finding a staging subdomain returning 404.
- Query the DNS CNAME record and see it points to an S3 website bucket.
- Check whether the bucket exists and confirm it is gone.
- Register the same bucket name under the attacker's AWS account and upload a proof-of-concept page.
- Send a request to an internal API endpoint on the hijacked subdomain asking it to fetch the AWS metadata URL.
- Use the stolen temporary credentials to start a session on an EC2 instance.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
A subdomain is a prefix like 'old-staging' added to a company's main domain. The company had pointed that subdomain at an Amazon S3 storage bucket but later deleted the bucket without removing the DNS record. Because anyone can create a bucket with the same name, the attacker claimed it and served their own page on the company's subdomain. They then used a feature on that subdomain that fetched URLs to reach Amazon's internal metadata service and steal cloud credentials.
What is Subdomain takeover?
A company's DNS still points at a cloud service it no longer uses, so anyone can claim it and serve content on the company's domain.