Skip to content
SSRF Disclosed report Intermediate

Mirroring repositories allows for SSRF

The repository mirroring feature allowed an HTTP URL that could redirect to internal resources, and the git command used to check the remote did not disable redirect following. An attacker could make the GitLab server send HTTP requests to internal addresses and observe whether they succeeded.

GitLab

Originally disclosed on GitLab

  • Fixed in 8 months
  • Disclosed after 8 months

HackerOne report #1204291 by forcesunseen on 2021-05-20, assigned to @cmaxim:

Report | Attachments | How To Reproduce

Report

Summary

The repository mirroring functionality can be configured with an HTTP URL which can then be set up to redirect to internal resources.

Gitaly passes most git commands with the http.followRedirects=false option to avoid following redirects, although this was not happening in this case: https://gitlab.com/gitlab-org/gitaly/-/blob/master/ruby/lib/gitlab/git/repository_mirroring.rb#L98

cmd = %W[#{Gitlab.config.git.bin_path} --git-dir=#{path} ls-remote --heads --tags #{remote}]

The HTTP response is not returned, although we can tell whether the request was successful or not.

Steps to reproduce
  1. Set up an external server which responds with HTTP redirects. (Example script attached)
  2. Go into the "Mirroring repositories" section of a project (Settings - > Repository)
  3. Enter your external server URL in the Git repository URL field and click on Mirror repository
  4. When the update button is clicked next to the newly created repository the HTTP request will be made to the external server and redirects will be followed.
Impact

An attacker can make HTTP requests to internal resources.

What is the current bug behavior?

git follows HTTP redirects.

What is the expected correct behavior?

git should not follow HTTP redirects, in the same way that other git commands are configured like this.

Relevant logs and/or screenshots

Video attached to this report. The top terminal is the external server and the bottom terminal is the server GitLab is running on.

Output of checks
Results of GitLab environment info
System information  
System:		  
Proxy:		no  
Current User:	git  
Using RVM:	no  
Ruby Version:	2.7.2p137  
Gem Version:	3.1.4  
Bundler Version:2.1.4  
Rake Version:	13.0.3  
Redis Version:	6.0.10  
Git Version:	2.29.0  
Sidekiq Version:5.2.9  
Go Version:	unknown

GitLab information  
Version:	13.10.3-ee  
Revision:	db2e358dba4  
Directory:	/opt/gitlab/embedded/service/gitlab-rails  
DB Adapter:	PostgreSQL  
DB Version:	12.6  
URL:		http://gitlab.skynet.party  
HTTP Clone URL:	http://gitlab.skynet.party/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:	13.17.0  
Repository storage paths:  
- default: 	/var/opt/gitlab/git-data/repositories  
GitLab Shell path:		/opt/gitlab/embedded/service/gitlab-shell  
Git:		/opt/gitlab/embedded/bin/git  

Impact

An attacker can make HTTP requests to internal resources.

Attachments

Warning: Attachments received through HackerOne, please exercise caution!

How To Reproduce

Please add reproducibility information to this section:

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

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 git ls-remote command used for repository mirroring did not include the http.followRedirects=false option, unlike other git commands in Gitaly.

Impact

An attacker can make HTTP requests to internal resources, and although the response is not returned, they can tell whether the request was successful or not.

What the attacker needed

Access to a project's mirroring settings; ability to set up an external server

The fix

The git command should be configured to not follow HTTP redirects, as other git commands are.

How it was found

  1. Set up an external server that responds with HTTP redirects.
  2. Go to the Mirroring repositories section of a project (Settings -> Repository).
  3. Enter the external server URL in the Git repository URL field and click Mirror repository.
  4. Click the update button next to the newly created repository; the HTTP request will be made to the external server and redirects will be followed.

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.

When you add a mirror repository, GitLab runs a git command to check the remote URL. That command followed HTTP redirects, so a malicious URL could redirect the request to an internal server. The attacker cannot see the response, but can tell if the request worked, which is enough to probe internal systems.

What is SSRF?

The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.

More from GitLab

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Server-side request forgery (SSRF)

The lesson behind this report.

The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.