Skip to content
Path traversal Disclosed report Intermediate

with uploader, anyone can read files under specific folders including export project tarball

The wiki attachment upload accepted a user-supplied file.path parameter, allowing an attacker to read files under specific directories, including other users' export files. An attacker could download the attachment to obtain the exported repository.

GitLab

Originally disclosed on GitLab

  • Fixed in 3 months
  • Disclosed after 3 months

HackerOne report #762554 by manassehzhou on 2019-12-20, assigned to @dcouture:

Summary

You can specify any path through file.path during post when uploading any attachment to wiki page, which lead to the possibility of reading anyone's export file.

Steps to reproduce

To begin with:

[@]root user need to export any of his repos, and it will appears in /opt/gitlab/embedded/service/gitlab-rails/public/uploads/-/system/import_export_upload/export_file/{project_id} like this

1.png
1.png From the original on GitLab
  1. Go to the wiki page, upload file, open burp suite and capture the packet

    2.png
    2.png From the original on GitLab
  2. modify a little bit.

    Add field file.path, then upload.

    3.png
    3.png From the original on GitLab
  3. download the attachment

    5.png
    5.png From the original on GitLab

    unzip you can find the exported repo.

    6.png
    6.png From the original on GitLab
  4. read anyone's export or anything under these directories:

    which is defined in /lib/gitlab/middleware/multipart.rb

    Ruby
        allowed_paths = [  
            ::FileUploader.root,  
            Gitlab.config.uploads.storage_path,  
            File.join(Rails.root, 'public/uploads/tmp')  
          ]  
    

Impact

You can specify any path through file.path during post when uploading any attachment to wiki page, which lead to the possibility of reading anyone's export file.

p.s. need to guess the directory.

What is the current bug behavior?

with file.path posted, the user can read any file under mentioned directories.

What is the expected correct behavior?

file.path should be filtered.

Results of GitLab environment info

running on docker with latest version.

8.png
8.png From the original on GitLab

Impact

You can specify any path through file.path during post when uploading any attachment to wiki page, which lead to the possibility of reading anyone's export file.

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

Root cause

The application accepted a client-supplied file.path during upload without filtering, allowing reads under the listed directories.

What the attacker needed

Access to a wiki page; ability to intercept HTTP requests; knowledge of target file path

The fix

The file.path parameter should be filtered to prevent arbitrary file reads.

How it was found

  1. Export a repository as root user to create an export file in a known directory.
  2. Go to a wiki page, upload a file, and capture the request with a proxy.
  3. Add a file.path field to the request and upload.
  4. Download the attachment and unzip it to obtain the exported repository.

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 upload a file to a website, the server usually decides where to save it. In this case, the website let the user specify the exact path where the file should be read from. That meant an attacker could point to someone else's private export file and download it.

What is Path traversal?

Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.

More from GitLab

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Path traversal and file inclusion

The lesson behind this report.

Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.