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 an attacker to register the bucket and take over the subdomain. The hijacked subdomain also exposed an internal API vulnerable to SSRF, which let the attacker retrieve AWS credentials and gain full EC2 access.
Free Link 🎈
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 the root cause was a dangling CNAME record pointing to a deleted S3 bucket, combined with an exposed internal API that allowed SSRF to the cloud metadata service.
Impact
The attacker could take over the subdomain and, by chaining SSRF to cloud metadata, obtain temporary AWS credentials and gain full EC2 access, potentially leading to remote code execution.
What the attacker needed
Dangling CNAME record; S3 bucket does not exist; internal API exposed
The fix
The report does not state that the issue was fixed; it should be fixed by removing dangling CNAME records, cleaning up unused subdomains, and restricting internal API access.
How it was found
- Enumerate subdomains and find a staging subdomain returning 404.
- Check the DNS CNAME record and discover it points to an S3 bucket.
- Verify the S3 bucket does not exist.
- Register the S3 bucket under the attacker's AWS account and host a proof-of-concept page.
- Access the subdomain to confirm the takeover.
- Send a request to the subdomain's API to fetch the AWS metadata endpoint and retrieve credentials.
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 part of a website's address, like blog.example.com. A CNAME is a DNS record that points one domain name to another. If the target of that CNAME no longer exists, an attacker can claim it and control the subdomain. Here, the attacker also found a way to make the server fetch internal addresses, which led to stealing 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.