Subdomain takeover on partners.ubnt.com due to non-used CloudFront DNS entry
A DNS record for partners.ubnt.com pointed to CloudFront without an active distribution, allowing an attacker to claim the domain and serve arbitrary content. This could enable phishing, cookie theft, and SSL certificate issuance for the domain.
Originally disclosed on HackerOne
- Fixed in 34 days
- Paid in 34 days
- Disclosed after 5 months
Hi,
So lately I have discovered that CloudFront is not validating which user that connects a CNAME:d domain to a CloudFront Origin. This means that if I could find a domain that is still pointing to CloudFront, without being connected to any Origin as a Custom CNAME, I can actually claim the domain myself and point it to whatever I want. A vulnerable domain looks like this:

I noticed that this was indeed the result I got on partners.ubnt.com. This domain is currently still pointing to CloudFront, but there is no CF Origin with the domain set as a CNAME.
I have claimed the domain now for PoC using the following setup:

And I have placed a file located under /login for validation and to show what could be a possible variant of an attack:
http://partners.ubnt.com/login
PoC-image:

You should most likely just remove the DNS-entry for this domain, and also make sure you constantly remove DNS records pointing to CloudFront (and other services as well of course) when you stop using them.
As you might understand, the consequences of this are pretty bad. I now can serve whatever I like on this domain, even fetching httpOnly cookies. I would also be able to issue an SSL for this domain through AlphaSSL or Let's Encrypt (that only needs meta/file verification to issue the certificate) That would end up with the ability to read secure cookies as well.
Also, there's no way at all for a visitor of this page to validate that the content on this domain is not served by UBNT, making it extremely easy to utilize this for targeting the organization by fake login forms / spear phishing using your own domain to plant the attack.
We at Detectify have written about this before a few years ago, but we were now able to actually exploit this using CloudFront as well, something that was not known before.
Regards, Frans
Context
Ubiquiti runs a partner portal at partners.ubnt.com. The hostname was still published in DNS as a CNAME pointing at CloudFront, but no CloudFront distribution had that hostname configured as a Custom CNAME any more. That mismatch between DNS and the CDN configuration is the whole bug: CloudFront does not check who owns a hostname before letting an account attach it as a Custom CNAME, so whoever claims the dangling name first controls what the CDN serves for it.
The report describes this as a subdomain takeover, filed under privilege escalation, disclosed on 27 November 2016.
Setup
The researcher needed nothing on the target side: no account on partners.ubnt.com, no access to Ubiquiti infrastructure. The only requirement was a CloudFront account of his own, in which he could create a distribution and set a Custom CNAME. The precondition on the victim side is a DNS record that still resolves to CloudFront while no distribution claims that hostname.
Finding it
The starting observation is that CloudFront does not validate which user connects a CNAME'd domain to a CloudFront origin. If a domain still points to CloudFront but is not connected to any origin as a Custom CNAME, anyone can claim that domain and point it at whatever they want.
A vulnerable domain looks like this:

The image shows the state of a hostname that resolves to CloudFront without a distribution behind it. Checking partners.ubnt.com produced exactly that result: the domain was still pointing to CloudFront, but no CF origin had the domain set as a CNAME.
Exploitation
Step 1: confirm the dangling CNAME
Resolve the hostname and check that it still lands on CloudFront while no distribution claims it. For partners.ubnt.com the answer was yes on both counts, which is the condition described above.
Step 2: claim the hostname in your own CloudFront account
The researcher claimed the domain for the proof of concept with the following setup:

The screenshot shows the setup he used to claim the domain for the proof of concept. From that moment CloudFront serves his content for requests to the Ubiquiti hostname.
Step 3: serve content and prove control
He placed a file under /login for validation, to show what a possible variant of the attack would look like:
http://partners.ubnt.com/login
He placed a file under /login for validation. The PoC image:

