Skip to content
Access control Disclosed report Advanced

Workhorse bypass allows files in /tmp to be read via Maven Repository APIs

Workhorse, GitLab's reverse proxy, decoded %2f as / when matching routes, so a project path containing an encoded slash was treated as a valid Maven package upload route. This let an authenticated user bypass Rails authorisation and use file.path or file.remote_id parameters to test whether arbitrary files or object storage objects exist.

GitLab

Originally disclosed on GitLab

Critical View original
  • Fixed in 8 days
  • Disclosed after 8 days

HackerOne report #908796 by ledz1996 on 2020-06-26, assigned to @ankelly:

Summary

Similar issue to #848415 and #876998
As far as we know there exists an UploadedFile.from_params leads to a series of Workhorse bypass vulnerability.
There exists one in maven APIs before but have been patched due to this issue

https://gitlab.com/gitlab-org/gitlab/-/issues/209080

However, the route Detecting in Workhorse sees %2f as /.
So this mean

  • If a full path for a project to put in for the API is 000173%2fpackages%2fmaven, the Workhorse will see this as 000173/packages/maven and treat this as a valid path for

internal/upstream/routes.go

Go
		route("PUT", apiPattern+`v4/projects/[0-9]+/packages/maven/`, upload.BodyUploader(api, signingProxy, preparers.packages)),  

This will proceed us to bypass the Workhorse authorizing in RoR part, thus result in system file/object storage enumerating by using file.path or file.remote_id.

Steps to reproduce

  1. Create an Project and Note the ID of the Project. For example: ID 40
  2. Create a subgroup and project with the following path: 0040/packages/maven
  3. Send the PUT request to the following URL: /api/v4/projects/0040%2fpackages%2fmaven/package/?file.path=../../../../../../../../../../../../etc/passwd Along with Header: Private-Token: which is the token for accessing the API

or /api/v4/projects/0040%2fpackages%2fmaven/package/?file.remote_id=object-id for Object Storage
4. If its response with 500 -> the file/ object is not exists, 400 -> The file exists.

Why 500 code means not exists:
fileenum1.PNG

Uploaded a video for this:
bandicam_2020-06-26_17-13-53-860.mp4

Results of GitLab environment info


System information  
System:		Ubuntu 16.04  
Proxy:		no  
Current User:	git  
Using RVM:	no  
Ruby Version:	2.6.6p146  
Gem Version:	2.7.10  
Bundler Version:1.17.3  
Rake Version:	12.3.3  
Redis Version:	5.0.9  
Git Version:	2.27.0  
Sidekiq Version:5.2.7  
Go Version:	unknown

GitLab information  
Version:	13.1.0-ee  
Revision:	1fa237df2f4  
Directory:	/opt/gitlab/embedded/service/gitlab-rails  
DB Adapter:	PostgreSQL  
DB Version:	11.7  
URL:		http://gitlab.example.vm  
HTTP Clone URL:	http://gitlab.example.vm/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: saml

GitLab Shell  
Version:	13.3.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

Disclose existence of a file in system, Object Storage, etc.

Attachments

Warning: Attachments received through HackerOne, please exercise caution!

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

Impact

An authenticated user could disclose the existence of files on the system or objects in object storage, but not read their contents.

What the attacker needed

A GitLab account; ability to create projects and subgroups; a private API token

How it was found

  1. Create a project and note its numeric ID.
  2. Create a subgroup and project whose path is the ID followed by /packages/maven.
  3. Send a PUT request to the Maven package API using the encoded project path and a file.path or file.remote_id parameter, with a valid private token.
  4. Observe the response: 500 means the file does not exist, 400 means it exists.

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 uses a helper program called Workhorse to check some requests before they reach the main application. Workhorse matched the URL after turning an encoded slash into a real slash, so a project name with an encoded slash looked like a different, allowed path. That let a logged-in user make the system check for files outside the project, such as system files.

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

More from GitLab

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.