Bypass Health Check endpoints whitelist
The health check endpoints on GitLab Omnibus were protected by an IP whitelist only when accessed over HTTPS, but the same endpoints were reachable over HTTP without the whitelist. An attacker could repeatedly call these endpoints over HTTP to cause a denial of service.
GitLab
Originally disclosed on GitLab
- Fixed in under an hour
- Disclosed after under an hour
HackerOne report #1653132 by zarloc on 2022-07-28, assigned to GitLab Team:
Report | How To Reproduce
Report
Summary
On a omnibus installtion of GitLab, by default the health check endpoints are protected with a whitelist config as: ['127.0.0.0/8', '::1/128'], but you can bypass this whitelist when accessing these endpoints with HTTP scheme without 301 to HTTPS scheme.
This result in a vector of denial of service for GitLab Omnibus instance
Steps to reproduce
On HTTPS scheme
curl 'https://gitlab.exemple.com/-/readiness?all=1'
{"error":"Not Found","status":404}
On HTTP scheme
curl 'http://gitlab.exemple.com/-/readiness?all=1'
{"status":"ok","master_check":[{"status":"ok"}],"db_check":[{"status":"ok"}],"redis_check":[{"status":"ok"}],"cache_check":[{"status":"ok"}],"queues_check":[{"status":"ok"}],"shared_state_check":[{"status":"ok"}],"trace_chunks_check":[{"status":"ok"}],"rate_limiting_check":[{"status":"ok"}],"sessions_check":[{"status":"ok"}],"gitaly_check":[{"status":"ok","labels":{"shard":"default"}}]}
Impact
Denial of Service if attacker call quickly this endpoint
Examples
Bug actually present in 15.2.0-ee, don't know in which version this comportment appear
What is the current bug behavior?
Don't receive a 301 to HTTPS scheme or apply whitelist to the HTTP endpoints.
What is the expected correct behavior?
Receive a 301 to HTTPS scheme or apply whitelist to HTTP endpoints.
Relevant logs and/or screenshots
The default config include gitlab-health.conf file which include proxy to health check endpoints without whitelist.
Nginx config (/var/opt/gitlab/nginx/conf/gitlab-http.conf)
server { ## HTTPS redirect server
listen *:80;
server_name gitlabexemple.com;
server_tokens off; ## Don't show the nginx version number, a security best practice
location /.well-known/acme-challenge/ {
root /var/opt/gitlab/nginx/www/;
}
location / {
return 301 https://gitlab.exemple.com:443$request_uri;
}
# health checks configuration
include /var/opt/gitlab/nginx/conf/gitlab-health.conf;
access_log /var/log/gitlab/nginx/gitlab_access.log gitlab_access;
error_log /var/log/gitlab/nginx/gitlab_error.log error;
}
Nginx /var/opt/gitlab/nginx/conf/gitlab-health.conf
location /error.txt {
# return code here is ignored by the error_page directive
return 500 'nginx returned $status when communicating with gitlab-workhorse\n';
}
location /error.json {
# return code here is ignored by the error_page directive
return 500 '{"error":"nginx returned $status when communicating with gitlab-workhorse","status":$status}\n';
}
location = /-/health {
proxy_cache off;
proxy_pass http://gitlab-workhorse;
error_page 404 500 502 /error.txt;
}
location = /-/readiness {
proxy_cache off;
proxy_pass http://gitlab-workhorse;
error_page 404 500 502 /error.json;
}
location = /-/liveness {
proxy_cache off;
proxy_pass http://gitlab-workhorse;
error_page 404 500 502 /error.json;
}
Output of checks
Access to HTTP health check endpoint need to return 404 or 301 to HTTPS which contain whitelist checking.
curl 'http://gitlab.exemple.com/-/readiness?all=1'
{"error":"Not Found","status":404}
Results of GitLab environment info
System information
System:
Proxy: no
Current User: git
Using RVM: no
Ruby Version: 2.7.5p203
Gem Version: 3.1.4
Bundler Version:2.3.15
Rake Version: 13.0.6
Redis Version: 6.2.7
Sidekiq Version:6.4.0
Go Version: unknown
GitLab information
Version: 15.2.0-ee
Revision: d836c22d87f
Directory: /opt/gitlab/embedded/service/gitlab-rails
DB Adapter: PostgreSQL
DB Version: 12.10
URL: https://gitlab.exemple.com
HTTP Clone URL: https://gitlab.exemple.com/some-group/some-project.git
SSH Clone URL: [email protected]:some-group/some-project.git
Elasticsearch: no
Geo: no
Using LDAP: no
Using Omniauth: yes
Omniauth Providers:
GitLab Shell
Version: 14.9.0
Repository storage paths:
- default: /var/opt/gitlab/git-data/repositories
GitLab Shell path: /opt/gitlab/embedded/service/gitlab-shell
Impact
Denial of service on the whole GitLab instance.
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
Root cause
The Nginx configuration included the health check endpoints in the HTTP server block without applying the IP whitelist, and the HTTP server did not redirect these specific paths to HTTPS.
Impact
An attacker could cause a denial of service on the whole GitLab instance by rapidly calling the health check endpoint over HTTP.
What the attacker needed
GitLab Omnibus installation with default config; Network access to the HTTP port
The fix
The HTTP server should redirect requests for health check endpoints to HTTPS or apply the same IP whitelist to HTTP requests.
How it was found
- Send a request to the readiness endpoint over HTTPS and observe a 404 error.
- Send the same request over HTTP and observe a successful response with health check details.
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.
GitLab has special health check pages that show if the system is working. These pages were supposed to be accessible only from the local machine, but the protection was only applied when using the secure HTTPS connection. By using the unencrypted HTTP connection, anyone could reach these pages and flood them with requests, potentially making the whole GitLab instance slow or unavailable.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.