Arbitrary file read in project uploads controller via path traversal
The project uploads controller allowed path traversal in the filename parameter, enabling an attacker to read arbitrary files on the server. By crafting a URL with encoded directory traversal sequences, an attacker could access sensitive files like /etc/passwd.
GitLab
Originally disclosed on GitLab
- Fixed in 3 days
- Disclosed after 3 days
⚠️ Please read the process on how to fix security issues before starting to work on the issue. Vulnerabilities must be fixed in a security mirror.
HackerOne report #1994725 by pwnie on 2023-05-20, assigned to H1 Triage:
Report | Attachments | How To Reproduce
Report
Summary
The project uploads controller is vulnerable to path traversal in the :filename parameter which leads to arbitrary file reads
Steps to reproduce
- Create a new group and recursively create 10 new subgroups
Example: http://gitlab.com/11/22/33/44/55/66/88/99/aa/bb/cc/dd/ notice the deeply nested subgroups and a project at the end (dd)
1.5 If you don't want to do this step you can just use mine: https://gitlab.com/11753220/22/33/44/55/66/77/88/99/10/11
Impact
Arbitrary file read
What is the current bug behavior?
:filename can contain path traversal characters
What is the expected correct behavior?
Sanitize :filename
Relevant logs and/or screenshots
Output of checks
The bug happens on Gitlab
Impact
Arbitrary file read
Attachments
Warning: Attachments received through HackerOne, please exercise caution!
How To Reproduce
Please add reproducibility information to this section:
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 application failed to sanitise the filename parameter, allowing directory traversal sequences to be used to access files outside the intended uploads directory.
Impact
An attacker could read arbitrary files on the server, potentially exposing sensitive information.
What the attacker needed
Ability to create groups and projects
The fix
The filename parameter should be sanitised to prevent path traversal characters.
How it was found
- Create a new group and recursively create 10 new subgroups, with a project at the end.
- Navigate to the crafted URL containing the uploads path and encoded directory traversal sequences to read /etc/passwd.
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.
This is a path traversal bug. The web server takes a filename from the URL and uses it to find a file on disk, but it doesn't check that the filename stays inside the intended folder. By using special characters like '..' (which means 'go up one folder'), an attacker can escape the uploads folder and read any file the server can access, such as system password files.
What is Path traversal?
Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.