The PoC image:
Root cause
CloudFront accepts a Custom CNAME from any account without verifying that the requester controls the hostname. The DNS record for partners.ubnt.com still pointed at CloudFront, but no CloudFront origin had the domain set as a CNAME. The two facts together are enough: the CDN has no reason to refuse the claim, and DNS still sends visitors to the CDN.
CloudFront itself performs no ownership check at claim time. The report's own recommendation reflects this: remove the DNS entry for the domain, and make sure DNS records pointing to CloudFront, and to other services, are removed constantly when they stop being used.
Impact
The consequences are described as pretty bad. With the hostname claimed, the attacker can serve whatever he likes on the domain, including content that fetches httpOnly cookies. He would also be able to issue an SSL certificate for the domain through AlphaSSL or Let's Encrypt, since those only need meta or file verification to issue the certificate, which would extend the attack to reading secure cookies as well.
There is no way for a visitor of the page to validate that the content on the domain is not served by UBNT, which makes it extremely easy to target the organisation with fake login forms or spear phishing that uses its own domain to plant the attack. The impact applies to anyone who visits the hostname while the attacker holds the claim.
Fix
The report recommends removing the DNS entry for this domain, and continuously removing DNS records that point to CloudFront, and to other services, once they are no longer used. The report does not describe a change made by CloudFront or by Ubiquiti beyond that recommendation.
Variants to test
- Check other hostnames in the same DNS zone for CNAMEs to CloudFront that no longer have a distribution. A positive result is a name that resolves to CloudFront and can be attached as a Custom CNAME in your own account.
- Apply the same check to other CDNs and hosted services that accept custom hostnames, since the report notes that records pointing to other services should be cleaned up as well. A positive result is a hostname you can claim and serve content from.
- After claiming a name, request a certificate through a domain-validated CA using file or meta verification. A positive result is an issued certificate for the victim hostname.
Hunting notes
This kind of bug hides in DNS zones where hostnames were once fronted by a CDN and later retired without deleting the record. During recon, the signal is a CNAME to a CDN provider that no distribution claims as a Custom CNAME. Confirming it means trying to attach the hostname as a Custom CNAME in your own account and serving a file from it.
The researcher claimed the real hostname, placed a file under /login on it, and described the cookie and certificate consequences, which could turn a DNS hygiene issue into a phishing vector against the organisation's own domain.
What happened, in plain words
Ubiquiti runs a partner portal at partners.ubnt.com. That address was still listed in the internet's address book (DNS) as a pointer to Amazon CloudFront, a content delivery network (CDN) that serves websites from many locations. But no CloudFront account was actually using that name any more. CloudFront does not check who owns a name before letting an account attach it, so anyone who claimed the name first could control what CloudFront served for it. The researcher claimed partners.ubnt.com in his own CloudFront account and placed a file under /login on the real Ubiquiti address. This is called a subdomain takeover. The report was filed under privilege escalation and disclosed on 27 November 2016.
Context
The hostname was still published in DNS as a CNAME pointing at CloudFront, but no CloudFront distribution had that hostname configured as a Custom CNAME any more. That mismatch between DNS and the CDN configuration is the whole bug: CloudFront does not check who owns a hostname before letting an account attach it as a Custom CNAME, so whoever claims the dangling name first controls what the CDN serves for it.
The report describes this as a subdomain takeover, filed under privilege escalation, disclosed on 27 November 2016.
Setup
The researcher needed nothing on the target side: no account on partners.ubnt.com, no access to Ubiquiti infrastructure. The only requirement was a CloudFront account of his own, in which he could create a distribution and set a Custom CNAME. The precondition on the victim side is a DNS record that still resolves to CloudFront while no distribution claims that hostname.
Finding it
The starting observation is that CloudFront does not validate which user connects a CNAME'd domain to a CloudFront origin. If a domain still points to CloudFront but is not connected to any origin as a Custom CNAME, anyone can claim that domain and point it at whatever they want.
A vulnerable domain looks like this:

The image shows the state of a hostname that resolves to CloudFront without a distribution behind it. Checking partners.ubnt.com produced exactly that result: the domain was still pointing to CloudFront, but no CF origin had the domain set as a CNAME.
Exploitation
Step 1: confirm the dangling CNAME
Resolve the hostname and check that it still lands on CloudFront while no distribution claims it. For partners.ubnt.com the answer was yes on both counts, which is the condition described above.
Step 2: claim the hostname in your own CloudFront account
The researcher claimed the domain for the proof of concept with the following setup:

