Confirm an S3 subdomain takeover by matching the bucket name to the CNAME before claiming it
When a subdomain's CNAME points at <name>.s3.amazonaws.com or <name>.s3-website-<region>.amazonaws.com, request it and look for the S3 error NoSuchBucket (the XML error body contains <Code>NoSuchBucket</Code> and <BucketName>).
dig +short CNAME assets.example-target.test
curl -si http://assets.example-target.test/ | head -n 20Why it works: S3 routes by bucket name, and bucket names are global. If the owner deleted the bucket but left the DNS record, anyone can create a bucket with that exact name. For the website endpoint, create it in the same region as the hostname, then enable static website hosting. The application's mistake is treating the DNS record's lifetime as independent of the resource it names.
Proof: upload a harmless poc.txt containing a unique string, then fetch http://assets.example-target.test/poc.txt and show it served from the target hostname. Impact grows if the host is trusted by a CSP script-src, CORS allowlist or cookie scope. False positives: AccessDenied or a 403 means the bucket still exists and is owned by someone, and a NoSuchKey means the bucket exists too. Only claim names for in-scope hosts, and remove your test file after.
Follow #cname, #dns, #s3 or #takeover for new tips like this one, on your notifications page and, if you choose, in a daily or weekly email.
Comments
No comments yet.