Chaining multiple low-impact bugs to arbitrary file read in GitLab
A directory traversal in GitLab's template API allowed reading files with a .gitignore extension, and a separate bug left symbolic links from failed project imports in a predictable temporary directory. By chaining them, an attacker could read arbitrary files such as /etc/passwd.
Since around August 2018, I began to read the source code of GitLab and test it over and over. The time pays me back, during the first several months I found some critical bugs (mentioned in my previous posts).
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the template finder concatenated user input into a file path without sanitising directory traversal, and the import process failed to clean up temporary directories containing symbolic links.
Impact
An attacker could read arbitrary files on the GitLab server, such as /etc/passwd, by chaining the two low-impact bugs.
What the attacker needed
Ability to import a project; crafted tarball with a symbolic link; access to the template API
How it was found
- Create a project tarball containing a symbolic link with a .gitignore extension that points to a sensitive file.
- Import the tarball; the import fails and leaves the symbolic link in a temporary directory.
- Note the path of the leftover symbolic link from the import error page.
- Use the template API with a directory traversal payload to read the symbolic link, which returns the contents of the target file.
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 write-up has not been written yet. The Original tab links to the source.
The template API let users ask for a template by name, but it did not properly check the name, so users could use '../' to reach other folders. Separately, when a project import failed, GitLab left behind a symbolic link (a shortcut file) that pointed to a sensitive file. By combining these two issues, an attacker could make the API follow the leftover link and return the contents of a sensitive file.
What is Path traversal?
Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.