The screenshot shows the setup he used to claim the domain for the proof of concept. From that moment CloudFront serves his content for requests to the Ubiquiti hostname.
Step 3: serve content and prove control
He placed a file under /login for validation, to show what a possible variant of the attack would look like:
http://partners.ubnt.com/login
He placed a file under /login for validation. The PoC image:

The PoC image:
Root cause
CloudFront accepts a Custom CNAME from any account without verifying that the requester controls the hostname. The DNS record for partners.ubnt.com still pointed at CloudFront, but no CloudFront origin had the domain set as a CNAME. The two facts together are enough: the CDN has no reason to refuse the claim, and DNS still sends visitors to the CDN.
CloudFront itself performs no ownership check at claim time. The report's own recommendation reflects this: remove the DNS entry for the domain, and make sure DNS records pointing to CloudFront, and to other services, are removed constantly when they stop being used.
Impact
The consequences are described as pretty bad. With the hostname claimed, the attacker can serve whatever he likes on the domain, including content that fetches httpOnly cookies. He would also be able to issue an SSL certificate for the domain through AlphaSSL or Let's Encrypt, since those only need meta or file verification to issue the certificate, which would extend the attack to reading secure cookies as well.
There is no way for a visitor of the page to validate that the content on the domain is not served by UBNT, which makes it extremely easy to target the organisation with fake login forms or spear phishing that uses its own domain to plant the attack. The impact applies to anyone who visits the hostname while the attacker holds the claim.
Fix
The report recommends removing the DNS entry for this domain, and continuously removing DNS records that point to CloudFront, and to other services, once they are no longer used. The report does not describe a change made by CloudFront or by Ubiquiti beyond that recommendation.
Variants to test
- Check other hostnames in the same DNS zone for CNAMEs to CloudFront that no longer have a distribution. A positive result is a name that resolves to CloudFront and can be attached as a Custom CNAME in your own account.
- Apply the same check to other CDNs and hosted services that accept custom hostnames, since the report notes that records pointing to other services should be cleaned up as well. A positive result is a hostname you can claim and serve content from.
- After claiming a name, request a certificate through a domain-validated CA using file or meta verification. A positive result is an issued certificate for the victim hostname.
Hunting notes
This kind of bug hides in DNS zones where hostnames were once fronted by a CDN and later retired without deleting the record. During recon, the signal is a CNAME to a CDN provider that no distribution claims as a Custom CNAME. Confirming it means trying to attach the hostname as a Custom CNAME in your own account and serving a file from it.
The researcher claimed the real hostname, placed a file under /login on it, and described the cookie and certificate consequences, which could turn a DNS hygiene issue into a phishing vector against the organisation's own domain.
Glossary
- DNS: the internet's address book, translating names like
partners.ubnt.cominto the servers that answer for them. - CNAME: a DNS record that says "this name is an alias for another name"; here it pointed
partners.ubnt.comat CloudFront. - CloudFront: Amazon's content delivery network, a service that caches and serves websites from many locations.
- CDN: content delivery network, a service that serves content on behalf of a website from servers close to visitors.
- Custom CNAME: a setting in a CloudFront account that lets a distribution answer for a chosen hostname.
- Distribution: a CloudFront configuration that defines where content comes from (the origin) and which hostnames it answers for.
- Origin: the server or storage that CloudFront fetches the real content from.
- Subdomain takeover: claiming a hostname that still points at a service but is no longer claimed by its owner, so you control what is served for it.
- Privilege escalation: gaining access or control beyond what you are supposed to have.
- httpOnly cookie: a cookie that JavaScript in the page cannot read, used to protect session data from script-based theft.
- Secure cookie: a cookie that the browser only sends over HTTPS.
- SSL certificate: a digital document that lets a browser verify it is talking securely to the real owner of a domain.
- AlphaSSL: a certificate authority that issues SSL certificates.
- Let's Encrypt: a free certificate authority that issues SSL certificates.
- Domain-validated CA: a certificate authority that issues a certificate after checking only that you control the domain, for example by placing a file on it or a meta tag in a page.
- Meta verification: proving domain control by adding a meta tag to a page served from the domain.
- File verification: proving domain control by placing a file at a known path on the domain.
- Spear phishing: a targeted phishing attack aimed at a specific organisation or person.
- Recon: the information-gathering phase of security testing.
- DNS zone: a portion of the DNS namespace managed together, for example all names under a company's domain.