Skip to content
Subdomain takeover Disclosed report Intermediate

Subdomain Takeover (and Stored XSS) via Trailing Dot at https://coding-exercises.udemy.com

A Udemy subdomain was vulnerable to takeover because GitBook's custom domain feature mishandled trailing dots, allowing an attacker to claim the subdomain.

cha5m Follow

Originally disclosed on HackerOne

Informational View original
  • Fixed in 8 months
  • Paid in 8 months
  • Disclosed after 13 months

Hello @Udemy!

Summary

I previously reported a cross-site scripting vulnerability ( #222337 ) at coding-exercises.udemy.com. I recently discovered that GitBook-hosted sites are also vulnerable to subdomain takeovers due to a trailing dot vulnerability in the GitBook "Custom Domain" feature (seen below).

Screen_Shot_2017-04-24_at_9.24.06_PM.png
Screen_Shot_2017-04-24_at_9.24.06_PM.png From the original on HackerOne

Proof of Concept

The taken-over subdomain can be found here: https://coding-exercises.udemy.com. (notice the trailing dot).

First, we will look at the dig results for coding-exercises.udemy.com. (with the trailing dot)

Chases-MacBook-Air:~ chase$ dig coding-exercises.udemy.com.

; <<>> DiG 9.8.3-P1 <<>> coding-exercises.udemy.com.
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 38225
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;coding-exercises.udemy.com.	IN	A

;; ANSWER SECTION:
coding-exercises.udemy.com. 1	IN	CNAME	www.gitbooks.io.
www.gitbooks.io.	3301	IN	CNAME	cdn.gitbook.com.
cdn.gitbook.com.	2494	IN	A	138.197.194.9

;; Query time: 342 msec
;; SERVER: 192.168.1.1#53(192.168.1.1)
;; WHEN: Mon Apr 24 21:24:39 2017
;; MSG SIZE  rcvd: 115

And now the dig results for coding-exercises.udemy.com

Chases-MacBook-Air:~ chase$ dig coding-exercises.udemy.com

; <<>> DiG 9.8.3-P1 <<>> coding-exercises.udemy.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 1203
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;coding-exercises.udemy.com.	IN	A

;; ANSWER SECTION:
coding-exercises.udemy.com. 267	IN	CNAME	www.gitbooks.io.
www.gitbooks.io.	3268	IN	CNAME	cdn.gitbook.com.
cdn.gitbook.com.	2461	IN	A	138.197.194.9

;; Query time: 785 msec
;; SERVER: 192.168.1.1#53(192.168.1.1)
;; WHEN: Mon Apr 24 21:25:12 2017
;; MSG SIZE  rcvd: 115

Mitigation

I noticed that this service is hosted by GitBook, however, your bug bounty brief does not state that third-party hosted services being out of scope. I have also reported these issues directly to GitBook in an attempt to get them resolved ASAP. However, it might be worthwhile for you, an actual GitBook customer, to reach out directly to get them resolved quicker.

Example

Here is an example of another report with a trailing dot causing a subdomain takeover in a service:

Please let me know if you have any other questions. I would be more than happy to help! :)

Thank you and best regards, n0rb3r7

The original report as published on HackerOne, by cha5m. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Impact

An attacker could take over the subdomain and host malicious content on it.

What the attacker needed

GitBook custom domain feature; trailing dot in domain name

How it was found

  1. Query the DNS for the subdomain with a trailing dot and observe it resolves to GitBook.
  2. Query the DNS for the subdomain without the trailing dot and observe the same resolution.
  3. Access the subdomain with a trailing dot to see the taken-over content.

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 report has not been written yet. The Original tab links to the source.

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.

More by cha5m

View all

4 more disclosed reports, best first.

More from Udemy

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Subdomain takeover

The lesson behind this report.

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.